xwayland: Rename xwl_window::window to ::toplevel

It's always the toplevel window, i.e. either the root window or a child
of it.

Preparation for later commits, no functional change.

v2: (Olivier Fourdan)
* Fix debug build.
* Add comment describing ::toplevel.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
This commit is contained in:
Michel Dänzer 2023-12-22 16:54:40 +01:00 committed by Marge Bot
parent 59a0259152
commit 972d5af537
8 changed files with 55 additions and 49 deletions

View File

@ -735,7 +735,7 @@ xwl_window_dmabuf_feedback_done(void *data,
struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
{
struct xwl_window *xwl_window = data;
uint32_t format = wl_drm_format_for_depth(xwl_window->window->drawable.depth);
uint32_t format = wl_drm_format_for_depth(xwl_window->toplevel->drawable.depth);
xwl_dmabuf_feedback_done(&xwl_window->feedback, dmabuf_feedback);
@ -743,7 +743,7 @@ xwl_window_dmabuf_feedback_done(void *data,
xwl_feedback_is_modifier_supported(&xwl_window->feedback, format,
DRM_FORMAT_MOD_INVALID, TRUE);
DebugF("XWAYLAND: Window 0x%x can%s get implicit scanout support\n",
xwl_window->window->drawable.id,
xwl_window->toplevel->drawable.id,
xwl_window->has_implicit_scanout_support ? "" : "not");
/* If the linux-dmabuf v4 per-surface feedback changed, make sure the

View File

@ -412,7 +412,7 @@ PixmapPtr
xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
WindowPtr window = xwl_window->window;
WindowPtr window = xwl_window->toplevel;
unsigned border_width = 2 * window->borderWidth;
if (!xwl_screen->glamor)

View File

@ -543,8 +543,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
xwl_seat->pointer_enter_serial = serial;
xwl_seat->focus_window = wl_surface_get_user_data(surface);
dx = xwl_seat->focus_window->window->drawable.x;
dy = xwl_seat->focus_window->window->drawable.y;
dx = xwl_seat->focus_window->toplevel->drawable.x;
dy = xwl_seat->focus_window->toplevel->drawable.y;
/* We just entered a new xwindow, forget about the old last xwindow */
xwl_seat->last_focus_window = NULL;
@ -660,8 +660,8 @@ dispatch_absolute_motion(struct xwl_seat *xwl_seat)
int flags;
int event_x = wl_fixed_to_int(xwl_seat->pending_pointer_event.x);
int event_y = wl_fixed_to_int(xwl_seat->pending_pointer_event.y);
int drawable_x = xwl_seat->focus_window->window->drawable.x;
int drawable_y = xwl_seat->focus_window->window->drawable.y;
int drawable_x = xwl_seat->focus_window->toplevel->drawable.x;
int drawable_y = xwl_seat->focus_window->toplevel->drawable.y;
int x;
int y;
@ -1411,8 +1411,8 @@ xwl_touch_send_event(struct xwl_touch *xwl_touch,
double dx, dy, x, y;
ValuatorMask mask;
dx = xwl_touch->window->window->drawable.x;
dy = xwl_touch->window->window->drawable.y;
dx = xwl_touch->window->toplevel->drawable.x;
dy = xwl_touch->window->toplevel->drawable.y;
x = (dx + xwl_touch->x) * 0xFFFF / xwl_screen_get_width(xwl_seat->xwl_screen);
y = (dy + xwl_touch->y) * 0xFFFF / xwl_screen_get_height(xwl_seat->xwl_screen);
@ -2202,8 +2202,8 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool,
sx *= xwl_seat->tablet_focus_window->viewport_scale_x;
sy *= xwl_seat->tablet_focus_window->viewport_scale_y;
dx = xwl_seat->tablet_focus_window->window->drawable.x;
dy = xwl_seat->tablet_focus_window->window->drawable.y;
dx = xwl_seat->tablet_focus_window->toplevel->drawable.x;
dy = xwl_seat->tablet_focus_window->toplevel->drawable.y;
xwl_tablet_tool->x = (double) dx + sx;
xwl_tablet_tool->y = (double) dy + sy;
@ -3193,8 +3193,8 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
if (xwl_seat->focus_window == NULL &&
xwl_seat->last_focus_window != NULL &&
(xwl_seat->last_focus_window->window == window ||
IsParent(xwl_seat->last_focus_window->window, window)))
(xwl_seat->last_focus_window->toplevel == window ||
IsParent(xwl_seat->last_focus_window->toplevel, window)))
return TRUE;
return FALSE;
@ -3257,7 +3257,7 @@ xwl_pointer_warp_emulator_set_fake_pos(struct xwl_pointer_warp_emulator *warp_em
if (!warp_emulator->xwl_seat->focus_window)
return;
window = warp_emulator->xwl_seat->focus_window->window;
window = warp_emulator->xwl_seat->focus_window->toplevel;
if (x >= window->drawable.x ||
y >= window->drawable.y ||
x < (window->drawable.x + window->drawable.width) ||
@ -3326,7 +3326,7 @@ xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emul
if (pointer_grab &&
!pointer_grab->ownerEvents &&
sprite &&
XYToWindow(sprite, x, y) != xwl_seat->focus_window->window)
XYToWindow(sprite, x, y) != xwl_seat->focus_window->toplevel)
return;
xwl_pointer_warp_emulator_lock(warp_emulator);
@ -3364,7 +3364,7 @@ xwl_pointer_warp_emulator_handle_motion(struct xwl_pointer_warp_emulator *warp_e
QueuePointerEvents(xwl_seat->relative_pointer, MotionNotify, 0,
POINTER_RELATIVE, &mask);
window = xwl_seat->focus_window->window;
window = xwl_seat->focus_window->toplevel;
miPointerGetPosition(xwl_seat->pointer, &x, &y);
if (xwl_pointer_warp_emulator_is_locked(warp_emulator) &&

View File

@ -785,7 +785,7 @@ xwl_present_check_flip(RRCrtcPtr crtc,
* window's, e.g. because a client redirected this window or one of its
* parents.
*/
if (screen->GetWindowPixmap(xwl_window->window) != screen->GetWindowPixmap(present_window))
if (screen->GetWindowPixmap(xwl_window->toplevel) != screen->GetWindowPixmap(present_window))
return FALSE;
/*
@ -793,7 +793,7 @@ xwl_present_check_flip(RRCrtcPtr crtc,
* dimensions as their xwl_window parent window. For the case of
* different sizes subsurfaces are presumably the way forward.
*/
if (!RegionEqual(&xwl_window->window->winSize, &present_window->winSize))
if (!RegionEqual(&xwl_window->toplevel->winSize, &present_window->winSize))
return FALSE;
return TRUE;

View File

@ -305,7 +305,7 @@ xwl_cursor_warped_to(DeviceIntPtr device,
xwl_window = xwl_window_from_window(window);
if (!xwl_window && xwl_seat->focus_window) {
focus = xwl_seat->focus_window->window;
focus = xwl_seat->focus_window->toplevel;
/* Warps on non wl_surface backed Windows are only allowed
* as long as the pointer stays within the focus window.
@ -339,15 +339,15 @@ find_matching_input_output_window(struct xwl_screen *xwl_screen,
/* When confining happens on InputOnly windows, work out the InputOutput
* window that would be covered by its geometry.
*/
if (window->drawable.x < xwl_window->window->drawable.x ||
if (window->drawable.x < xwl_window->toplevel->drawable.x ||
window->drawable.x + window->drawable.width >
xwl_window->window->drawable.x + xwl_window->window->drawable.width ||
window->drawable.y < xwl_window->window->drawable.y ||
xwl_window->toplevel->drawable.x + xwl_window->toplevel->drawable.width ||
window->drawable.y < xwl_window->toplevel->drawable.y ||
window->drawable.y + window->drawable.height >
xwl_window->window->drawable.y + xwl_window->window->drawable.height)
xwl_window->toplevel->drawable.y + xwl_window->toplevel->drawable.height)
continue;
if (xwl_window->window->drawable.class == InputOnly)
if (xwl_window->toplevel->drawable.class == InputOnly)
continue;
return xwl_window;

View File

@ -339,7 +339,7 @@ xwl_window_allocate_pixmap(struct xwl_window *xwl_window)
return window_pixmap;
#endif /* XWL_HAS_GLAMOR */
window_pixmap = screen->GetWindowPixmap(xwl_window->window);
window_pixmap = screen->GetWindowPixmap(xwl_window->toplevel);
return screen->CreatePixmap(screen,
window_pixmap->drawable.width,
window_pixmap->drawable.height,
@ -358,7 +358,7 @@ xwl_window_realloc_pixmap(struct xwl_window *xwl_window)
if (!new_window_pixmap)
return;
window = xwl_window->window;
window = xwl_window->toplevel;
screen = window->drawable.pScreen;
window_pixmap = screen->GetWindowPixmap(window);
copy_pixmap_area(window_pixmap,
@ -366,7 +366,7 @@ xwl_window_realloc_pixmap(struct xwl_window *xwl_window)
0, 0,
window_pixmap->drawable.width,
window_pixmap->drawable.height);
xwl_window_set_pixmap(xwl_window->window, new_window_pixmap);
xwl_window_set_pixmap(xwl_window->toplevel, new_window_pixmap);
screen->DestroyPixmap(window_pixmap);
}
@ -393,7 +393,7 @@ xwl_window_buffers_set_syncpts(struct xwl_window_buffer *xwl_window_buffer)
else
goto fail;
xwl_glamor_dri3_syncobj_passthrough(xwl_window->window,
xwl_glamor_dri3_syncobj_passthrough(xwl_window->toplevel,
xwl_window_buffer->syncobj,
xwl_window_buffer->syncobj,
acquire_point,
@ -418,7 +418,7 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window)
PixmapPtr window_pixmap;
Bool implicit_sync = TRUE;
window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->toplevel);
xwl_window_buffer_add_damage_region(xwl_window);
@ -441,8 +441,8 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window)
while (nBox--) {
copy_pixmap_area(window_pixmap,
xwl_window_buffer->pixmap,
pBox->x1 + xwl_window->window->borderWidth,
pBox->y1 + xwl_window->window->borderWidth,
pBox->x1 + xwl_window->toplevel->borderWidth,
pBox->y1 + xwl_window->toplevel->borderWidth,
pBox->x2 - pBox->x1,
pBox->y2 - pBox->y1);
@ -451,7 +451,7 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window)
RegionEmpty(xwl_window_buffer->damage_region);
xorg_list_del(&xwl_window_buffer->link_buffer);
xwl_window_set_pixmap(xwl_window->window, xwl_window_buffer->pixmap);
xwl_window_set_pixmap(xwl_window->toplevel, xwl_window_buffer->pixmap);
/* Can't re-use client pixmap as a window buffer */
if (xwl_is_client_pixmap(window_pixmap)) {

View File

@ -87,7 +87,7 @@ window_get_damage(WindowPtr window)
RegionPtr
xwl_window_get_damage_region(struct xwl_window *xwl_window)
{
return DamageRegion(window_get_damage(xwl_window->window));
return DamageRegion(window_get_damage(xwl_window->toplevel));
}
struct xwl_window *
@ -133,9 +133,9 @@ xwl_window_set_allow_commits(struct xwl_window *xwl_window, Bool allow,
xwl_window->allow_commits = allow;
DebugF("XWAYLAND: win %d allow_commits = %d (%s)\n",
xwl_window->window->drawable.id, allow, debug_msg);
xwl_window->toplevel->drawable.id, allow, debug_msg);
damage = window_get_damage(xwl_window->window);
damage = window_get_damage(xwl_window->toplevel);
if (allow &&
xorg_list_is_empty(&xwl_window->link_damage) &&
damage &&
@ -207,7 +207,7 @@ damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data)
if (xorg_list_is_empty(&xwl_window->link_damage))
xorg_list_add(&xwl_window->link_damage, &xwl_screen->damage_window_list);
window_pixmap = xwl_screen->screen->GetWindowPixmap(xwl_window->window);
window_pixmap = xwl_screen->screen->GetWindowPixmap(xwl_window->toplevel);
if (xwl_is_client_pixmap(window_pixmap))
xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window));
}
@ -447,7 +447,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
if (!xwl_screen->rootless)
return FALSE;
window = window_get_client_toplevel(xwl_window->window);
window = window_get_client_toplevel(xwl_window->toplevel);
if (!window)
return FALSE;
@ -479,7 +479,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
*/
xwl_output = xwl_screen_get_first_output(xwl_screen);
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, owner);
if (xwl_output && xwl_window->window->overrideRedirect &&
if (xwl_output && xwl_window->toplevel->overrideRedirect &&
emulated_mode && emulated_mode->from_vidmode &&
drawable->x == 0 && drawable->y == 0 &&
drawable->width == xwl_screen_get_width(xwl_screen) &&
@ -561,7 +561,7 @@ xwl_window_init_allow_commits(struct xwl_window *xwl_window)
PropertyPtr prop = NULL;
int ret;
ret = dixLookupProperty(&prop, xwl_window->window,
ret = dixLookupProperty(&prop, xwl_window->toplevel,
xwl_window->xwl_screen->allow_commits_prop,
serverClient, DixReadAccess);
if (ret == Success && prop)
@ -590,7 +590,7 @@ send_window_client_message(struct xwl_window *xwl_window, Atom type_atom, uint64
e.u.u.type = ClientMessage;
e.u.u.detail = 32;
e.u.clientMessage.window = xwl_window->window->drawable.id;
e.u.clientMessage.window = xwl_window->toplevel->drawable.id;
e.u.clientMessage.u.l.type = type_atom;
e.u.clientMessage.u.l.longs0 = serial_lo(value);
e.u.clientMessage.u.l.longs1 = serial_hi(value);
@ -685,7 +685,7 @@ xwl_window_rootful_update_fullscreen(struct xwl_window *xwl_window,
if (!xwl_screen->fullscreen)
return;
if (xwl_window->window != xwl_screen->screen->root)
if (xwl_window->toplevel != xwl_screen->screen->root)
return;
if (xwl_window->wl_output_fullscreen != xwl_output->output)
@ -1148,7 +1148,7 @@ static Bool
xwl_create_root_surface(struct xwl_window *xwl_window)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
WindowPtr window = xwl_window->window;
WindowPtr window = xwl_window->toplevel;
struct wl_region *region;
@ -1252,7 +1252,7 @@ ensure_surface_for_window(WindowPtr window)
return FALSE;
xwl_window->xwl_screen = xwl_screen;
xwl_window->window = window;
xwl_window->toplevel = window;
xwl_window->fractional_scale_numerator = FRACTIONAL_SCALE_DENOMINATOR;
xwl_window->viewport_scale_x = 1.0;
xwl_window->viewport_scale_y = 1.0;
@ -1723,15 +1723,15 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window)
if (RegionNumRects(region) > 256) {
box = RegionExtents(region);
xwl_surface_damage(xwl_screen, xwl_window->surface,
box->x1 + xwl_window->window->borderWidth,
box->y1 + xwl_window->window->borderWidth,
box->x1 + xwl_window->toplevel->borderWidth,
box->y1 + xwl_window->toplevel->borderWidth,
box->x2 - box->x1, box->y2 - box->y1);
} else {
box = RegionRects(region);
for (i = 0; i < RegionNumRects(region); i++, box++) {
xwl_surface_damage(xwl_screen, xwl_window->surface,
box->x1 + xwl_window->window->borderWidth,
box->y1 + xwl_window->window->borderWidth,
box->x1 + xwl_window->toplevel->borderWidth,
box->y1 + xwl_window->toplevel->borderWidth,
box->x2 - box->x1, box->y2 - box->y1);
}
}
@ -1748,7 +1748,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
return;
xwl_window_create_frame_callback(xwl_window);
DamageEmpty(window_get_damage(xwl_window->window));
DamageEmpty(window_get_damage(xwl_window->toplevel));
}
Bool

View File

@ -62,7 +62,13 @@ struct xwl_window {
int surface_scale;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
WindowPtr window;
/* Top-level window for the Wayland surface:
* - With rootful, the root window itself
* - With rootless, a direct child of the root window
*/
WindowPtr toplevel;
struct xorg_list link_damage;
struct xorg_list link_window;
struct wl_callback *frame_callback;