blob: 0b588e9af6ba8e693d1ae5b2bd88461351984ae0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/**
* EventBox is a [[email protected]] subclass which is meant to fix an issue with its
* [[email protected]::enter_notify_event] and [[email protected]::leave_notify_event] when nesting EventBoxes
*
* Its css selector is `eventbox`.
*/
public class Astal.EventBox : Gtk.EventBox {
public signal void hover (HoverEvent event);
public signal void hover_lost (HoverEvent event);
public signal void click (ClickEvent event);
public signal void click_release (ClickEvent event);
public signal void scroll (ScrollEvent event);
public signal void motion (MotionEvent event);
static construct {
set_css_name("eventbox");
}
construct {
add_events(Gdk.EventMask.SCROLL_MASK);
add_events(Gdk.EventMask.SMOOTH_SCROLL_MASK);
add_events(Gdk.EventMask.POINTER_MOTION_MASK);
enter_notify_event.connect((self, event) => {
if (event.window == self.get_window() &&
event.detail != Gdk.NotifyType.INFERIOR) {
this.set_state_flags(Gtk.StateFlags.PRELIGHT, false);
hover(HoverEvent(event) { lost = false });
}
});
leave_notify_event.connect((self, event) => {
if (event.window == self.get_window() &&
event.detail != Gdk.NotifyType.INFERIOR) {
this.unset_state_flags(Gtk.StateFlags.PRELIGHT);
hover_lost(HoverEvent(event) { lost = true });
}
});
button_press_event.connect((event) => {
click(ClickEvent(event) { release = false });
});
button_release_event.connect((event) => {
click_release(ClickEvent(event) { release = true });
});
scroll_event.connect((event) => {
scroll(ScrollEvent(event));
});
motion_notify_event.connect((event) => {
motion(MotionEvent(event));
});
}
}
/**
* Struct for [[email protected]]
*/
public struct Astal.MotionEvent {
uint time;
double x;
double y;
Gdk.ModifierType modifier;
public MotionEvent(Gdk.EventMotion event) {
this.time = event.time;
this.x = event.x;
this.y = event.y;
this.modifier = event.state;
}
}
|