Browse code
feat: Focus browser window upon activation
... | ... |
@@ -22,6 +22,44 @@ namespace Amber { |
22 | 22 |
|
23 | 23 |
} |
24 | 24 |
|
25 |
+ [DBus (name = "com.paysonwallach.attention")] |
|
26 |
+ private interface WindowManagerBuseIFace : Object { |
|
27 |
+ public abstract void activate_window_demanding_attention () throws DBusError, IOError; |
|
28 |
+ |
|
29 |
+ } |
|
30 |
+ |
|
31 |
+ private class WindowManagerProxy : Object { |
|
32 |
+ private static Once<WindowManagerProxy> instance; |
|
33 |
+ |
|
34 |
+ public static unowned WindowManagerProxy get_default () { |
|
35 |
+ return instance.once (() => { |
|
36 |
+ return new WindowManagerProxy (); |
|
37 |
+ }); |
|
38 |
+ } |
|
39 |
+ |
|
40 |
+ construct { |
|
41 |
+ try {} catch (IOError err) { |
|
42 |
+ warning (err.message); |
|
43 |
+ } |
|
44 |
+ } |
|
45 |
+ |
|
46 |
+ public void activate_window_demanding_attention () { |
|
47 |
+ try { |
|
48 |
+ WindowManagerBuseIFace? window_manager = Bus.get_proxy_sync ( |
|
49 |
+ BusType.SESSION, |
|
50 |
+ "com.paysonwallach.attention", |
|
51 |
+ "/com/paysonwallach/attention"); |
|
52 |
+ |
|
53 |
+ window_manager.activate_window_demanding_attention (); |
|
54 |
+ } catch (DBusError err) { |
|
55 |
+ error (@"DBusError: $(err.message)"); |
|
56 |
+ } catch (IOError err) { |
|
57 |
+ error (@"IOError: $(err.message)"); |
|
58 |
+ } |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ } |
|
62 |
+ |
|
25 | 63 |
public class Helper : Application { |
26 | 64 |
private uint watch_id = 0U; |
27 | 65 |
|
... | ... |
@@ -38,6 +76,8 @@ namespace Amber { |
38 | 76 |
Config.BRIDGE_DBUS_OBJECT_PATH); |
39 | 77 |
|
40 | 78 |
browser_proxy.open (uris); |
79 |
+ WindowManagerProxy.get_default () |
|
80 |
+ .activate_window_demanding_attention (); |
|
41 | 81 |
release (); |
42 | 82 |
} |
43 | 83 |
|