2020-07-30 21:06:59 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2020 Red Hat
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gdktoplevelsizeprivate.h"
|
|
|
|
|
|
|
|
/**
|
2021-02-21 05:13:57 +00:00
|
|
|
* GdkToplevelSize:
|
2020-07-30 21:06:59 +00:00
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
* The `GdkToplevelSize` struct contains information that is useful
|
2021-02-22 00:11:52 +00:00
|
|
|
* to compute the size of a toplevel.
|
2020-07-30 21:06:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
G_DEFINE_POINTER_TYPE (GdkToplevelSize, gdk_toplevel_size)
|
|
|
|
|
|
|
|
#define UNCONFIGURED_WIDTH 400
|
|
|
|
#define UNCONFIGURED_HEIGHT 300
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_toplevel_size_init (GdkToplevelSize *size,
|
|
|
|
int bounds_width,
|
|
|
|
int bounds_height)
|
|
|
|
{
|
|
|
|
*size = (GdkToplevelSize) { 0 };
|
|
|
|
|
|
|
|
size->bounds_width = bounds_width;
|
|
|
|
size->bounds_height = bounds_height;
|
|
|
|
|
|
|
|
size->width = UNCONFIGURED_WIDTH;
|
|
|
|
size->height = UNCONFIGURED_HEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_toplevel_size_get_bounds:
|
2021-02-21 05:13:57 +00:00
|
|
|
* @size: a `GdkToplevelSize`
|
2020-07-30 21:06:59 +00:00
|
|
|
* @bounds_width: (out): return location for width
|
|
|
|
* @bounds_height: (out): return location for height
|
|
|
|
*
|
|
|
|
* Retrieves the bounds the toplevel is placed within.
|
|
|
|
*
|
|
|
|
* The bounds represent the largest size a toplevel may have while still being
|
2020-08-21 12:41:13 +00:00
|
|
|
* able to fit within some type of boundary. Depending on the backend, this may
|
2020-07-30 21:06:59 +00:00
|
|
|
* be equivalent to the dimensions of the work area or the monitor on which the
|
|
|
|
* window is being presented on, or something else that limits the way a
|
|
|
|
* toplevel can be presented.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_toplevel_size_get_bounds (GdkToplevelSize *size,
|
|
|
|
int *bounds_width,
|
|
|
|
int *bounds_height)
|
|
|
|
{
|
|
|
|
g_return_if_fail (bounds_width);
|
|
|
|
g_return_if_fail (bounds_height);
|
|
|
|
|
|
|
|
*bounds_width = size->bounds_width;
|
|
|
|
*bounds_height = size->bounds_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_toplevel_size_set_size:
|
2021-02-21 05:13:57 +00:00
|
|
|
* @size: a `GdkToplevelSize`
|
2020-07-30 21:06:59 +00:00
|
|
|
* @width: the width
|
|
|
|
* @height: the height
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
* Sets the size the toplevel prefers to be resized to.
|
|
|
|
*
|
|
|
|
* The size should be within the bounds (see
|
|
|
|
* [method@Gdk.ToplevelSize.get_bounds]). The set size should
|
|
|
|
* be considered as a hint, and should not be assumed to be
|
|
|
|
* respected by the windowing system, or backend.
|
2020-07-30 21:06:59 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_toplevel_size_set_size (GdkToplevelSize *size,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
size->width = width;
|
|
|
|
size->height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_toplevel_size_set_min_size:
|
2021-02-21 05:13:57 +00:00
|
|
|
* @size: a `GdkToplevelSize`
|
2020-07-30 21:06:59 +00:00
|
|
|
* @min_width: the minimum width
|
|
|
|
* @min_height: the minimum height
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
* Sets the minimum size of the toplevel.
|
|
|
|
*
|
2020-07-30 21:06:59 +00:00
|
|
|
* The minimum size corresponds to the limitations the toplevel can be shrunk
|
2021-02-21 05:13:57 +00:00
|
|
|
* to, without resulting in incorrect painting. A user of a `GdkToplevel` should
|
2020-07-30 21:06:59 +00:00
|
|
|
* calculate these given both the existing size, and the bounds retrieved from
|
2021-02-21 05:13:57 +00:00
|
|
|
* the `GdkToplevelSize` object.
|
2020-07-30 21:06:59 +00:00
|
|
|
*
|
|
|
|
* The minimum size should be within the bounds (see
|
2021-02-21 05:13:57 +00:00
|
|
|
* [method@Gdk.ToplevelSize.get_bounds]).
|
2020-07-30 21:06:59 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_toplevel_size_set_min_size (GdkToplevelSize *size,
|
|
|
|
int min_width,
|
|
|
|
int min_height)
|
|
|
|
{
|
|
|
|
size->min_width = min_width;
|
|
|
|
size->min_height = min_height;
|
|
|
|
}
|
2020-08-07 16:45:19 +00:00
|
|
|
|
2020-12-02 16:08:43 +00:00
|
|
|
/**
|
|
|
|
* gdk_toplevel_size_set_shadow_width:
|
2021-02-21 05:13:57 +00:00
|
|
|
* @size: a `GdkToplevelSize`
|
2020-12-02 16:08:43 +00:00
|
|
|
* @left: width of the left part of the shadow
|
|
|
|
* @right: width of the right part of the shadow
|
|
|
|
* @top: height of the top part of the shadow
|
|
|
|
* @bottom: height of the bottom part of the shadow
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
* Sets the shadows size of the toplevel.
|
|
|
|
*
|
2020-12-02 16:08:43 +00:00
|
|
|
* The shadow width corresponds to the part of the computed surface size
|
|
|
|
* that would consist of the shadow margin surrounding the window, would
|
|
|
|
* there be any.
|
|
|
|
*/
|
2020-11-24 14:51:56 +00:00
|
|
|
void
|
2020-12-02 16:08:43 +00:00
|
|
|
gdk_toplevel_size_set_shadow_width (GdkToplevelSize *size,
|
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom)
|
2020-11-24 14:51:56 +00:00
|
|
|
{
|
2020-12-02 16:08:43 +00:00
|
|
|
size->shadow.is_valid = TRUE;
|
|
|
|
size->shadow.left = left;
|
|
|
|
size->shadow.right = right;
|
|
|
|
size->shadow.top = top;
|
|
|
|
size->shadow.bottom = bottom;
|
2020-11-24 14:51:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 16:45:19 +00:00
|
|
|
void
|
|
|
|
gdk_toplevel_size_validate (GdkToplevelSize *size)
|
|
|
|
{
|
2021-05-03 02:34:22 +00:00
|
|
|
#if 0
|
2020-12-02 09:57:32 +00:00
|
|
|
int geometry_width, geometry_height;
|
|
|
|
|
|
|
|
geometry_width = size->width;
|
|
|
|
geometry_height = size->height;
|
2020-12-02 16:08:43 +00:00
|
|
|
if (size->shadow.is_valid)
|
2020-12-02 09:57:32 +00:00
|
|
|
{
|
2020-12-02 16:08:43 +00:00
|
|
|
geometry_width -= size->shadow.left + size->shadow.right;
|
|
|
|
geometry_height -= size->shadow.top + size->shadow.bottom;
|
2020-12-02 09:57:32 +00:00
|
|
|
}
|
2021-05-03 02:34:22 +00:00
|
|
|
#endif
|
2020-08-07 16:45:19 +00:00
|
|
|
}
|