Mercurial > dwindows
comparison gtk3/dw.c @ 1476:d76a36c9cff1
FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
value of 200x200 if the window hasn't completely appeared.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 21 Dec 2011 13:04:21 +0000 |
parents | 1794caee0758 |
children | 9097a5eb144c |
comparison
equal
deleted
inserted
replaced
1475:e0212278f794 | 1476:d76a36c9cff1 |
---|---|
8746 if(GTK_IS_WINDOW(handle)) | 8746 if(GTK_IS_WINDOW(handle)) |
8747 { | 8747 { |
8748 GdkWindow *window = gtk_widget_get_window(handle); | 8748 GdkWindow *window = gtk_widget_get_window(handle); |
8749 int horz = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_horz")); | 8749 int horz = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_horz")); |
8750 int vert = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_vert")); | 8750 int vert = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_vert")); |
8751 int cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width")); | |
8752 int cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height")); | |
8751 int newx = x, newy = y, width = 0, height = 0; | 8753 int newx = x, newy = y, width = 0, height = 0; |
8752 | 8754 |
8753 /* If the window is mapped */ | 8755 /* If the window is mapped */ |
8754 if(window && gtk_widget_get_mapped(handle)) | 8756 if(window && gtk_widget_get_mapped(handle)) |
8755 { | 8757 { |
8756 /* If we need the width or height... */ | 8758 /* If we need the width or height... */ |
8757 if(horz || vert) | 8759 if(horz || vert) |
8758 { | 8760 { |
8759 GdkRectangle frame; | 8761 GdkRectangle frame; |
8762 int count = 0; | |
8760 | 8763 |
8761 /* Get the frame size */ | 8764 /* Get the frame size */ |
8762 gdk_window_get_frame_extents(window, &frame); | 8765 gdk_window_get_frame_extents(window, &frame); |
8766 | |
8767 /* FIXME: Sometimes we get returned an invalid 200x200 | |
8768 * result... so if we get this... try the call a second | |
8769 * time and hope for a better result. | |
8770 */ | |
8771 while((frame.width == 200 || frame.width == (200 + cx)) && | |
8772 (frame.height == 200 || frame.height == (200 + cy)) && count < 10) | |
8773 { | |
8774 dw_main_sleep(1); | |
8775 count++; | |
8776 gdk_window_get_frame_extents(window, &frame); | |
8777 } | |
8763 width = frame.width; | 8778 width = frame.width; |
8764 height = frame.height; | 8779 height = frame.height; |
8780 dw_debug("Frame %dx%d\n", width, height); | |
8765 } | 8781 } |
8766 } | 8782 } |
8767 else | 8783 else |
8768 { | 8784 { |
8769 int cx , cy; | |
8770 | |
8771 /* Check if we have cached frame size values */ | 8785 /* Check if we have cached frame size values */ |
8772 if(!((cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width"))) | | 8786 if(!(cx | cy)) |
8773 (cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height"))))) | |
8774 { | 8787 { |
8775 /* If not try to ask the window manager for the estimated size... | 8788 /* If not try to ask the window manager for the estimated size... |
8776 * and finally if all else fails, guess. | 8789 * and finally if all else fails, guess. |
8777 */ | 8790 */ |
8778 _dw_get_frame_extents(handle, &cy, &cx); | 8791 _dw_get_frame_extents(handle, &cy, &cx); |
8790 if(!width || !height) | 8803 if(!width || !height) |
8791 { | 8804 { |
8792 /* Ask what GTK is planning on suggesting for the window size */ | 8805 /* Ask what GTK is planning on suggesting for the window size */ |
8793 gtk_window_get_size(GTK_WINDOW(handle), !width ? &width : NULL, !height ? &height : NULL); | 8806 gtk_window_get_size(GTK_WINDOW(handle), !width ? &width : NULL, !height ? &height : NULL); |
8794 } | 8807 } |
8808 dw_debug("Estimate %dx%d + %dx%d\n", width, height, cx, cy); | |
8795 /* Add the frame size to it */ | 8809 /* Add the frame size to it */ |
8796 width += cx; | 8810 width += cx; |
8797 height += cy; | 8811 height += cy; |
8798 } | 8812 } |
8799 /* Do any gravity calculations */ | 8813 /* Do any gravity calculations */ |