s/0/FALSE/

2000-04-15  Michael Natterer  <mitch@gimp.org>

	* app/disp_callbacks.c: s/0/FALSE/

	* app/gdisplay_ops.c (gdisplay_shrink_wrap): removed all the
	gtk_drawing_area_size(), show/hide and gtk_main_iteration() stuff
	and don't touch the drawing area at all.

	Instead, use brute force on gdisp->shell:
	1. gtk_widget_size_allocate(gdisp->shell)
	2. gdk_window_resize(gdisp->shell->window)

	(tested with Sawmill, Enlightenment and twm)
This commit is contained in:
Michael Natterer 2000-04-15 16:00:19 +00:00 committed by Michael Natterer
parent fee4626459
commit 554b9a344e
6 changed files with 111 additions and 121 deletions

View File

@ -1,3 +1,17 @@
2000-04-15 Michael Natterer <mitch@gimp.org>
* app/disp_callbacks.c: s/0/FALSE/
* app/gdisplay_ops.c (gdisplay_shrink_wrap): removed all the
gtk_drawing_area_size(), show/hide and gtk_main_iteration() stuff
and don't touch the drawing area at all.
Instead, use brute force on gdisp->shell:
1. gtk_widget_size_allocate(gdisp->shell)
2. gdk_window_resize(gdisp->shell->window)
(tested with Sawmill, Enlightenment and twm)
2000-04-14 Michael Natterer <mitch@gimp.org>
* libgimp/gimpdialog.c: fixed a compiler warning.

View File

@ -199,13 +199,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
resize_display (gdisp, 0, FALSE);
resize_display (gdisp, FALSE, FALSE);
}
break;
case GDK_LEAVE_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
gdisplay_update_cursor (gdisp, 0, 0);
gtk_label_set_text (GTK_LABEL (gdisp->cursor_label), "");
info_window_update_RGB (gdisp, -1, -1);
@ -215,8 +215,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
break;
case GDK_ENTER_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
/* Actually, should figure out tx,ty here */
break;

View File

@ -199,13 +199,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
resize_display (gdisp, 0, FALSE);
resize_display (gdisp, FALSE, FALSE);
}
break;
case GDK_LEAVE_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
gdisplay_update_cursor (gdisp, 0, 0);
gtk_label_set_text (GTK_LABEL (gdisp->cursor_label), "");
info_window_update_RGB (gdisp, -1, -1);
@ -215,8 +215,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
break;
case GDK_ENTER_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
/* Actually, should figure out tx,ty here */
break;

View File

@ -148,40 +148,42 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
* I'm pretty sure this assumes that the current size is < display size
* Is this a valid assumption?
*/
gint x, y;
GtkAllocation allocation;
gint disp_width, disp_height;
gint width, height;
gint shell_x, shell_y;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
s_width = gdk_screen_width ();
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (gdisp, gdisp->gimage->width);
width = SCALEX (gdisp, gdisp->gimage->width);
height = SCALEY (gdisp, gdisp->gimage->height);
disp_width = gdisp->disp_width;
disp_width = gdisp->disp_width;
disp_height = gdisp->disp_height;
shell_width = gdisp->shell->allocation.width;
shell_width = gdisp->shell->allocation.width;
shell_height = gdisp->shell->allocation.height;
border_x = shell_width - disp_width;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
allocation.x = 0;
allocation.y = 0;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
if (width < gdisp->statusarea->requisition.width)
@ -189,31 +191,24 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
width = gdisp->statusarea->requisition.width;
}
#ifdef GDK_WINDOWING_WIN32
gtk_widget_hide(gdisp->shell);
#else
while (gtk_events_pending())
gtk_main_iteration();
#endif
allocation.width = width + border_x;
allocation.height = height + border_y;
gtk_drawing_area_size(GTK_DRAWING_AREA(gdisp->canvas),
width, height);
gtk_widget_size_allocate (gdisp->shell, &allocation);
#ifdef GDK_WINDOWING_WIN32
gtk_widget_show(gdisp->shell);
#endif
gdk_window_resize (gdisp->shell->window,
allocation.width,
allocation.height);
#undef RESIZE_DEBUG
#ifdef RESIZE_DEBUG
g_print("1w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
g_print ("1w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
#endif /* RESIZE_DEBUG */
gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y);
gdisp->disp_width = width; /* Should this be shell width? */
gdisp->disp_height = height;
}
@ -223,7 +218,7 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
if (width < gdisp->statusarea->requisition.width)
@ -231,31 +226,25 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
width = gdisp->statusarea->requisition.width;
}
#ifdef GDK_WINDOWING_WIN32
gtk_widget_hide(gdisp->shell);
#else
while (gtk_events_pending())
gtk_main_iteration();
#endif
allocation.width = width + border_x;
allocation.height = height + border_y;
gtk_drawing_area_size(GTK_DRAWING_AREA(gdisp->canvas),
width, height);
#ifdef GDK_WINDOWING_WIN32
gtk_widget_show(gdisp->shell);
#endif
gtk_widget_size_allocate (gdisp->shell, &allocation);
gdk_window_resize (gdisp->shell->window,
allocation.width,
allocation.height);
#ifdef RESIZE_DEBUG
g_print("2w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
g_print ("2w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
#endif /* RESIZE_DEBUG */
gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y);
/* Set the new disp_width and disp_height values */
gdisp->disp_width = width;
gdisp->disp_width = width;
gdisp->disp_height = height;
}
/* Otherwise, reexpose by hand to reflect changes */
@ -265,16 +254,15 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
/* If the width or height of the display has changed, recalculate
* the display offsets...
*/
if (disp_width != gdisp->disp_width ||
if (disp_width != gdisp->disp_width ||
disp_height != gdisp->disp_height)
{
gdisp->offset_x += (disp_width - gdisp->disp_width) / 2;
gdisp->offset_x += (disp_width - gdisp->disp_width) / 2;
gdisp->offset_y += (disp_height - gdisp->disp_height) / 2;
bounds_checking (gdisp);
}
}
gint
gdisplay_resize_image (GDisplay *gdisp)
{

View File

@ -199,13 +199,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
resize_display (gdisp, 0, FALSE);
resize_display (gdisp, FALSE, FALSE);
}
break;
case GDK_LEAVE_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
gdisplay_update_cursor (gdisp, 0, 0);
gtk_label_set_text (GTK_LABEL (gdisp->cursor_label), "");
info_window_update_RGB (gdisp, -1, -1);
@ -215,8 +215,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
break;
case GDK_ENTER_NOTIFY:
if ( ( (GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL )
return TRUE;
if (((GdkEventCrossing*) event)->mode != GDK_CROSSING_NORMAL)
return TRUE;
/* Actually, should figure out tx,ty here */
break;

View File

@ -148,40 +148,42 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
* I'm pretty sure this assumes that the current size is < display size
* Is this a valid assumption?
*/
gint x, y;
GtkAllocation allocation;
gint disp_width, disp_height;
gint width, height;
gint shell_x, shell_y;
gint shell_width, shell_height;
gint max_auto_width, max_auto_height;
gint border_x, border_y;
gint s_width, s_height;
s_width = gdk_screen_width ();
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALEX (gdisp, gdisp->gimage->width);
width = SCALEX (gdisp, gdisp->gimage->width);
height = SCALEY (gdisp, gdisp->gimage->height);
disp_width = gdisp->disp_width;
disp_width = gdisp->disp_width;
disp_height = gdisp->disp_height;
shell_width = gdisp->shell->allocation.width;
shell_width = gdisp->shell->allocation.width;
shell_height = gdisp->shell->allocation.height;
border_x = shell_width - disp_width;
border_x = shell_width - disp_width;
border_y = shell_height - disp_height;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_width = (s_width - border_x) * 0.75;
max_auto_height = (s_height - border_y) * 0.75;
allocation.x = 0;
allocation.y = 0;
/* If one of the display dimensions has changed and one of the
* dimensions fits inside the screen
*/
if (((width + border_x) < s_width || (height + border_y) < s_height) &&
(width != disp_width || height != disp_height))
{
width = ((width + border_x) < s_width) ? width : max_auto_width;
width = ((width + border_x) < s_width) ? width : max_auto_width;
height = ((height + border_y) < s_height) ? height : max_auto_height;
if (width < gdisp->statusarea->requisition.width)
@ -189,31 +191,24 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
width = gdisp->statusarea->requisition.width;
}
#ifdef GDK_WINDOWING_WIN32
gtk_widget_hide(gdisp->shell);
#else
while (gtk_events_pending())
gtk_main_iteration();
#endif
allocation.width = width + border_x;
allocation.height = height + border_y;
gtk_drawing_area_size(GTK_DRAWING_AREA(gdisp->canvas),
width, height);
gtk_widget_size_allocate (gdisp->shell, &allocation);
#ifdef GDK_WINDOWING_WIN32
gtk_widget_show(gdisp->shell);
#endif
gdk_window_resize (gdisp->shell->window,
allocation.width,
allocation.height);
#undef RESIZE_DEBUG
#ifdef RESIZE_DEBUG
g_print("1w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
g_print ("1w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
#endif /* RESIZE_DEBUG */
gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y);
gdisp->disp_width = width; /* Should this be shell width? */
gdisp->disp_height = height;
}
@ -223,7 +218,7 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
else if ((width > disp_width || height > disp_height) &&
(disp_width < max_auto_width || disp_height < max_auto_height))
{
width = MIN (max_auto_width, width);
width = MIN (max_auto_width, width);
height = MIN (max_auto_height, height);
if (width < gdisp->statusarea->requisition.width)
@ -231,31 +226,25 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
width = gdisp->statusarea->requisition.width;
}
#ifdef GDK_WINDOWING_WIN32
gtk_widget_hide(gdisp->shell);
#else
while (gtk_events_pending())
gtk_main_iteration();
#endif
allocation.width = width + border_x;
allocation.height = height + border_y;
gtk_drawing_area_size(GTK_DRAWING_AREA(gdisp->canvas),
width, height);
#ifdef GDK_WINDOWING_WIN32
gtk_widget_show(gdisp->shell);
#endif
gtk_widget_size_allocate (gdisp->shell, &allocation);
gdk_window_resize (gdisp->shell->window,
allocation.width,
allocation.height);
#ifdef RESIZE_DEBUG
g_print("2w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
g_print ("2w:%d/%d d:%d/%d s:%d/%d b:%d/%d\n",
width, height,
disp_width, disp_height,
shell_width, shell_height,
border_x, border_y);
#endif /* RESIZE_DEBUG */
gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y);
/* Set the new disp_width and disp_height values */
gdisp->disp_width = width;
gdisp->disp_width = width;
gdisp->disp_height = height;
}
/* Otherwise, reexpose by hand to reflect changes */
@ -265,16 +254,15 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
/* If the width or height of the display has changed, recalculate
* the display offsets...
*/
if (disp_width != gdisp->disp_width ||
if (disp_width != gdisp->disp_width ||
disp_height != gdisp->disp_height)
{
gdisp->offset_x += (disp_width - gdisp->disp_width) / 2;
gdisp->offset_x += (disp_width - gdisp->disp_width) / 2;
gdisp->offset_y += (disp_height - gdisp->disp_height) / 2;
bounds_checking (gdisp);
}
}
gint
gdisplay_resize_image (GDisplay *gdisp)
{