Merge branch 'wip/otte/geometry' into 'master'

Some GdkGeometry cleanups

See merge request GNOME/gtk!2322
This commit is contained in:
Benjamin Otte 2020-07-30 15:31:27 +00:00
commit 4dc2ab61c9
9 changed files with 23 additions and 736 deletions

View File

@ -1137,65 +1137,10 @@ create_moveresize_surface (MoveResizeData *mv_resize,
static void static void
calculate_unmoving_origin (MoveResizeData *mv_resize) calculate_unmoving_origin (MoveResizeData *mv_resize)
{ {
int x, y, width, height; gdk_surface_get_geometry (mv_resize->moveresize_surface,
&mv_resize->moveresize_orig_x,
if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY && &mv_resize->moveresize_orig_y,
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC) NULL, NULL);
{
gdk_surface_get_origin (mv_resize->moveresize_surface,
&mv_resize->moveresize_orig_x,
&mv_resize->moveresize_orig_y);
}
else
{
gdk_surface_get_geometry (mv_resize->moveresize_surface,
&x, &y, &width, &height);
switch (mv_resize->moveresize_geometry.win_gravity)
{
case GDK_GRAVITY_NORTH_WEST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_NORTH:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_NORTH_EAST:
mv_resize->moveresize_orig_x = x = width;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_WEST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_CENTER:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_EAST:
mv_resize->moveresize_orig_x = x + width;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_SOUTH_WEST:
mv_resize->moveresize_orig_x = x + width;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_SOUTH:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_SOUTH_EAST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_STATIC:
default:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y;
break;
}
}
} }
static void static void

View File

@ -296,15 +296,8 @@ GdkGLContext *gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
typedef enum typedef enum
{ {
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1, GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2, GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
} GdkSurfaceHints; } GdkSurfaceHints;
typedef enum typedef enum
@ -333,13 +326,6 @@ struct _GdkGeometry
int min_height; int min_height;
int max_width; int max_width;
int max_height; int max_height;
int base_width;
int base_height;
int width_inc;
int height_inc;
double min_aspect;
double max_aspect;
GdkGravity win_gravity;
}; };
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL

View File

@ -1586,33 +1586,11 @@ gdk_surface_constrain_size (GdkGeometry *geometry,
*/ */
int min_width = 0; int min_width = 0;
int min_height = 0; int min_height = 0;
int base_width = 0;
int base_height = 0;
int xinc = 1;
int yinc = 1;
int max_width = G_MAXINT; int max_width = G_MAXINT;
int max_height = G_MAXINT; int max_height = G_MAXINT;
#define FLOOR(value, base) ( ((int) ((value) / (base))) * (base) ) if (flags & GDK_HINT_MIN_SIZE)
if ((flags & GDK_HINT_BASE_SIZE) && (flags & GDK_HINT_MIN_SIZE))
{ {
base_width = geometry->base_width;
base_height = geometry->base_height;
min_width = geometry->min_width;
min_height = geometry->min_height;
}
else if (flags & GDK_HINT_BASE_SIZE)
{
base_width = geometry->base_width;
base_height = geometry->base_height;
min_width = geometry->base_width;
min_height = geometry->base_height;
}
else if (flags & GDK_HINT_MIN_SIZE)
{
base_width = geometry->min_width;
base_height = geometry->min_height;
min_width = geometry->min_width; min_width = geometry->min_width;
min_height = geometry->min_height; min_height = geometry->min_height;
} }
@ -1623,80 +1601,11 @@ gdk_surface_constrain_size (GdkGeometry *geometry,
max_height = geometry->max_height; max_height = geometry->max_height;
} }
if (flags & GDK_HINT_RESIZE_INC)
{
xinc = MAX (xinc, geometry->width_inc);
yinc = MAX (yinc, geometry->height_inc);
}
/* clamp width and height to min and max values /* clamp width and height to min and max values
*/ */
width = CLAMP (width, min_width, max_width); width = CLAMP (width, min_width, max_width);
height = CLAMP (height, min_height, max_height); height = CLAMP (height, min_height, max_height);
/* shrink to base + N * inc
*/
width = base_width + FLOOR (width - base_width, xinc);
height = base_height + FLOOR (height - base_height, yinc);
/* constrain aspect ratio, according to:
*
* width
* min_aspect <= -------- <= max_aspect
* height
*/
if (flags & GDK_HINT_ASPECT &&
geometry->min_aspect > 0 &&
geometry->max_aspect > 0)
{
int delta;
if (flags & GDK_HINT_BASE_SIZE)
{
width -= base_width;
height -= base_height;
min_width -= base_width;
min_height -= base_height;
max_width -= base_width;
max_height -= base_height;
}
if (geometry->min_aspect * height > width)
{
delta = FLOOR (height - width / geometry->min_aspect, yinc);
if (height - delta >= min_height)
height -= delta;
else
{
delta = FLOOR (height * geometry->min_aspect - width, xinc);
if (width + delta <= max_width)
width += delta;
}
}
if (geometry->max_aspect * height < width)
{
delta = FLOOR (width - height * geometry->max_aspect, xinc);
if (width - delta >= min_width)
width -= delta;
else
{
delta = FLOOR (width / geometry->max_aspect - height, yinc);
if (height + delta <= max_height)
height += delta;
}
}
if (flags & GDK_HINT_BASE_SIZE)
{
width += base_width;
height += base_height;
}
}
#undef FLOOR
*new_width = width; *new_width = width;
*new_height = height; *new_height = height;
} }

View File

@ -623,10 +623,6 @@ _gdk_macos_surface_set_geometry_hints (GdkMacosSurface *self,
g_return_if_fail (geometry != NULL); g_return_if_fail (geometry != NULL);
g_return_if_fail (self->window != NULL); g_return_if_fail (self->window != NULL);
if (geom_mask & GDK_HINT_POS) { /* TODO */ }
if (geom_mask & GDK_HINT_USER_POS) { /* TODO */ }
if (geom_mask & GDK_HINT_USER_SIZE) { /* TODO */ }
if (geom_mask & GDK_HINT_MAX_SIZE) if (geom_mask & GDK_HINT_MAX_SIZE)
max_size = NSMakeSize (geometry->max_width, geometry->max_height); max_size = NSMakeSize (geometry->max_width, geometry->max_height);
else else
@ -638,29 +634,6 @@ _gdk_macos_surface_set_geometry_hints (GdkMacosSurface *self,
else else
min_size = NSMakeSize (1, 1); min_size = NSMakeSize (1, 1);
[self->window setContentMinSize:min_size]; [self->window setContentMinSize:min_size];
if (geom_mask & GDK_HINT_BASE_SIZE) { /* TODO */ }
if (geom_mask & GDK_HINT_RESIZE_INC)
{
NSSize size = NSMakeSize (geometry->width_inc, geometry->height_inc);
[self->window setContentResizeIncrements:size];
}
if (geom_mask & GDK_HINT_ASPECT)
{
NSSize size;
if (geometry->min_aspect != geometry->max_aspect)
g_warning ("Only equal minimum and maximum aspect ratios are supported on Mac OS. Using minimum aspect ratio...");
size.width = geometry->min_aspect;
size.height = 1.0;
[self->window setContentAspectRatio:size];
}
if (geom_mask & GDK_HINT_WIN_GRAVITY) { /* TODO */ }
} }
void void

View File

@ -1306,9 +1306,6 @@ gdk_wayland_surface_configure_toplevel (GdkSurface *surface)
{ {
GdkSurfaceHints geometry_mask = impl->geometry_mask; GdkSurfaceHints geometry_mask = impl->geometry_mask;
/* Ignore size increments for maximized/fullscreen surfaces */
if (fixed_size)
geometry_mask &= ~GDK_HINT_RESIZE_INC;
if (!saved_size) if (!saved_size)
{ {
/* Do not reapply constrains if we are restoring original size */ /* Do not reapply constrains if we are restoring original size */

View File

@ -1351,17 +1351,6 @@ _gdk_win32_hrgn_to_region (HRGN hrgn,
return result; return result;
} }
static void
adjust_drag (LONG *drag,
LONG curr,
int inc)
{
if (*drag > curr)
*drag = curr + ((*drag + inc/2 - curr) / inc) * inc;
else
*drag = curr - ((curr - *drag + inc/2) / inc) * inc;
}
static void static void
handle_wm_paint (MSG *msg, handle_wm_paint (MSG *msg,
GdkSurface *window) GdkSurface *window)
@ -1998,7 +1987,7 @@ static gboolean
gdk_event_translate (MSG *msg, gdk_event_translate (MSG *msg,
int *ret_valp) int *ret_valp)
{ {
RECT rect, *drag, orig_drag; RECT rect;
POINT point; POINT point;
MINMAXINFO *mmi; MINMAXINFO *mmi;
HWND hwnd; HWND hwnd;
@ -3163,7 +3152,6 @@ gdk_event_translate (MSG *msg,
case WM_SIZING: case WM_SIZING:
GetWindowRect (GDK_SURFACE_HWND (window), &rect); GetWindowRect (GDK_SURFACE_HWND (window), &rect);
drag = (RECT *) msg->lParam;
GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s", GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s",
(msg->wParam == WMSZ_BOTTOM ? "BOTTOM" : (msg->wParam == WMSZ_BOTTOM ? "BOTTOM" :
(msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" : (msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" :
@ -3176,205 +3164,10 @@ gdk_event_translate (MSG *msg,
(msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" : (msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" :
"???")))))))), "???")))))))),
_gdk_win32_rect_to_string (&rect), _gdk_win32_rect_to_string (&rect),
_gdk_win32_rect_to_string (drag))); _gdk_win32_rect_to_string ((RECT *) msg->lParam)));
impl = GDK_WIN32_SURFACE (window); impl = GDK_WIN32_SURFACE (window);
orig_drag = *drag;
if (impl->hint_flags & GDK_HINT_RESIZE_INC)
{
GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
if (impl->hint_flags & GDK_HINT_BASE_SIZE)
{
/* Resize in increments relative to the base size */
rect.left = rect.top = 0;
rect.right = impl->hints.base_width * impl->surface_scale;
rect.bottom = impl->hints.base_height * impl->surface_scale;
_gdk_win32_adjust_client_rect (window, &rect);
point.x = rect.left;
point.y = rect.top;
ClientToScreen (GDK_SURFACE_HWND (window), &point);
rect.left = point.x;
rect.top = point.y;
point.x = rect.right;
point.y = rect.bottom;
ClientToScreen (GDK_SURFACE_HWND (window), &point);
rect.right = point.x;
rect.bottom = point.y;
GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
_gdk_win32_rect_to_string (&rect)));
}
switch (msg->wParam)
{
case WMSZ_BOTTOM:
if (drag->bottom == rect.bottom)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
break;
case WMSZ_BOTTOMLEFT:
if (drag->bottom == rect.bottom && drag->left == rect.left)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
break;
case WMSZ_LEFT:
if (drag->left == rect.left)
break;
adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
break;
case WMSZ_TOPLEFT:
if (drag->top == rect.top && drag->left == rect.left)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
break;
case WMSZ_TOP:
if (drag->top == rect.top)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
break;
case WMSZ_TOPRIGHT:
if (drag->top == rect.top && drag->right == rect.right)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
break;
case WMSZ_RIGHT:
if (drag->right == rect.right)
break;
adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
break;
case WMSZ_BOTTOMRIGHT:
if (drag->bottom == rect.bottom && drag->right == rect.right)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
break;
}
if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
drag->top != orig_drag.top || drag->right != orig_drag.right)
{
*ret_valp = TRUE;
return_val = TRUE;
GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
_gdk_win32_rect_to_string (drag)));
}
}
/* WM_GETMINMAXINFO handles min_size and max_size hints? */
if (impl->hint_flags & GDK_HINT_ASPECT)
{
RECT decorated_rect;
RECT undecorated_drag;
int decoration_width, decoration_height;
double drag_aspect;
int drag_width, drag_height, new_width, new_height;
GetClientRect (GDK_SURFACE_HWND (window), &rect);
decorated_rect = rect;
_gdk_win32_adjust_client_rect (window, &decorated_rect);
/* Set undecorated_drag to the client area being dragged
* out, in screen coordinates.
*/
undecorated_drag = *drag;
undecorated_drag.left -= decorated_rect.left - rect.left;
undecorated_drag.right -= decorated_rect.right - rect.right;
undecorated_drag.top -= decorated_rect.top - rect.top;
undecorated_drag.bottom -= decorated_rect.bottom - rect.bottom;
decoration_width = (decorated_rect.right - decorated_rect.left) - (rect.right - rect.left);
decoration_height = (decorated_rect.bottom - decorated_rect.top) - (rect.bottom - rect.top);
drag_width = undecorated_drag.right - undecorated_drag.left;
drag_height = undecorated_drag.bottom - undecorated_drag.top;
drag_aspect = (double) drag_width / drag_height;
GDK_NOTE (EVENTS, g_print (" (ASPECT:%g--%g curr: %g)",
impl->hints.min_aspect, impl->hints.max_aspect, drag_aspect));
if (drag_aspect < impl->hints.min_aspect)
{
/* Aspect is getting too narrow */
switch (msg->wParam)
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
/* User drags top or bottom edge outward. Keep height, increase width. */
new_width = impl->hints.min_aspect * drag_height;
drag->left -= (new_width - drag_width) / 2;
drag->right = drag->left + new_width + decoration_width;
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
/* User drags bottom-left or bottom-right corner down. Adjust height. */
new_height = drag_width / impl->hints.min_aspect;
drag->bottom = drag->top + new_height + decoration_height;
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
/* User drags left or right edge inward. Decrease height */
new_height = drag_width / impl->hints.min_aspect;
drag->top += (drag_height - new_height) / 2;
drag->bottom = drag->top + new_height + decoration_height;
break;
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
/* User drags top-left or top-right corner up. Adjust height. */
new_height = drag_width / impl->hints.min_aspect;
drag->top = drag->bottom - new_height - decoration_height;
}
}
else if (drag_aspect > impl->hints.max_aspect)
{
/* Aspect is getting too wide */
switch (msg->wParam)
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
/* User drags top or bottom edge inward. Decrease width. */
new_width = impl->hints.max_aspect * drag_height;
drag->left += (drag_width - new_width) / 2;
drag->right = drag->left + new_width + decoration_width;
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
/* User drags bottom-left or top-left corner left. Adjust width. */
new_width = impl->hints.max_aspect * drag_height;
drag->left = drag->right - new_width - decoration_width;
break;
case WMSZ_BOTTOMRIGHT:
case WMSZ_TOPRIGHT:
/* User drags bottom-right or top-right corner right. Adjust width. */
new_width = impl->hints.max_aspect * drag_height;
drag->right = drag->left + new_width + decoration_width;
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
/* User drags left or right edge outward. Increase height. */
new_height = drag_width / impl->hints.max_aspect;
drag->top -= (new_height - drag_height) / 2;
drag->bottom = drag->top + new_height + decoration_height;
break;
}
}
*ret_valp = TRUE;
return_val = TRUE;
GDK_NOTE (EVENTS, g_print (" (handled ASPECT: %s)",
_gdk_win32_rect_to_string (drag)));
}
break; break;
case WM_GETMINMAXINFO: case WM_GETMINMAXINFO:

View File

@ -779,75 +779,6 @@ get_outer_rect (GdkSurface *window,
_gdk_win32_adjust_client_rect (window, rect); _gdk_win32_adjust_client_rect (window, rect);
} }
static void
adjust_for_gravity_hints (GdkSurface *window,
RECT *outer_rect,
int *x,
int *y)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
if (impl->hint_flags & GDK_HINT_WIN_GRAVITY)
{
#ifdef G_ENABLE_DEBUG
int orig_x = *x, orig_y = *y;
#endif
switch (impl->hints.win_gravity)
{
case GDK_GRAVITY_NORTH:
case GDK_GRAVITY_CENTER:
case GDK_GRAVITY_SOUTH:
*x -= (outer_rect->right - outer_rect->left / 2) / impl->surface_scale;
*x += window->width / 2;
break;
case GDK_GRAVITY_SOUTH_EAST:
case GDK_GRAVITY_EAST:
case GDK_GRAVITY_NORTH_EAST:
*x -= (outer_rect->right - outer_rect->left) / impl->surface_scale;
*x += window->width;
break;
case GDK_GRAVITY_STATIC:
*x += outer_rect->left / impl->surface_scale;
break;
default:
break;
}
switch (impl->hints.win_gravity)
{
case GDK_GRAVITY_WEST:
case GDK_GRAVITY_CENTER:
case GDK_GRAVITY_EAST:
*y -= ((outer_rect->bottom - outer_rect->top) / 2) / impl->surface_scale;
*y += window->height / 2;
break;
case GDK_GRAVITY_SOUTH_WEST:
case GDK_GRAVITY_SOUTH:
case GDK_GRAVITY_SOUTH_EAST:
*y -= (outer_rect->bottom - outer_rect->top) / impl->surface_scale;
*y += window->height;
break;
case GDK_GRAVITY_STATIC:
*y += outer_rect->top * impl->surface_scale;
break;
default:
break;
}
GDK_NOTE (MISC,
(orig_x != *x || orig_y != *y) ?
g_print ("adjust_for_gravity_hints: x: %d->%d, y: %d->%d\n",
orig_x, *x, orig_y, *y)
: (void) 0);
}
}
static void static void
gdk_win32_surface_fullscreen (GdkSurface *window); gdk_win32_surface_fullscreen (GdkSurface *window);
@ -917,8 +848,6 @@ show_window_internal (GdkSurface *window,
/* For initial map of "normal" windows we want to emulate WM window /* For initial map of "normal" windows we want to emulate WM window
* positioning behaviour, which means: * positioning behaviour, which means:
* + Use user specified position if GDK_HINT_POS or GDK_HINT_USER_POS
* otherwise:
* + default to the initial CW_USEDEFAULT placement, * + default to the initial CW_USEDEFAULT placement,
* no matter if the user moved the window before showing it. * no matter if the user moved the window before showing it.
* + Certain window types and hints have more elaborate positioning * + Certain window types and hints have more elaborate positioning
@ -926,8 +855,7 @@ show_window_internal (GdkSurface *window,
*/ */
surface = GDK_WIN32_SURFACE (window); surface = GDK_WIN32_SURFACE (window);
if (!already_mapped && if (!already_mapped &&
GDK_IS_TOPLEVEL (window) && GDK_IS_TOPLEVEL (window))
(surface->hint_flags & (GDK_HINT_POS | GDK_HINT_USER_POS)) == 0)
{ {
gboolean center = FALSE; gboolean center = FALSE;
RECT window_rect, center_on_rect; RECT window_rect, center_on_rect;
@ -1141,8 +1069,6 @@ gdk_win32_surface_do_move (GdkSurface *window,
impl = GDK_WIN32_SURFACE (window); impl = GDK_WIN32_SURFACE (window);
get_outer_rect (window, window->width, window->height, &outer_rect); get_outer_rect (window, window->width, window->height, &outer_rect);
adjust_for_gravity_hints (window, &outer_rect, &x, &y);
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0," GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
"NOACTIVATE|NOSIZE|NOZORDER)\n", "NOACTIVATE|NOSIZE|NOZORDER)\n",
GDK_SURFACE_HWND (window), GDK_SURFACE_HWND (window),
@ -1227,8 +1153,6 @@ gdk_win32_surface_do_move_resize (GdkSurface *window,
get_outer_rect (window, width, height, &outer_rect); get_outer_rect (window, width, height, &outer_rect);
adjust_for_gravity_hints (window, &outer_rect, &x, &y);
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld," GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
"NOACTIVATE|NOZORDER)\n", "NOACTIVATE|NOZORDER)\n",
GDK_SURFACE_HWND (window), GDK_SURFACE_HWND (window),
@ -1510,11 +1434,6 @@ gdk_win32_surface_set_geometry_hints (GdkSurface *window,
impl->hint_flags = geom_mask; impl->hint_flags = geom_mask;
impl->hints = *geometry; impl->hints = *geometry;
if (geom_mask & GDK_HINT_POS)
{
/* even the X11 mplementation doesn't care */
}
if (geom_mask & GDK_HINT_MIN_SIZE) if (geom_mask & GDK_HINT_MIN_SIZE)
{ {
GDK_NOTE (MISC, g_print ("... MIN_SIZE: %dx%d\n", GDK_NOTE (MISC, g_print ("... MIN_SIZE: %dx%d\n",
@ -1527,29 +1446,6 @@ gdk_win32_surface_set_geometry_hints (GdkSurface *window,
geometry->max_width, geometry->max_height)); geometry->max_width, geometry->max_height));
} }
if (geom_mask & GDK_HINT_BASE_SIZE)
{
GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
geometry->base_width, geometry->base_height));
}
if (geom_mask & GDK_HINT_RESIZE_INC)
{
GDK_NOTE (MISC, g_print ("... RESIZE_INC: (%d,%d)\n",
geometry->width_inc, geometry->height_inc));
}
if (geom_mask & GDK_HINT_ASPECT)
{
GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
geometry->min_aspect, geometry->max_aspect));
}
if (geom_mask & GDK_HINT_WIN_GRAVITY)
{
GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity));
}
_gdk_win32_surface_update_style_bits (window); _gdk_win32_surface_update_style_bits (window);
} }

View File

@ -1723,8 +1723,7 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
if (toplevel) if (toplevel)
{ {
/* These are affected by surface scale: */ /* These are affected by surface scale: */
geom_mask = toplevel->last_geometry_hints_mask & geom_mask = toplevel->last_geometry_hints_mask & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
if (geom_mask) if (geom_mask)
gdk_x11_surface_set_geometry_hints (surface, gdk_x11_surface_set_geometry_hints (surface,
&toplevel->last_geometry_hints, &toplevel->last_geometry_hints,
@ -2151,27 +2150,14 @@ gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
size_hints.flags = 0; size_hints.flags = 0;
if (geom_mask & GDK_HINT_POS) size_hints.flags |= PPosition;
{ /* We need to initialize the following obsolete fields because KWM
size_hints.flags |= PPosition; * apparently uses these fields if they are non-zero.
/* We need to initialize the following obsolete fields because KWM * #@#!#!$!.
* apparently uses these fields if they are non-zero. */
* #@#!#!$!. size_hints.x = 0;
*/ size_hints.y = 0;
size_hints.x = 0;
size_hints.y = 0;
}
if (geom_mask & GDK_HINT_USER_POS)
{
size_hints.flags |= USPosition;
}
if (geom_mask & GDK_HINT_USER_SIZE)
{
size_hints.flags |= USSize;
}
if (geom_mask & GDK_HINT_MIN_SIZE) if (geom_mask & GDK_HINT_MIN_SIZE)
{ {
size_hints.flags |= PMinSize; size_hints.flags |= PMinSize;
@ -2186,19 +2172,6 @@ gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
size_hints.max_height = MAX (geometry->max_height, 1) * impl->surface_scale; size_hints.max_height = MAX (geometry->max_height, 1) * impl->surface_scale;
} }
if (geom_mask & GDK_HINT_BASE_SIZE)
{
size_hints.flags |= PBaseSize;
size_hints.base_width = geometry->base_width * impl->surface_scale;
size_hints.base_height = geometry->base_height * impl->surface_scale;
}
if (geom_mask & GDK_HINT_RESIZE_INC)
{
size_hints.flags |= PResizeInc;
size_hints.width_inc = geometry->width_inc * impl->surface_scale;
size_hints.height_inc = geometry->height_inc * impl->surface_scale;
}
else if (impl->surface_scale > 1) else if (impl->surface_scale > 1)
{ {
size_hints.flags |= PResizeInc; size_hints.flags |= PResizeInc;
@ -2206,37 +2179,6 @@ gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
size_hints.height_inc = impl->surface_scale; size_hints.height_inc = impl->surface_scale;
} }
if (geom_mask & GDK_HINT_ASPECT)
{
size_hints.flags |= PAspect;
if (geometry->min_aspect <= 1)
{
size_hints.min_aspect.x = 65536 * geometry->min_aspect;
size_hints.min_aspect.y = 65536;
}
else
{
size_hints.min_aspect.x = 65536;
size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
}
if (geometry->max_aspect <= 1)
{
size_hints.max_aspect.x = 65536 * geometry->max_aspect;
size_hints.max_aspect.y = 65536;
}
else
{
size_hints.max_aspect.x = 65536;
size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
}
}
if (geom_mask & GDK_HINT_WIN_GRAVITY)
{
size_hints.flags |= PWinGravity;
size_hints.win_gravity = geometry->win_gravity;
}
/* FIXME: Would it be better to delete this property if /* FIXME: Would it be better to delete this property if
* geom_mask == 0? It would save space on the server * geom_mask == 0? It would save space on the server
*/ */
@ -2289,27 +2231,6 @@ gdk_surface_get_geometry_hints (GdkSurface *surface,
geometry->max_height = MAX (size_hints->max_height, 1) / impl->surface_scale; geometry->max_height = MAX (size_hints->max_height, 1) / impl->surface_scale;
} }
if (size_hints->flags & PResizeInc)
{
*geom_mask |= GDK_HINT_RESIZE_INC;
geometry->width_inc = size_hints->width_inc / impl->surface_scale;
geometry->height_inc = size_hints->height_inc / impl->surface_scale;
}
if (size_hints->flags & PAspect)
{
*geom_mask |= GDK_HINT_ASPECT;
geometry->min_aspect = (double) size_hints->min_aspect.x / (double) size_hints->min_aspect.y;
geometry->max_aspect = (double) size_hints->max_aspect.x / (double) size_hints->max_aspect.y;
}
if (size_hints->flags & PWinGravity)
{
*geom_mask |= GDK_HINT_WIN_GRAVITY;
geometry->win_gravity = size_hints->win_gravity;
}
XFree (size_hints); XFree (size_hints);
} }
@ -4210,66 +4131,10 @@ static void
calculate_unmoving_origin (MoveResizeData *mv_resize) calculate_unmoving_origin (MoveResizeData *mv_resize)
{ {
GdkRectangle rect; GdkRectangle rect;
int width, height;
if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY && gdk_x11_surface_get_frame_extents (mv_resize->moveresize_surface, &rect);
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC) mv_resize->moveresize_orig_x = rect.x;
{ mv_resize->moveresize_orig_y = rect.y;
gdk_surface_get_origin (mv_resize->moveresize_surface,
&mv_resize->moveresize_orig_x,
&mv_resize->moveresize_orig_y);
}
else
{
gdk_x11_surface_get_frame_extents (mv_resize->moveresize_surface, &rect);
gdk_surface_get_geometry (mv_resize->moveresize_surface,
NULL, NULL, &width, &height);
switch (mv_resize->moveresize_geometry.win_gravity)
{
case GDK_GRAVITY_NORTH_WEST:
mv_resize->moveresize_orig_x = rect.x;
mv_resize->moveresize_orig_y = rect.y;
break;
case GDK_GRAVITY_NORTH:
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
mv_resize->moveresize_orig_y = rect.y;
break;
case GDK_GRAVITY_NORTH_EAST:
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
mv_resize->moveresize_orig_y = rect.y;
break;
case GDK_GRAVITY_WEST:
mv_resize->moveresize_orig_x = rect.x;
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
break;
case GDK_GRAVITY_CENTER:
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
break;
case GDK_GRAVITY_EAST:
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
break;
case GDK_GRAVITY_SOUTH_WEST:
mv_resize->moveresize_orig_x = rect.x;
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
break;
case GDK_GRAVITY_SOUTH:
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
break;
case GDK_GRAVITY_SOUTH_EAST:
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
break;
case GDK_GRAVITY_STATIC:
default:
mv_resize->moveresize_orig_x = rect.x;
mv_resize->moveresize_orig_y = rect.y;
break;
}
}
} }
static void static void

