blob: 2d3095a6b23d6e937b112c5029dccdf3b65d8a4e (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/**
* This button has no extra functionality on top if its base [[email protected]] class.
*
* The purpose of this Button subclass is to have a destructable
* struct as the argument in GJS event handlers.
*/
public class Astal.Button : Gtk.Button {
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);
construct {
add_events(Gdk.EventMask.SCROLL_MASK);
add_events(Gdk.EventMask.SMOOTH_SCROLL_MASK);
enter_notify_event.connect((self, event) => {
hover(HoverEvent(event) { lost = false });
});
leave_notify_event.connect((self, event) => {
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));
});
}
}
public enum Astal.MouseButton {
PRIMARY = 1,
MIDDLE = 2,
SECONDARY = 3,
BACK = 4,
FORWARD = 5,
}
/**
* Struct for [[email protected]]
*/
public struct Astal.ClickEvent {
bool release;
uint time;
double x;
double y;
Gdk.ModifierType modifier;
MouseButton button;
public ClickEvent(Gdk.EventButton event) {
this.time = event.time;
this.x = event.x;
this.y = event.y;
this.button = (MouseButton)event.button;
this.modifier = event.state;
}
}
/**
* Struct for [[email protected]]
*/
public struct Astal.HoverEvent {
bool lost;
uint time;
double x;
double y;
Gdk.ModifierType modifier;
Gdk.CrossingMode mode;
Gdk.NotifyType detail;
public HoverEvent(Gdk.EventCrossing event) {
this.time = event.time;
this.x = event.x;
this.y = event.y;
this.modifier = event.state;
this.mode = event.mode;
this.detail = event.detail;
}
}
/**
* Struct for [[email protected]]
*/
public struct Astal.ScrollEvent {
uint time;
double x;
double y;
Gdk.ModifierType modifier;
Gdk.ScrollDirection direction;
double delta_x;
double delta_y;
public ScrollEvent(Gdk.EventScroll event) {
this.time = event.time;
this.x = event.x;
this.y = event.y;
this.modifier = event.state;
this.direction = event.direction;
this.delta_x = event.delta_x;
this.delta_y = event.delta_y;
}
}
|