comparison gtk/dw.c @ 1482:dd584f431f9f

Even better workaround to Compiz bug on GTK... it only seems to happen when there are no window decorations, so when there are no decorations, set the window to undecorated and skip the code completely, setting the frame extents to 0x0 for an undecorated window.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 22 Dec 2011 14:48:38 +0000
parents 1ad57598f9cb
children 928daa73de8d
comparison
equal deleted inserted replaced
1481:1ad57598f9cb 1482:dd584f431f9f
3478 if(!(flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU))) 3478 if(!(flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)))
3479 gtk_window_set_deletable(GTK_WINDOW(tmp), FALSE); 3479 gtk_window_set_deletable(GTK_WINDOW(tmp), FALSE);
3480 #endif 3480 #endif
3481 3481
3482 gdk_window_set_decorations(tmp->window, flags); 3482 gdk_window_set_decorations(tmp->window, flags);
3483 if(!flags)
3484 gtk_window_set_decorated(GTK_WINDOW(tmp), FALSE);
3483 3485
3484 if(hwndOwner) 3486 if(hwndOwner)
3485 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); 3487 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3486 3488
3487 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); 3489 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
10141 } 10143 }
10142 10144
10143 /* Internal function to figure out the frame extents of an unmapped window */ 10145 /* Internal function to figure out the frame extents of an unmapped window */
10144 void _dw_get_frame_extents(GtkWidget *window, int *vert, int *horz) 10146 void _dw_get_frame_extents(GtkWidget *window, int *vert, int *horz)
10145 { 10147 {
10146 const char *request = "_NET_REQUEST_FRAME_EXTENTS"; 10148 if(gtk_window_get_decorated(GTK_WINDOW(window)))
10147 unsigned long *extents = NULL; 10149 {
10148 union extents_union eu; 10150 const char *request = "_NET_REQUEST_FRAME_EXTENTS";
10149 GdkAtom request_extents = gdk_atom_intern(request, FALSE); 10151 unsigned long *extents = NULL;
10150 10152 union extents_union eu;
10151 /* Set some rational defaults.. just in case */ 10153 GdkAtom request_extents = gdk_atom_intern(request, FALSE);
10152 *vert = 28; 10154
10153 *horz = 12; 10155 /* Set some rational defaults.. just in case */
10154 10156 *vert = 28;
10155 /* See if the current window manager supports _NET_REQUEST_FRAME_EXTENTS */ 10157 *horz = 12;
10156 if(gdk_net_wm_supports(request_extents)) 10158
10157 { 10159 /* See if the current window manager supports _NET_REQUEST_FRAME_EXTENTS */
10158 GdkDisplay *display = gtk_widget_get_display(window); 10160 if(gdk_net_wm_supports(request_extents))
10159 Display *xdisplay = GDK_DISPLAY_XDISPLAY(display); 10161 {
10160 GdkWindow *root_window = gdk_get_default_root_window(); 10162 GdkDisplay *display = gtk_widget_get_display(window);
10161 Window xroot_window = GDK_WINDOW_XID(root_window); 10163 Display *xdisplay = GDK_DISPLAY_XDISPLAY(display);
10162 Atom extents_request_atom = gdk_x11_get_xatom_by_name_for_display(display, request); 10164 GdkWindow *root_window = gdk_get_default_root_window();
10163 unsigned long window_id = GDK_WINDOW_XID(GDK_DRAWABLE(window->window)); 10165 Window xroot_window = GDK_WINDOW_XID(root_window);
10164 XEvent notify_xevent, xevent = {0}; 10166 Atom extents_request_atom = gdk_x11_get_xatom_by_name_for_display(display, request);
10165 10167 unsigned long window_id = GDK_WINDOW_XID(GDK_DRAWABLE(window->window));
10166 if(!extents_atom) 10168 XEvent notify_xevent, xevent = {0};
10167 { 10169
10168 const char *extents_name = "_NET_FRAME_EXTENTS"; 10170 if(!extents_atom)
10169 extents_atom = gdk_x11_get_xatom_by_name_for_display(display, extents_name); 10171 {
10170 } 10172 const char *extents_name = "_NET_FRAME_EXTENTS";
10171 10173 extents_atom = gdk_x11_get_xatom_by_name_for_display(display, extents_name);
10172 xevent.xclient.type = ClientMessage; 10174 }
10173 xevent.xclient.message_type = extents_request_atom; 10175
10174 xevent.xclient.display = xdisplay; 10176 xevent.xclient.type = ClientMessage;
10175 xevent.xclient.window = window_id; 10177 xevent.xclient.message_type = extents_request_atom;
10176 xevent.xclient.format = 32; 10178 xevent.xclient.display = xdisplay;
10177 10179 xevent.xclient.window = window_id;
10178 /* Send the property request */ 10180 xevent.xclient.format = 32;
10179 XSendEvent(xdisplay, xroot_window, False, 10181
10180 (SubstructureRedirectMask | SubstructureNotifyMask), 10182 /* Send the property request */
10181 &xevent); 10183 XSendEvent(xdisplay, xroot_window, False,
10184 (SubstructureRedirectMask | SubstructureNotifyMask),
10185 &xevent);
10186
10187 /* Record the request time */
10188 time(&extents_time);
10189
10190 /* Look for the property notify event */
10191 XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id);
10192
10193 /* If we didn't get the notification... put the event back onto the stack */
10194 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id
10195 || notify_xevent.xproperty.atom != extents_atom)
10196 XPutBackEvent(xdisplay, &notify_xevent);
10197 }
10182 10198
10183 /* Record the request time */ 10199 /* Attempt to retrieve window's frame extents. */
10184 time(&extents_time); 10200 eu.extents = &extents;
10185 10201 if(gdk_property_get(window->window,
10186 /* Look for the property notify event */ 10202 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE),
10187 XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id); 10203 gdk_atom_intern("CARDINAL", FALSE),
10188 10204 0, sizeof(unsigned long)*4, FALSE,
10189 /* If we didn't get the notification... put the event back onto the stack */ 10205 NULL, NULL, NULL, eu.gu_extents))
10190 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id 10206 {
10191 || notify_xevent.xproperty.atom != extents_atom) 10207 *horz = extents[0] + extents[1];
10192 XPutBackEvent(xdisplay, &notify_xevent); 10208 *vert = extents[2] + extents[3];
10193 } 10209 }
10194 10210 }
10195 /* Attempt to retrieve window's frame extents. */ 10211 else
10196 eu.extents = &extents; 10212 *horz = *vert = 0;
10197 if(gdk_property_get(window->window,
10198 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE),
10199 gdk_atom_intern("CARDINAL", FALSE),
10200 0, sizeof(unsigned long)*4, FALSE,
10201 NULL, NULL, NULL, eu.gu_extents))
10202 {
10203 *horz = extents[0] + extents[1];
10204 *vert = extents[2] + extents[3];
10205 }
10206 } 10213 }
10207 10214
10208 /* 10215 /*
10209 * Sets the size of a given window (widget). 10216 * Sets the size of a given window (widget).
10210 * Parameters: 10217 * Parameters: