5
5
namespace Eidete.Widgets {
7
public class Key : Label {
14
public bool iso_level3_shift;
17
public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){
23
this.iso_level3_shift = iso_level3_shift;
29
public class KeyView : Granite.Widgets.CompositedWindow{
7
public class YellowCircle : Granite.Widgets.CompositedWindow {
9
public YellowCircle (Gdk.RGBA color) {
10
this.skip_pager_hint = true;
11
this.skip_taskbar_hint = true;
12
this.set_keep_above (true);
14
this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
15
this.accept_focus = false;
17
this.draw.connect ( (ctx) => {
18
ctx.arc (this.get_allocated_width () / 2, this.get_allocated_height () / 2,
19
this.get_allocated_width () / 2, 0, 6.28318);
20
ctx.set_source_rgba (color.red, color.green, color.blue, color.alpha);
25
this.set_size_request (70, 70);
27
this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);
31
public new void move (int x, int y) {
32
base.move (x - (int)(this.get_allocated_width ()/2), y - (int)(this.get_allocated_height ()/2));
36
public class ClickWindow : Granite.Widgets.CompositedWindow {
37
public ClickWindow (int x, int y, int button) {
38
this.skip_pager_hint = true;
39
this.skip_taskbar_hint = true;
40
this.set_keep_above (true);
42
this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
43
this.accept_focus = false;
59
var lbl = new Gtk.Label (label);
60
lbl.attributes = new Pango.AttrList ();
61
lbl.attributes.insert (new Pango.AttrFontDesc (Pango.FontDescription.from_string ("16px")));
63
var css = new Gtk.CssProvider ();
65
css.load_from_data ("*{color:#fff; text-shadow:1 1 #000;}", -1);
66
} catch (Error e) { warning (e.message); }
67
lbl.get_style_context ().add_provider (css, 20000);
70
this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);
72
this.move (x + 5, y + 5);
74
Timeout.add (10, () => {
75
this.opacity -= 0.007;
76
if (this.opacity < 0.1) //prevent flickering
77
this.foreach ( (c) => this.remove (c) );
78
if (this.opacity <= 0) {
88
public class Key : Label {
95
public bool iso_level3_shift;
98
public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){
104
this.iso_level3_shift = iso_level3_shift;
110
public class KeyView : Granite.Widgets.CompositedWindow {
31
112
public int key_size;
32
113
public int fade_duration;
44
125
public Queue<Key> keys;
127
public YellowCircle circle;
46
129
public Cairo.ImageSurface key_bg;
48
131
[CCode (cname = "intercept_key_thread")]
49
132
public extern void *intercept_key_thread ();
51
134
public signal void captured (string keyvalue, bool released);
135
public signal void captured_mouse (int x, int y, int button);
136
public signal void captured_move (int x, int y);
54
138
public override bool draw (Cairo.Context ctx){
110
194
this.screen_h = h;
197
public KeyView (bool keyboard, bool mouse, bool mouse_circle, Gdk.RGBA mouse_circle_color){
114
198
this.key_size = 75;
115
199
this.fade_duration = 2000;
118
202
this.set_keep_above (true);
119
203
this.deletable = false;
120
204
this.resizable = false;
121
205
this.set_has_resize_grip (false);
122
206
this.skip_pager_hint = true;
123
this.skip_taskbar_hint = true;
125
this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
126
this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK |
127
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ;
207
this.skip_taskbar_hint = true;
208
this.accept_focus = false;
210
this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
211
this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK |
212
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ;
131
216
Cairo.RectangleInt rect = {0, 0, 1, 1};
132
217
this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle (rect), 0, 0);
244
this.circle = new YellowCircle (mouse_circle_color);
245
this.captured_move.connect ( (x, y) => {
246
this.circle.move (x, y);
247
//debug ("Moved to %i, %i\n", x, y);
252
this.captured_mouse.connect ( (x, y, button) => {
253
debug ("Button %i pressed at %i, %i ", button, x, y);
255
Timeout.add (10, () => { new ClickWindow (x, y, button); return false; });
158
259
this.captured.connect ( (keyvalue, released) => {
160
261
switch (keyvalue){