diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-08-13 13:51:23 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-08-13 13:51:23 +0200 |
commit | 9e618cc3f9a59038213aa8a91382a4c84315f569 (patch) | |
tree | 62a1ac64c4a6299e6ab787864ed3b97305acdecc /src/renderers | |
parent | 394ad3b32f9f79775bcac4c6cc2a4dfa74586800 (diff) | |
parent | d98e3381ccbe703a6df8fad73b69546dd72a8705 (diff) |
Merge branch 'release/0.7.1-1'0.7.1-1
Diffstat (limited to 'src/renderers')
-rw-r--r-- | src/renderers/centerRenderer.vala | 7 | ||||
-rw-r--r-- | src/renderers/pieRenderer.vala | 84 | ||||
-rw-r--r-- | src/renderers/pieWindow.vala | 145 | ||||
-rw-r--r-- | src/renderers/sliceRenderer.vala | 2 |
4 files changed, 152 insertions, 86 deletions
diff --git a/src/renderers/centerRenderer.vala b/src/renderers/centerRenderer.vala index 88b569c..65a28fa 100644 --- a/src/renderers/centerRenderer.vala +++ b/src/renderers/centerRenderer.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 @@ -188,8 +188,9 @@ public class CenterRenderer : GLib.Object { // draw caption if (Config.global.theme.caption && caption != null && this.activity.val > 0) { ctx.save(); - ctx.identity_matrix(); - ctx.translate(this.parent.center_x, (int)(Config.global.theme.caption_position) + this.parent.center_y); + double x, y; + ctx.get_current_point(out x, out y); + ctx.move_to(GLib.Math.floor(x), GLib.Math.floor(y)); caption.paint_on(ctx, this.activity.val*this.alpha.val); ctx.restore(); } diff --git a/src/renderers/pieRenderer.vala b/src/renderers/pieRenderer.vala index 32f3a5f..47d8b8e 100644 --- a/src/renderers/pieRenderer.vala +++ b/src/renderers/pieRenderer.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 @@ -175,28 +175,6 @@ public class PieRenderer : GLib.Object { set_show_mode(ShowPieMode.FULL_PIE); } - - private void get_mouse_and_screen(out int mousex, out int mousey, out int screenx, out int screeny) { - // get the mouse position and screen resolution - 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 ); - } - } - mousex= (int) x; - mousey= (int) y; - screenx= Gdk.Screen.width(); - screeny= Gdk.Screen.height(); - } - ///////////////////////////////////////////////////////////////////// /// Loads a Pie. All members are initialized accordingly. ///////////////////////////////////////////////////////////////////// @@ -239,12 +217,40 @@ public class PieRenderer : GLib.Object { + Config.global.theme.visible_slice_radius)*2*Config.global.theme.max_zoom); } - - - // get mouse position and screen resolution - int mouse_x, mouse_y, screen_x, screen_y; - get_mouse_and_screen( out mouse_x, out mouse_y, out screen_x, out screen_y ); + int mouse_x, mouse_y; + + #if HAVE_GTK_3_20 + var seat = Gdk.Display.get_default().get_default_seat(); + seat.get_pointer().get_position(null, out mouse_x, out mouse_y); + #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 ); + } + } + + mouse_x = (int) x; + mouse_y = (int) y; + #endif + + #if HAVE_GTK_3_22 + var monitor = Gdk.Display.get_default().get_monitor_at_point(mouse_x, mouse_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 //reduce the window size if needed to get closer to the actual mouse position int reduce_szx= 1; @@ -255,24 +261,24 @@ public class PieRenderer : GLib.Object { if (mouse_x < sz/2) { if (mouse_y < sz/2) showpie= ShowPieMode.CPIE_TOP_LEFT; //show 1/4 pie - else if (screen_y > 0 && screen_y-mouse_y < sz/2) + else if (monitor_y > 0 && monitor_y-mouse_y < sz/2) showpie= ShowPieMode.CPIE_BOT_LEFT; //show 1/4 pie else showpie= ShowPieMode.HPIE_LEFT; //show 1/2 pie } else if (mouse_y < sz/2) { - if (screen_x > 0 && screen_x-mouse_x < sz/2) + if (monitor_x > 0 && monitor_x-mouse_x < sz/2) showpie= ShowPieMode.CPIE_TOP_RIGHT; //show 1/4 pie else showpie= ShowPieMode.HPIE_TOP; //show 1/2 pie - } else if (screen_x > 0 && screen_x-mouse_x < sz/2) { - if (screen_y > 0 && screen_y-mouse_y < sz/2) + } else if (monitor_x > 0 && monitor_x-mouse_x < sz/2) { + if (monitor_y > 0 && monitor_y-mouse_y < sz/2) showpie= ShowPieMode.CPIE_BOT_RIGHT; //show 1/4 pie else showpie= ShowPieMode.HPIE_RIGHT; //show 1/2 pie - } else if (screen_y > 0 && screen_y-mouse_y < sz/2) + } else if (monitor_y > 0 && monitor_y-mouse_y < sz/2) showpie= ShowPieMode.HPIE_BOTTOM; //show 1/2 pie @@ -288,26 +294,26 @@ public class PieRenderer : GLib.Object { switch( PieManager.get_shape_number(pie.id) ) { case 1: showpie= ShowPieMode.CPIE_BOT_RIGHT; - if (screen_x-mouse_x > sz/2) + if (monitor_x-mouse_x > sz/2) reduce_szx= 0; //keep full width - if (screen_y-mouse_y > sz/2) + if (monitor_y-mouse_y > sz/2) reduce_szy= 0; //keep full height break; case 2: showpie= ShowPieMode.HPIE_RIGHT; - if (screen_x-mouse_x > sz/2) + if (monitor_x-mouse_x > sz/2) reduce_szx= 0; //keep full width break; case 3: showpie= ShowPieMode.CPIE_TOP_RIGHT; - if (screen_x-mouse_x > sz/2) + if (monitor_x-mouse_x > sz/2) reduce_szx= 0; //keep full width if (mouse_y > sz/2) reduce_szy= 0; //keep full height break; case 4: showpie= ShowPieMode.HPIE_BOTTOM; - if (screen_y-mouse_y > sz/2) + if (monitor_y-mouse_y > sz/2) reduce_szy= 0; //keep full height break; case 6: @@ -319,7 +325,7 @@ public class PieRenderer : GLib.Object { showpie= ShowPieMode.CPIE_BOT_LEFT; if (mouse_x > sz/2) reduce_szx= 0; //keep full width - if (screen_y-mouse_y > sz/2) + if (monitor_y-mouse_y > sz/2) reduce_szy= 0; //keep full height break; case 8: 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(); diff --git a/src/renderers/sliceRenderer.vala b/src/renderers/sliceRenderer.vala index b465bd7..c370b10 100644 --- a/src/renderers/sliceRenderer.vala +++ b/src/renderers/sliceRenderer.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 |