View File

@ -233,7 +233,6 @@ typedef struct
guint modal : 1; guint modal : 1;
guint resizable : 1; guint resizable : 1;
guint transient_parent_group : 1; guint transient_parent_group : 1;
guint gravity : 5; /* GdkGravity */
guint csd_requested : 1; guint csd_requested : 1;
guint client_decorated : 1; /* Decorations drawn client-side */ guint client_decorated : 1; /* Decorations drawn client-side */
guint use_client_shadow : 1; /* Decorations use client-side shadows */ guint use_client_shadow : 1; /* Decorations use client-side shadows */
@ -416,13 +415,6 @@ static gboolean gtk_window_compare_hints (GdkGeometry *geometry_a,
guint flags_a, guint flags_a,
GdkGeometry *geometry_b, GdkGeometry *geometry_b,
guint flags_b); guint flags_b);
static void gtk_window_constrain_size (GtkWindow *window,
GdkGeometry *geometry,
guint flags,
int width,
int height,
int *new_width,
int *new_height);
static void gtk_window_update_fixed_size (GtkWindow *window, static void gtk_window_update_fixed_size (GtkWindow *window,
GdkGeometry *new_geometry, GdkGeometry *new_geometry,
int new_width, int new_width,
@ -1499,7 +1491,6 @@ gtk_window_init (GtkWindow *window)
priv->configure_notify_received = FALSE; priv->configure_notify_received = FALSE;
priv->need_default_size = TRUE; priv->need_default_size = TRUE;
priv->modal = FALSE; priv->modal = FALSE;
priv->gravity = GDK_GRAVITY_NORTH_WEST;
priv->decorated = TRUE; priv->decorated = TRUE;
priv->display = gdk_display_get_default (); priv->display = gdk_display_get_default ();
@ -5304,10 +5295,9 @@ gtk_window_compute_configure_request (GtkWindow *window,
new_flags, new_flags,
&w, &h); &w, &h);
gtk_window_update_fixed_size (window, &new_geometry, w, h); gtk_window_update_fixed_size (window, &new_geometry, w, h);
gtk_window_constrain_size (window, gdk_surface_constrain_size (&new_geometry, new_flags,
&new_geometry, new_flags, w, h,
w, h, &w, &h);
&w, &h);
info = gtk_window_get_geometry_info (window, FALSE); info = gtk_window_get_geometry_info (window, FALSE);
@ -5462,17 +5452,6 @@ gtk_window_move_resize (GtkWindow *window)
* this. * this.
*/ */
/* Also, if the initial position was explicitly set, then we always
* toggle on PPosition. This makes gtk_window_move(window, 0, 0)
* work.
*/
if (configure_request_pos_changed)
{
new_flags |= GDK_HINT_POS;
hints_changed = TRUE;
}
current_width = gdk_surface_get_width (priv->surface); current_width = gdk_surface_get_width (priv->surface);
current_height = gdk_surface_get_height (priv->surface); current_height = gdk_surface_get_height (priv->surface);
@ -5552,7 +5531,7 @@ gtk_window_move_resize (GtkWindow *window)
return; /* Bail out, we didn't really process the move/resize */ return; /* Bail out, we didn't really process the move/resize */
} }
else if ((configure_request_size_changed || hints_changed) && else if ((configure_request_size_changed || hints_changed || configure_request_pos_changed) &&
(current_width != new_request.width || current_height != new_request.height)) (current_width != new_request.width || current_height != new_request.height))
{ {
/* We are in one of the following situations: /* We are in one of the following situations:
@ -5659,50 +5638,9 @@ gtk_window_compare_hints (GdkGeometry *geometry_a,
geometry_a->max_height != geometry_b->max_height)) geometry_a->max_height != geometry_b->max_height))
return FALSE; return FALSE;
if ((flags_a & GDK_HINT_BASE_SIZE) &&
(geometry_a->base_width != geometry_b->base_width ||
geometry_a->base_height != geometry_b->base_height))
return FALSE;
if ((flags_a & GDK_HINT_ASPECT) &&
(geometry_a->min_aspect != geometry_b->min_aspect ||
geometry_a->max_aspect != geometry_b->max_aspect))
return FALSE;
if ((flags_a & GDK_HINT_RESIZE_INC) &&
(geometry_a->width_inc != geometry_b->width_inc ||
geometry_a->height_inc != geometry_b->height_inc))
return FALSE;
if ((flags_a & GDK_HINT_WIN_GRAVITY) &&
geometry_a->win_gravity != geometry_b->win_gravity)
return FALSE;
return TRUE; return TRUE;
} }
static void
gtk_window_constrain_size (GtkWindow *window,
GdkGeometry *geometry,
guint flags,
int width,
int height,
int *new_width,
int *new_height)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
guint geometry_flags;
/* ignore size increments for windows that fit in a fixed space */
if (priv->maximized || priv->fullscreen || priv->tiled)
geometry_flags = flags & ~GDK_HINT_RESIZE_INC;
else
geometry_flags = flags;
gdk_surface_constrain_size (geometry, geometry_flags, width, height,
new_width, new_height);
}
/* For non-resizable windows, make sure the given width/height fits /* For non-resizable windows, make sure the given width/height fits
* in the geometry constrains and update the geometry hints to match * in the geometry constrains and update the geometry hints to match
* the given width/height if not. * the given width/height if not.
@ -5776,20 +5714,8 @@ gtk_window_compute_hints (GtkWindow *window,
else else
gtk_window_guess_default_size (window, &requisition.width, &requisition.height); gtk_window_guess_default_size (window, &requisition.width, &requisition.height);
/* We don't want to set GDK_HINT_POS in here, we just set it
* in gtk_window_move_resize() when we want the position
* honored.
*/
*new_flags = 0; *new_flags = 0;
/* For simplicity, we always set the base hint, even when we
* don't expect it to have any visible effect.
* (Note: geometry_size_to_pixels() depends on this.)
*/
*new_flags |= GDK_HINT_BASE_SIZE;
new_geometry->base_width = 0;
new_geometry->base_height = 0;
get_shadow_width (window, &shadow); get_shadow_width (window, &shadow);
*new_flags |= GDK_HINT_MIN_SIZE; *new_flags |= GDK_HINT_MIN_SIZE;
new_geometry->min_width = requisition.width + shadow.left + shadow.right; new_geometry->min_width = requisition.width + shadow.left + shadow.right;
@ -5802,9 +5728,6 @@ gtk_window_compute_hints (GtkWindow *window,
new_geometry->max_width = new_geometry->min_width; new_geometry->max_width = new_geometry->min_width;
new_geometry->max_height = new_geometry->min_height; new_geometry->max_height = new_geometry->min_height;
} }
*new_flags |= GDK_HINT_WIN_GRAVITY;
new_geometry->win_gravity = priv->gravity;
} }
#undef INCLUDE_CSD_SIZE #undef INCLUDE_CSD_SIZE