comparison gtk3/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 5cfbf2715eec
comparison
equal deleted inserted replaced
1481:1ad57598f9cb 1482:dd584f431f9f
2938 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */ 2938 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */
2939 if(!(flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU))) 2939 if(!(flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)))
2940 gtk_window_set_deletable(GTK_WINDOW(tmp), FALSE); 2940 gtk_window_set_deletable(GTK_WINDOW(tmp), FALSE);
2941 2941
2942 gdk_window_set_decorations(gtk_widget_get_window(tmp), flags); 2942 gdk_window_set_decorations(gtk_widget_get_window(tmp), flags);
2943 if(!flags)
2944 gtk_window_set_decorated(GTK_WINDOW(tmp), FALSE);
2943 2945
2944 if(hwndOwner) 2946 if(hwndOwner)
2945 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(tmp)), gtk_widget_get_window(GTK_WIDGET(hwndOwner)), 0, 0); 2947 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(tmp)), gtk_widget_get_window(GTK_WIDGET(hwndOwner)), 0, 0);
2946 2948
2947 if(flStyle & DW_FCF_SIZEBORDER) 2949 if(flStyle & DW_FCF_SIZEBORDER)
8526 } 8528 }
8527 8529
8528 /* Internal function to figure out the frame extents of an unmapped window */ 8530 /* Internal function to figure out the frame extents of an unmapped window */
8529 void _dw_get_frame_extents(GtkWidget *window, int *vert, int *horz) 8531 void _dw_get_frame_extents(GtkWidget *window, int *vert, int *horz)
8530 { 8532 {
8531 const char *request = "_NET_REQUEST_FRAME_EXTENTS"; 8533 if(gtk_window_get_decorated(GTK_WINDOW(window)))
8532 unsigned long *extents = NULL; 8534 {
8533 union extents_union eu; 8535 const char *request = "_NET_REQUEST_FRAME_EXTENTS";
8534 GdkAtom request_extents = gdk_atom_intern(request, FALSE); 8536 unsigned long *extents = NULL;
8535 GdkWindow *gdkwindow = gtk_widget_get_window(window); 8537 union extents_union eu;
8536 GdkDisplay *display = gtk_widget_get_display(window); 8538 GdkAtom request_extents = gdk_atom_intern(request, FALSE);
8537 8539 GdkWindow *gdkwindow = gtk_widget_get_window(window);
8538 /* Set some rational defaults.. just in case */ 8540 GdkDisplay *display = gtk_widget_get_display(window);
8539 *vert = 28; 8541
8540 *horz = 12; 8542 /* Set some rational defaults.. just in case */
8541 8543 *vert = 28;
8542 /* See if the current window manager supports _NET_REQUEST_FRAME_EXTENTS */ 8544 *horz = 12;
8543 if(gdk_x11_screen_supports_net_wm_hint(gdk_screen_get_default(), request_extents)) 8545
8544 { 8546 /* See if the current window manager supports _NET_REQUEST_FRAME_EXTENTS */
8545 Display *xdisplay = GDK_DISPLAY_XDISPLAY(display); 8547 if(gdk_x11_screen_supports_net_wm_hint(gdk_screen_get_default(), request_extents))
8546 GdkWindow *root_window = gdk_get_default_root_window(); 8548 {
8547 Window xroot_window = GDK_WINDOW_XID(root_window); 8549 Display *xdisplay = GDK_DISPLAY_XDISPLAY(display);
8548 Atom extents_request_atom = gdk_x11_get_xatom_by_name_for_display(display, request); 8550 GdkWindow *root_window = gdk_get_default_root_window();
8549 unsigned long window_id = GDK_WINDOW_XID(gdkwindow); 8551 Window xroot_window = GDK_WINDOW_XID(root_window);
8550 XEvent notify_xevent, xevent = {0}; 8552 Atom extents_request_atom = gdk_x11_get_xatom_by_name_for_display(display, request);
8551 8553 unsigned long window_id = GDK_WINDOW_XID(gdkwindow);
8552 if(!extents_atom) 8554 XEvent notify_xevent, xevent = {0};
8553 { 8555
8554 const char *extents_name = "_NET_FRAME_EXTENTS"; 8556 if(!extents_atom)
8555 extents_atom = gdk_x11_get_xatom_by_name_for_display(display, extents_name); 8557 {
8556 } 8558 const char *extents_name = "_NET_FRAME_EXTENTS";
8557 8559 extents_atom = gdk_x11_get_xatom_by_name_for_display(display, extents_name);
8558 xevent.xclient.type = ClientMessage; 8560 }
8559 xevent.xclient.message_type = extents_request_atom; 8561
8560 xevent.xclient.display = xdisplay; 8562 xevent.xclient.type = ClientMessage;
8561 xevent.xclient.window = window_id; 8563 xevent.xclient.message_type = extents_request_atom;
8562 xevent.xclient.format = 32; 8564 xevent.xclient.display = xdisplay;
8563 8565 xevent.xclient.window = window_id;
8564 /* Send the property request */ 8566 xevent.xclient.format = 32;
8565 XSendEvent(xdisplay, xroot_window, False, 8567
8566 (SubstructureRedirectMask | SubstructureNotifyMask), 8568 /* Send the property request */
8567 &xevent); 8569 XSendEvent(xdisplay, xroot_window, False,
8568 8570 (SubstructureRedirectMask | SubstructureNotifyMask),
8569 /* Record the request time */ 8571 &xevent);
8570 time(&extents_time); 8572
8573 /* Record the request time */
8574 time(&extents_time);
8575
8576 /* Look for the property notify event */
8577 XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id);
8578
8579 /* If we didn't get the notification... put the event back onto the stack */
8580 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id
8581 || notify_xevent.xproperty.atom != extents_atom)
8582 XPutBackEvent(xdisplay, &notify_xevent);
8583 }
8571 8584
8572 /* Look for the property notify event */ 8585 /* Attempt to retrieve window's frame extents. */
8573 XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id); 8586 eu.extents = &extents;
8574 8587 if(gdk_property_get(gdkwindow,
8575 /* If we didn't get the notification... put the event back onto the stack */ 8588 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE),
8576 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id 8589 gdk_atom_intern("CARDINAL", FALSE),
8577 || notify_xevent.xproperty.atom != extents_atom) 8590 0, sizeof(unsigned long)*4, FALSE,
8578 XPutBackEvent(xdisplay, &notify_xevent); 8591 NULL, NULL, NULL, eu.gu_extents))
8579 } 8592 {
8580 8593 *horz = extents[0] + extents[1];
8581 /* Attempt to retrieve window's frame extents. */ 8594 *vert = extents[2] + extents[3];
8582 eu.extents = &extents; 8595 }
8583 if(gdk_property_get(gdkwindow, 8596 }
8584 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE), 8597 else
8585 gdk_atom_intern("CARDINAL", FALSE), 8598 *horz = *vert = 0;
8586 0, sizeof(unsigned long)*4, FALSE,
8587 NULL, NULL, NULL, eu.gu_extents))
8588 {
8589 *horz = extents[0] + extents[1];
8590 *vert = extents[2] + extents[3];
8591 }
8592 } 8599 }
8593 8600
8594 /* 8601 /*
8595 * Sets the size of a given window (widget). 8602 * Sets the size of a given window (widget).
8596 * Parameters: 8603 * Parameters: