Skip to content

Commit

Permalink
Window: Handle the DefaultRootWindow being passed to XGetWindowAttrib…
Browse files Browse the repository at this point in the history
…utes.

Fixes window centering on screen in Worker.
  • Loading branch information
waddlesplash committed Nov 20, 2023
1 parent a17df7e commit 144cb3b
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions xlib/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ extern "C" int
XGetWindowAttributes(Display* display, Window w,
XWindowAttributes* window_attributes_return)
{
if (w == DefaultRootWindow(display)) {
// Special case: the root window.
window_attributes_return->root = DefaultRootWindow(display);
window_attributes_return->screen = &display->screens[0];
window_attributes_return->visual = window_attributes_return->screen->root_visual;
window_attributes_return->c_class = window_attributes_return->visual->c_class;
window_attributes_return->depth = window_attributes_return->screen->depths[0].depth;

window_attributes_return->x = 0;
window_attributes_return->y = 0;
window_attributes_return->width = window_attributes_return->screen->width;
window_attributes_return->height = window_attributes_return->screen->height;

window_attributes_return->border_width = 0;
window_attributes_return->your_event_mask = 0;
window_attributes_return->all_event_masks = 0;
window_attributes_return->map_state = IsViewable;

return 1;
}

XWindow* window = Drawables::get_window(w);
if (!window)
return 0;
Expand Down Expand Up @@ -948,10 +969,6 @@ XSetNormalHints(Display* display, Window w, XSizeHints* hints)
if (!hints)
return BadValue;

if (hints->flags & PBaseSize) {
// Not supported.
}

if (hints->flags & PMinSize)
window->minimum_size(hints->min_width, hints->min_height);
if (hints->flags & PMaxSize)
Expand All @@ -960,6 +977,9 @@ XSetNormalHints(Display* display, Window w, XSizeHints* hints)
if (hints->flags & PResizeInc) {
// Not supported.
}
if (hints->flags & PBaseSize) {
// Not supported.
}

// TODO: Flags?
return Success;
Expand Down

0 comments on commit 144cb3b

Please sign in to comment.