summaryrefslogtreecommitdiff
path: root/src/renderers/pieRenderer.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderers/pieRenderer.vala')
-rw-r--r--src/renderers/pieRenderer.vala84
1 files changed, 45 insertions, 39 deletions
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: