Skip to content

Commit 6a6d733

Browse files
committed
Don't try to send grants for not realized windows
We rely on composite redirect mode of the X server to get per window pixmaps. Those are setup/teared-down in compRealizeWindow/ compUnrealizeWindow (via compCheckRedirect). So not realized windows don't have a per window pixmap. Sending grant refs for them was always broken since we didn't send the offset into the screen pixmap in those cases. But with the recent change to not allocate grant refs for the screen pixmap this leads to a noticable error message. So don't try to send grant refs for not realized windows. This means that the configure before mapping will not contiain grant refs. But when we map the window we will get a damage event because of the new pixmap compRealizeWindow has allocated and send them then. So this should be fine.
1 parent fb542b7 commit 6a6d733

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

gui-agent/vmside.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct window_data {
148148
int support_delete_window;
149149
int support_take_focus;
150150
int window_dump_pending; /* send MSG_WINDOW_DUMP at next damage notification */
151+
int mapped;
151152
};
152153

153154
struct embeder_data {
@@ -470,6 +471,7 @@ static void process_xevent_createnotify(Ghandles * g, XCreateWindowEvent * ev)
470471
wd->support_delete_window = False;
471472
wd->support_take_focus = False;
472473
wd->window_dump_pending = False;
474+
wd->mapped = False;
473475
list_insert(windows_list, ev->window, wd);
474476

475477
if (attr.border_width > 0) {
@@ -874,6 +876,7 @@ static void process_xevent_map(Ghandles * g, XID window)
874876

875877
if (g->log_level > 1)
876878
fprintf(stderr, "MAP for window 0x%x\n", (int)window);
879+
wd->mapped = True;
877880
wd->window_dump_pending = True;
878881
send_window_state(g, window);
879882
XGetWindowAttributes(g->display, window, &attr);
@@ -898,10 +901,14 @@ static void process_xevent_map(Ghandles * g, XID window)
898901
static void process_xevent_unmap(Ghandles * g, XID window)
899902
{
900903
struct msg_hdr hdr;
904+
struct window_data *wd;
901905
SKIP_NONMANAGED_WINDOW;
902906

907+
wd = list_lookup(windows_list, window)->data;
908+
903909
if (g->log_level > 1)
904910
fprintf(stderr, "UNMAP for window 0x%x\n", (int)window);
911+
wd->mapped = False;
905912
hdr.type = MSG_UNMAP;
906913
hdr.window = window;
907914
hdr.untrusted_len = 0;
@@ -945,18 +952,23 @@ static void process_xevent_configure(Ghandles * g, XID window,
945952
struct msg_hdr hdr;
946953
struct msg_configure conf;
947954
struct genlist *l;
955+
int mapped = False;
948956
/* SKIP_NONMANAGED_WINDOW; */
949-
if (!(l=list_lookup(windows_list, window))) {
957+
if ((l=list_lookup(windows_list, window))) {
958+
mapped = ((struct window_data*)l->data)->mapped;
959+
} else {
950960
/* if not real managed window, check if this is embeder for another window */
951961
struct genlist *e;
952962
if ((e=list_lookup(embeder_list, window))) {
963+
struct genlist *i;
953964
window = ((struct embeder_data*)e->data)->icon_window;
954-
if (!list_lookup(windows_list, window))
965+
if (!(i = list_lookup(windows_list, window)))
955966
/* probably icon window have just destroyed, so ignore message */
956967
/* "l" not updated intentionally - when configure notify comes
957968
* from the embeder, it should be passed to dom0 (in most cases as
958969
* ACK for earlier configure request) */
959970
return;
971+
mapped = ((struct window_data*)i->data)->mapped;
960972
} else {
961973
/* ignore not managed windows */
962974
return;
@@ -999,7 +1011,10 @@ static void process_xevent_configure(Ghandles * g, XID window,
9991011
conf.height = ev->height;
10001012
conf.override_redirect = ev->override_redirect;
10011013
write_message(g->vchan, hdr, conf);
1002-
send_pixmap_grant_refs(g, window);
1014+
if (mapped) {
1015+
// see comment in dump_window_grant_refs in the xdriver
1016+
send_pixmap_grant_refs(g, window);
1017+
}
10031018
}
10041019

10051020
static void send_clipboard_data(libvchan_t *vchan, XID window, char *data, uint32_t len, int protocol_version)

xf86-input-mfndev/src/qubes.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,19 @@ static void dump_window_grant_refs(int window_id, int fd)
600600
// the window is destroyed before the driver sees the req
601601
goto send_response;
602602

603+
if (!x_window->realized) {
604+
// Composite redirect is setup/teared-down during Realize-/Unrealize-
605+
// Window (called when a window gets mapped/unmapped). So if the window
606+
// is not realized we don't have a per window pixmap we can send.
607+
//
608+
// This means that the configure of a window before mapping will not
609+
// send grants. This should be fine since when compRealizeWindow
610+
// replaces the pixmap it will trigger a damage event and we will send
611+
// the grants then.
612+
xf86Msg(X_ERROR, "can't dump not realized window\n");
613+
goto send_response;
614+
}
615+
603616
screen = x_window->drawable.pScreen;
604617
pixmap = (*screen->GetWindowPixmap) (x_window);
605618

0 commit comments

Comments
 (0)