Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 5802230

Browse files
committed
use gdk monitor on wayland if possible
1 parent c707a59 commit 5802230

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/renderers/pieWindow.vala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,21 +420,29 @@ public class PieWindow : Gtk.Window {
420420
double frame_time = this.timer.elapsed();
421421
this.timer.reset();
422422

423+
int center_x = this.renderer.center_x;
424+
int center_y = this.renderer.center_y;
425+
423426
// on wayland we have a fullscreen window and since we
424427
// do not get the pointer location until the mouse moved
425428
// we can only display the pie centered...
426429
if (this.wayland) {
427-
var screen = Gdk.Screen.get_default().get_root_window();
428-
x = screen.get_width() / 2;
429-
y = screen.get_height() / 2;
430-
ctx.translate(x, y);
431-
} else {
432-
// align the context to the center of the PieWindow
433-
x += this.renderer.center_x;
434-
y += this.renderer.center_y;
435-
ctx.translate(this.renderer.center_x, this.renderer.center_y);
430+
#if HAVE_GTK_3_22
431+
var monitor = Gdk.Display.get_default().get_monitor_at_point(mouse_x, mouse_y).get_geometry();
432+
center_x = monitor.width / 2;
433+
center_y = monitor.height / 2;
434+
#else
435+
var screen = Gdk.Screen.get_default().get_root_window();
436+
center_x = screen.get_width() / 2;
437+
center_y = screen.get_height() / 2;
438+
#endif
436439
}
437440

441+
// align the context to the center of the PieWindow
442+
x += center_x;
443+
y += center_y;
444+
ctx.translate(center_x, center_y);
445+
438446
// render the Pie
439447
this.renderer.draw(frame_time, ctx, mouse_x - x, mouse_y - y);
440448

0 commit comments

Comments
 (0)