diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-24 19:58:27 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-24 19:58:27 +0200 |
commit | 5ad5531baa3ab7729427caf821fde6a6856da34e (patch) | |
tree | 016644484b3c5814879a0e910394e9b064d2b2d2 /src/renderers/pieWindow.vala | |
parent | 394ad3b32f9f79775bcac4c6cc2a4dfa74586800 (diff) | |
parent | 309d161f6d464fcea2de200bb3cb5a7cb784b6d3 (diff) |
Updated version 0.7.1 from 'upstream/0.7.1'
with Debian dir 55ec79e844cfb79babaf0535d64bfdb9bd5b22f7
Diffstat (limited to 'src/renderers/pieWindow.vala')
-rw-r--r-- | src/renderers/pieWindow.vala | 145 |
1 files changed, 102 insertions, 43 deletions
diff --git a/src/renderers/pieWindow.vala b/src/renderers/pieWindow.vala index d2bf61f..a5142df 100644 --- a/src/renderers/pieWindow.vala +++ b/src/renderers/pieWindow.vala @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2016 by Simon Schneegans +// Copyright (c) 2011-2017 by Simon Schneegans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -102,6 +102,12 @@ public class PieWindow : Gtk.Window { private string search_string = ""; ///////////////////////////////////////////////////////////////////// + /// Used to identify wayland sessions. + ///////////////////////////////////////////////////////////////////// + + private bool wayland = GLib.Environment.get_variable("XDG_SESSION_TYPE") == "wayland"; + + ///////////////////////////////////////////////////////////////////// /// C'tor, sets up the window. ///////////////////////////////////////////////////////////////////// @@ -112,7 +118,7 @@ public class PieWindow : Gtk.Window { this.set_skip_taskbar_hint(true); this.set_skip_pager_hint(true); this.set_keep_above(true); - this.set_type_hint(Gdk.WindowTypeHint.POPUP_MENU); + this.set_type_hint(Gdk.WindowTypeHint.DOCK); this.set_decorated(false); this.set_resizable(false); this.icon_name = "gnome-pie"; @@ -186,8 +192,7 @@ public class PieWindow : Gtk.Window { }); this.show.connect_after(() => { - Gtk.grab_add(this); - FocusGrabber.grab(this.get_window(), true, true, false); + FocusGrabber.grab(this.get_window()); }); this.scroll_event.connect((e) => { @@ -209,8 +214,25 @@ public class PieWindow : Gtk.Window { public void load_pie(Pie pie) { this.renderer.load_pie(pie); - this.set_window_position(pie); - this.set_size_request(renderer.size_w, renderer.size_h); + + if (wayland) { + // wayland does not support client side window placement + // therefore we will make a fullscreen window + #if HAVE_GTK_3_22 + var monitor = Gdk.Display.get_default().get_monitor_at_point(this.back_x, this.back_y).get_geometry(); + int monitor_x = monitor.width; + int monitor_y = monitor.height; + #else + var screen = Gdk.Screen.get_default().get_root_window(); + int monitor_x = screen.get_width(); + int monitor_y = screen.get_height(); + #endif + + this.set_size_request(monitor_x, monitor_y); + } else { + this.set_window_position(pie); + this.set_size_request(renderer.size_w, renderer.size_h); + } } ///////////////////////////////////////////////////////////////////// @@ -226,15 +248,22 @@ public class PieWindow : Gtk.Window { this.back_sz_x++; this.back_sz_y++; - int screenx= Gdk.Screen.width(); - int screeny= Gdk.Screen.height(); + #if HAVE_GTK_3_22 + var monitor = Gdk.Display.get_default().get_monitor_at_point(this.back_x, this.back_y).get_geometry(); + int monitor_x = monitor.width; + int monitor_y = monitor.height; + #else + var screen = Gdk.Screen.get_default().get_root_window(); + int monitor_x = screen.get_width(); + int monitor_y = screen.get_height(); + #endif //allow some window movement from the screen borders //(some panels moves the window after it was realized) int dx = this.panel_sz - this.back_x; if (dx > 0) this.back_sz_x += dx; - dx = this.panel_sz - (screenx - this.back_x - this.back_sz_x +1); + dx = this.panel_sz - (monitor_x - this.back_x - this.back_sz_x +1); if (dx > 0) { this.back_sz_x += dx; this.back_x -= dx; @@ -243,7 +272,7 @@ public class PieWindow : Gtk.Window { int dy = this.panel_sz - this.back_y; if (dy > 0) this.back_sz_y += dy; - dy = this.panel_sz - (screeny - this.back_y - this.back_sz_y +1); + dy = this.panel_sz - (monitor_y - this.back_y - this.back_sz_y +1); if (dy > 0) { this.back_sz_y += dy; this.back_y -= dy; @@ -264,10 +293,10 @@ public class PieWindow : Gtk.Window { this.back_sz_y += this.back_y; this.back_y = 0; } - if (this.back_x + this.back_sz_x > screenx) - this.back_sz_x = screenx - this.back_x; - if (this.back_y + this.back_sz_y > screeny) - this.back_sz_y = screeny - this.back_y; + if (this.back_x + this.back_sz_x > monitor_x) + this.back_sz_x = monitor_x - this.back_x; + if (this.back_y + this.back_sz_y > monitor_y) + this.back_sz_y = monitor_y - this.back_y; this.background = new Image.capture_screen(this.back_x, this.back_y, this.back_sz_x, this.back_sz_y); } @@ -314,20 +343,27 @@ public class PieWindow : Gtk.Window { ///////////////////////////////////////////////////////////////////// private void get_mouse_position(out int mx, out int my) { - // get the mouse position - mx = 0; - my = 0; - Gdk.ModifierType mask; - - var display = Gdk.Display.get_default(); - var manager = display.get_device_manager(); - GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER); - - foreach(var device in list) { - if (device.input_source != Gdk.InputSource.KEYBOARD) { - this.get_window().get_device_position(device, out mx, out my, out mask); + #if HAVE_GTK_3_20 + var seat = Gdk.Display.get_default().get_default_seat(); + seat.get_pointer().get_position(null, out mx, out my); + #else + double x = 0.0; + double y = 0.0; + + var display = Gdk.Display.get_default(); + var manager = display.get_device_manager(); + GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER); + + foreach(var device in list) { + if (device.input_source != Gdk.InputSource.KEYBOARD) { + Gdk.Screen screen; + device.get_position( out screen, out x, out y ); + } } - } + + mx = (int) x; + my = (int) y; + #endif } ///////////////////////////////////////////////////////////////////// @@ -335,14 +371,19 @@ public class PieWindow : Gtk.Window { ///////////////////////////////////////////////////////////////////// private void set_mouse_position(int mx, int my) { - var display = Gdk.Display.get_default(); - var manager = display.get_device_manager(); - GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER); - foreach(var device in list) { - if (device.input_source != Gdk.InputSource.KEYBOARD) { - device.warp(Gdk.Screen.get_default(), mx, my); + #if HAVE_GTK_3_20 + var seat = Gdk.Display.get_default().get_default_seat(); + seat.get_pointer().warp(this.screen, mx, my); + #else + var display = Gdk.Display.get_default(); + var manager = display.get_device_manager(); + GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER); + foreach(var device in list) { + if (device.input_source != Gdk.InputSource.KEYBOARD) { + device.warp(Gdk.Screen.get_default(), mx, my); + } } - } + #endif } ///////////////////////////////////////////////////////////////////// @@ -350,6 +391,9 @@ public class PieWindow : Gtk.Window { ///////////////////////////////////////////////////////////////////// private bool draw_window(Cairo.Context ctx) { + int x, y; + this.get_position(out x, out y); + // paint the background image if there is no compositing if (this.has_compositing) { ctx.set_operator (Cairo.Operator.CLEAR); @@ -358,8 +402,6 @@ public class PieWindow : Gtk.Window { } else { //correct the background position if the window was moved //since the background image was captured - int x, y; - this.get_position(out x, out y); int dx = this.back_x - x; int dy = this.back_y - y; ctx.save(); @@ -370,9 +412,6 @@ public class PieWindow : Gtk.Window { ctx.restore(); } - // align the context to the center of the PieWindow - ctx.translate(this.renderer.center_x, this.renderer.center_y); - // get the mouse position int mouse_x, mouse_y; get_mouse_position( out mouse_x, out mouse_y ); @@ -381,9 +420,31 @@ public class PieWindow : Gtk.Window { double frame_time = this.timer.elapsed(); this.timer.reset(); + int center_x = this.renderer.center_x; + int center_y = this.renderer.center_y; + + // on wayland we have a fullscreen window and since we + // do not get the pointer location until the mouse moved + // we can only display the pie centered... + if (this.wayland) { + #if HAVE_GTK_3_22 + var monitor = Gdk.Display.get_default().get_monitor_at_point(mouse_x, mouse_y).get_geometry(); + center_x = monitor.width / 2; + center_y = monitor.height / 2; + #else + var screen = Gdk.Screen.get_default().get_root_window(); + center_x = screen.get_width() / 2; + center_y = screen.get_height() / 2; + #endif + } + + // align the context to the center of the PieWindow + x += center_x; + y += center_y; + ctx.translate(center_x, center_y); + // render the Pie - this.renderer.draw(frame_time, ctx, mouse_x - (int)this.renderer.center_x, - mouse_y - (int)this.renderer.center_y); + this.renderer.draw(frame_time, ctx, mouse_x - x, mouse_y - y); return true; } @@ -396,7 +457,6 @@ public class PieWindow : Gtk.Window { if (!this.closing) { this.closing = true; this.on_closing(); - Gtk.grab_remove(this); FocusGrabber.ungrab(); GLib.Timeout.add(10, () => { @@ -421,7 +481,6 @@ public class PieWindow : Gtk.Window { if (!this.closing) { this.closing = true; this.on_closing(); - Gtk.grab_remove(this); FocusGrabber.ungrab(); this.renderer.cancel(); |