Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 6506285

Browse files
committed
[[ Bug 15097 ]] Make 'the effective rect of stack' more reliable on Linux
Before the port to GDK, the Linux engine used its own heuristic for computing the frame rect of a window - this was not entirely reliable. The appropriate method has now been updated to use gdk_window_get_frame_extents which uses a couple of methods to try and ensure accuracy. Indeed, as long as the window manager is compliant with EWMH (and isn't broken) it should be correct.
1 parent 7dc9b48 commit 6506285

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

docs/notes/bugfix-15097.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ensure 'the effective rect of stack' is more accurate on Linux
2+
3+
With the move to GDK since 7.0 there is a better method for computing the effective rect of a window. The engine has been updated to use this method, rather than the heuristic which was there before.

engine/src/linux.stubs

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ gdk libgdk-x11-2.0.so.0
299299
gdk_window_set_skip_pager_hint: (pointer, integer) -> ()
300300
gdk_window_constrain_size: (pointer, integer, integer, integer, pointer, pointer) -> ()
301301
gdk_window_unmaximize: (pointer) -> ()
302+
gdk_window_get_frame_extents: (pointer, pointer) -> ()
302303

303304
gdk_pixbuf libgdk_pixbuf-2.0.so.0
304305
gdk_pixbuf_get_pixels: (pointer) -> (pointer)

engine/src/lnxstack.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -449,37 +449,9 @@ MCRectangle MCStack::view_platform_getwindowrect(void) const
449449

450450
MCRectangle MCStack::view_device_getwindowrect(void) const
451451
{
452-
x11::Window t_root, t_child, t_parent;
453-
x11::Window *t_children;
454-
int32_t t_win_x, t_win_y, t_x_offset, t_y_offset;
455-
uint32_t t_width, t_height, t_border_width, t_depth, t_child_count;
456-
457-
x11::Window t_window = x11::gdk_x11_drawable_get_xid(window);
458-
459-
x11::Display *t_display = x11::gdk_x11_display_get_xdisplay(MCdpy);
460-
461-
// We query for the top-level parent using the X11 functions because the GDK
462-
// equivalents do not account for re-parenting window managers and will not
463-
// return the re-parented parent.
464-
x11::XQueryTree(t_display, t_window, &t_root, &t_parent, &t_children, &t_child_count);
465-
x11::XFree(t_children);
466-
while (t_parent != t_root)
467-
{
468-
t_window = t_parent;
469-
x11::XQueryTree(t_display, t_window, &t_root, &t_parent, &t_children, &t_child_count);
470-
x11::XFree(t_children);
471-
}
472-
473-
x11::XGetGeometry(t_display, t_window, &t_root, &t_win_x, &t_win_y, &t_width, &t_height, &t_border_width, &t_depth);
474-
x11::XTranslateCoordinates(t_display, t_window, t_root, 0, 0, &t_win_x, &t_win_y, &t_child);
475-
476-
MCRectangle t_rect;
477-
t_rect.x = t_win_x - t_border_width;
478-
t_rect.y = t_win_y - t_border_width;
479-
t_rect.width = t_width + t_border_width * 2;
480-
t_rect.height = t_height + t_border_width * 2;
481-
482-
return t_rect;
452+
GdkRectangle t_frame;
453+
gdk_window_get_frame_extents(window, &t_frame);
454+
return MCRectangleMake(t_frame . x, t_frame . y, t_frame . width, t_frame . height);
483455
}
484456

485457
// IM-2014-01-29: [[ HiDPI ]] Placeholder method for Linux HiDPI support

0 commit comments

Comments
 (0)