Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/pywinbox/_pywinbox_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,29 @@ def _getWindowBox(handle: EwmhWindow) -> Box:
# https://stackoverflow.com/questions/12775136/get-window-position-and-size-in-python-with-xlib
geom = handle.xWindow.get_geometry()
pos = handle.root.translate_coords(handle.id, 0, 0)
return Box(pos.x, pos.y, geom.width, geom.height)

# check if application uses special title bar (a.k.a. GTK HeaderBar)
# see: https://docs.gtk.org/gtk4/class.HeaderBar.html
# if it has HeaderBar (e.g., gedit):
# top left will be top left including extra space (shadows?)
# in that case, we subtract gtk extents to the right box
# if it doesn't (e.g., gvim):
# top left will be top left of client window (i.e., excluding the title bar)
# in that case, we add the title bar to get the right box

_net_extents = handle._getNetFrameExtents()
if _net_extents and len(_net_extents) >= 4: # this means it has no GTK HeaderBar
x = pos.x - int(_net_extents[0])
y = pos.y - int(_net_extents[2])
w = geom.width + int(_net_extents[0]) + int(_net_extents[1])
h = geom.height + int(_net_extents[2]) + int(_net_extents[3])
else:
_gtk_extents = handle._getGtkFrameExtents()
x = pos.x + int(_gtk_extents[0])
y = pos.y + int(_gtk_extents[2])
w = geom.width - int(_gtk_extents[0]) - int(_gtk_extents[1])
h = geom.height - int(_gtk_extents[2]) - int(_gtk_extents[3])
return Box(x, y, w, h)


def _moveResizeWindow(handle: EwmhWindow, newBox: Box):
Expand Down