forked from AuroraMiddleware/gtk
Merge branch 'gdk-api-cleanups' into 'master'
Gdk api cleanups See merge request GNOME/gtk!669
This commit is contained in:
commit
8984320964
@ -271,7 +271,6 @@ gdk_surface_get_frame_extents
|
||||
gdk_surface_get_origin
|
||||
gdk_surface_get_root_coords
|
||||
gdk_surface_get_device_position
|
||||
gdk_surface_get_device_position_double
|
||||
GdkModifierType
|
||||
GdkModifierIntent
|
||||
gdk_surface_get_parent
|
||||
@ -511,9 +510,7 @@ gdk_device_ungrab
|
||||
<SUBSECTION>
|
||||
gdk_device_get_state
|
||||
gdk_device_get_position
|
||||
gdk_device_get_position_double
|
||||
gdk_device_get_surface_at_position
|
||||
gdk_device_get_surface_at_position_double
|
||||
gdk_device_get_history
|
||||
gdk_device_free_history
|
||||
GdkTimeCoord
|
||||
|
@ -4688,8 +4688,6 @@ gtk_window_activate_focus
|
||||
gtk_window_activate_default
|
||||
gtk_window_set_modal
|
||||
gtk_window_set_default_size
|
||||
gtk_window_set_gravity
|
||||
gtk_window_get_gravity
|
||||
gtk_window_set_hide_on_close
|
||||
gtk_window_get_hide_on_close
|
||||
GtkWindowPosition
|
||||
@ -4746,7 +4744,6 @@ gtk_window_get_destroy_with_parent
|
||||
gtk_window_get_icon_name
|
||||
gtk_window_get_mnemonic_modifier
|
||||
gtk_window_get_modal
|
||||
gtk_window_get_position
|
||||
gtk_window_get_role
|
||||
gtk_window_get_size
|
||||
gtk_window_get_title
|
||||
@ -4761,7 +4758,6 @@ gtk_window_get_focus_on_map
|
||||
gtk_window_get_group
|
||||
gtk_window_has_group
|
||||
gtk_window_get_window_type
|
||||
gtk_window_move
|
||||
gtk_window_resize
|
||||
gtk_window_set_default_icon_name
|
||||
gtk_window_set_icon_name
|
||||
|
@ -150,11 +150,8 @@ see for example <link
|
||||
linkend="gtk-window-iconify">gtk_window_iconify()</link> or <link
|
||||
linkend="gtk-window-maximize">gtk_window_maximize()</link> or <link
|
||||
linkend="gtk-window-set-decorated">gtk_window_set_decorated()</link>.
|
||||
Keep in mind that <link
|
||||
linkend="gtk-window-move">gtk_window_move()</link> and window sizing
|
||||
are ultimately controlled by the window manager as well and most
|
||||
window managers <emphasis>will</emphasis> ignore certain requests from
|
||||
time to time, in the interests of good user interface.
|
||||
Keep in mind that most window managers <emphasis>will</emphasis> ignore
|
||||
certain requests from time to time, in the interests of good user interface.
|
||||
</para>
|
||||
|
||||
<!--
|
||||
|
@ -106,7 +106,7 @@ gdk_broadway_device_get_state (GdkDevice *device,
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
gdk_surface_get_device_position_double (surface, device, &x, &y, mask);
|
||||
gdk_surface_get_device_position (surface, device, &x, &y, mask);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
|
@ -529,7 +529,7 @@ gdk_device_get_state (GdkDevice *device,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_position_double:
|
||||
* gdk_device_get_position:
|
||||
* @device: pointer device to query status about.
|
||||
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
|
||||
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
|
||||
@ -540,9 +540,9 @@ gdk_device_get_state (GdkDevice *device,
|
||||
* unless there is an ongoing grab on them. See gdk_device_grab().
|
||||
**/
|
||||
void
|
||||
gdk_device_get_position_double (GdkDevice *device,
|
||||
gdouble *x,
|
||||
gdouble *y)
|
||||
gdk_device_get_position (GdkDevice *device,
|
||||
double *x,
|
||||
double *y)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
gdouble tmp_x, tmp_y;
|
||||
@ -568,33 +568,7 @@ gdk_device_get_position_double (GdkDevice *device,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_position:
|
||||
* @device: pointer device to query status about.
|
||||
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
|
||||
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
|
||||
*
|
||||
* Gets the current location of @device. As a slave device
|
||||
* coordinates are those of its master pointer, This function
|
||||
* may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
|
||||
* unless there is an ongoing grab on them, see gdk_device_grab().
|
||||
**/
|
||||
void
|
||||
gdk_device_get_position (GdkDevice *device,
|
||||
gint *x,
|
||||
gint *y)
|
||||
{
|
||||
gdouble tmp_x, tmp_y;
|
||||
|
||||
gdk_device_get_position_double (device, &tmp_x, &tmp_y);
|
||||
if (x)
|
||||
*x = round (tmp_x);
|
||||
if (y)
|
||||
*y = round (tmp_y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gdk_device_get_surface_at_position_double:
|
||||
* gdk_device_get_surface_at_position:
|
||||
* @device: pointer #GdkDevice to query info to.
|
||||
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
|
||||
* relative to the surface origin, or %NULL.
|
||||
@ -613,9 +587,9 @@ gdk_device_get_position (GdkDevice *device,
|
||||
* device position, or %NULL.
|
||||
**/
|
||||
GdkSurface *
|
||||
gdk_device_get_surface_at_position_double (GdkDevice *device,
|
||||
gdouble *win_x,
|
||||
gdouble *win_y)
|
||||
gdk_device_get_surface_at_position (GdkDevice *device,
|
||||
double *win_x,
|
||||
double *win_y)
|
||||
{
|
||||
gdouble tmp_x, tmp_y;
|
||||
GdkSurface *surface;
|
||||
@ -642,43 +616,6 @@ gdk_device_get_surface_at_position_double (GdkDevice *device,
|
||||
return surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_surface_at_position:
|
||||
* @device: pointer #GdkDevice to query info to.
|
||||
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
|
||||
* relative to the surface origin, or %NULL.
|
||||
* @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
|
||||
* relative to the surface origin, or %NULL.
|
||||
*
|
||||
* Obtains the surface underneath @device, returning the location of the device in @win_x and @win_y. Returns
|
||||
* %NULL if the surface tree under @device is not known to GDK (for example, belongs to another application).
|
||||
*
|
||||
* As a slave device coordinates are those of its master pointer, This
|
||||
* function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
|
||||
* unless there is an ongoing grab on them, see gdk_device_grab().
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the #GdkSurface under the
|
||||
* device position, or %NULL.
|
||||
**/
|
||||
GdkSurface *
|
||||
gdk_device_get_surface_at_position (GdkDevice *device,
|
||||
gint *win_x,
|
||||
gint *win_y)
|
||||
{
|
||||
gdouble tmp_x, tmp_y;
|
||||
GdkSurface *surface;
|
||||
|
||||
surface =
|
||||
gdk_device_get_surface_at_position_double (device, &tmp_x, &tmp_y);
|
||||
|
||||
if (win_x)
|
||||
*win_x = round (tmp_x);
|
||||
if (win_y)
|
||||
*win_y = round (tmp_y);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_history: (skip)
|
||||
* @device: a #GdkDevice
|
||||
|
@ -167,25 +167,13 @@ void gdk_device_get_state (GdkDevice *device,
|
||||
gdouble *axes,
|
||||
GdkModifierType *mask);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_device_get_position (GdkDevice *device,
|
||||
gint *x,
|
||||
gint *y);
|
||||
void gdk_device_get_position (GdkDevice *device,
|
||||
double *x,
|
||||
double *y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *
|
||||
gdk_device_get_surface_at_position
|
||||
(GdkDevice *device,
|
||||
gint *win_x,
|
||||
gint *win_y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_device_get_position_double (GdkDevice *device,
|
||||
gdouble *x,
|
||||
gdouble *y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *
|
||||
gdk_device_get_surface_at_position_double
|
||||
(GdkDevice *device,
|
||||
gdouble *win_x,
|
||||
gdouble *win_y);
|
||||
GdkSurface * gdk_device_get_surface_at_position (GdkDevice *device,
|
||||
double *win_x,
|
||||
double *win_y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_device_get_history (GdkDevice *device,
|
||||
GdkSurface *surface,
|
||||
|
3001
gdk/gdksurface.c
3001
gdk/gdksurface.c
File diff suppressed because it is too large
Load Diff
@ -640,18 +640,12 @@ GDK_AVAILABLE_IN_ALL
|
||||
gint gdk_surface_get_scale_factor (GdkSurface *surface);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_surface_get_device_position (GdkSurface *surface,
|
||||
GdkSurface * gdk_surface_get_device_position (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint *x,
|
||||
gint *y,
|
||||
double *x,
|
||||
double *y,
|
||||
GdkModifierType *mask);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_surface_get_device_position_double (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
GdkModifierType *mask);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_surface_get_parent (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_surface_get_toplevel (GdkSurface *surface);
|
||||
@ -731,31 +725,31 @@ void gdk_surface_register_dnd (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_resize_drag (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp);
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_resize_drag_for_device (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp);
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_move_drag (GdkSurface *surface,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp);
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_move_drag_for_device (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp);
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
|
||||
/* Interface for dirty-region queueing */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -125,7 +125,7 @@ gdk_quartz_device_core_get_state (GdkDevice *device,
|
||||
{
|
||||
gdouble x_pos, y_pos;
|
||||
|
||||
gdk_surface_get_device_position_double (window, device, &x_pos, &y_pos, mask);
|
||||
gdk_surface_get_device_position (window, device, &x_pos, &y_pos, mask);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
|
@ -321,7 +321,7 @@ gdk_wayland_device_get_state (GdkDevice *device,
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
gdk_surface_get_device_position_double (surface, device, &x, &y, mask);
|
||||
gdk_surface_get_device_position (surface, device, &x, &y, mask);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
@ -614,9 +614,9 @@ emulate_crossing (GdkSurface *surface,
|
||||
gdk_event_set_device (event, device);
|
||||
gdk_event_set_source_device (event, device);
|
||||
|
||||
gdk_surface_get_device_position_double (surface, device,
|
||||
&event->crossing.x, &event->crossing.y,
|
||||
&event->crossing.state);
|
||||
gdk_surface_get_device_position (surface, device,
|
||||
&event->crossing.x, &event->crossing.y,
|
||||
&event->crossing.state);
|
||||
event->crossing.x_root = event->crossing.x;
|
||||
event->crossing.y_root = event->crossing.y;
|
||||
|
||||
|
@ -2447,8 +2447,7 @@ gdk_wayland_surface_map (GdkSurface *surface)
|
||||
GDK_SURFACE_IMPL_WAYLAND (attached_grab_surface->impl);
|
||||
grab_device = gdk_seat_get_pointer (attached_impl->grab_input_seat);
|
||||
transient_for =
|
||||
gdk_device_get_surface_at_position (grab_device,
|
||||
NULL, NULL);
|
||||
gdk_device_get_surface_at_position (grab_device, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2465,8 +2464,13 @@ gdk_wayland_surface_map (GdkSurface *surface)
|
||||
* position of the device that holds the grab.
|
||||
*/
|
||||
if (impl->position_method == POSITION_METHOD_NONE && grab_device)
|
||||
gdk_surface_get_device_position (transient_for, grab_device,
|
||||
&surface->x, &surface->y, NULL);
|
||||
{
|
||||
double px, py;
|
||||
gdk_surface_get_device_position (transient_for, grab_device,
|
||||
&px, &py, NULL);
|
||||
surface->x = round (px);
|
||||
surface->y = round (py);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3556,8 +3560,8 @@ gdk_wayland_surface_begin_resize_drag (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GdkSurfaceImplWayland *impl;
|
||||
@ -3646,8 +3650,8 @@ static void
|
||||
gdk_wayland_surface_begin_move_drag (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GdkSurfaceImplWayland *impl;
|
||||
|
@ -45,14 +45,14 @@ gdk_device_win32_get_state (GdkDevice *device,
|
||||
gdouble *axes,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
gint x_int, y_int;
|
||||
double x, y;
|
||||
|
||||
gdk_surface_get_device_position (window, device, &x_int, &y_int, mask);
|
||||
gdk_surface_get_device_position (window, device, &x, &y, mask);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
axes[0] = x_int;
|
||||
axes[1] = y_int;
|
||||
axes[0] = round (x);
|
||||
axes[1] = round (y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -888,7 +888,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
PACKET packet;
|
||||
gint root_x, root_y;
|
||||
gint num_axes;
|
||||
gint x, y;
|
||||
double x, y;
|
||||
guint translated_buttons, button_diff, button_mask;
|
||||
/* Translation from tablet button state to GDK button state for
|
||||
* buttons 1-3 - swap button 2 and 3.
|
||||
@ -908,7 +908,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
g_object_ref (window);
|
||||
|
||||
GDK_NOTE (EVENTS_OR_INPUT,
|
||||
g_print ("gdk_input_other_event: window=%p %+d%+d\n",
|
||||
g_print ("gdk_input_other_event: window=%p %+g%+g\n",
|
||||
window ? GDK_SURFACE_HWND (window) : NULL, x, y));
|
||||
|
||||
if (msg->message == WT_PACKET || msg->message == WT_CSRCHANGE)
|
||||
|
@ -1717,6 +1717,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDrag *drag;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
double px, py;
|
||||
int x_root, y_root;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
@ -1731,9 +1732,9 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
|
||||
|
||||
gdk_device_get_position (device, &x_root, &y_root);
|
||||
x_root += dx;
|
||||
y_root += dy;
|
||||
gdk_device_get_position (device, &px, &px);
|
||||
x_root = round (px) + dx;
|
||||
y_root = round (py) + dy;
|
||||
|
||||
drag_win32->start_x = x_root;
|
||||
drag_win32->start_y = y_root;
|
||||
|
@ -192,7 +192,7 @@ gdk_x11_device_core_get_state (GdkDevice *device,
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
gdk_surface_get_device_position_double (surface, device, &x, &y, mask);
|
||||
gdk_surface_get_device_position (surface, device, &x, &y, mask);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
|
@ -2077,6 +2077,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
|
||||
GdkX11Drag *x11_drag;
|
||||
GdkDrag *drag;
|
||||
GdkDisplay *display;
|
||||
double px, py;
|
||||
int x_root, y_root;
|
||||
Atom xselection;
|
||||
GdkSurface *ipc_surface;
|
||||
@ -2097,9 +2098,9 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
|
||||
|
||||
precache_target_list (drag);
|
||||
|
||||
gdk_device_get_position (device, &x_root, &y_root);
|
||||
x_root += dx;
|
||||
y_root += dy;
|
||||
gdk_device_get_position (device, &px, &py);
|
||||
x_root = round (px) + dx;
|
||||
y_root = round (py) + dy;
|
||||
|
||||
x11_drag->start_x = x_root;
|
||||
x11_drag->start_y = y_root;
|
||||
|
@ -4293,12 +4293,12 @@ emulate_resize_drag (GdkSurface *surface,
|
||||
}
|
||||
|
||||
static void
|
||||
emulate_move_drag (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
emulate_move_drag (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MoveResizeData *mv_resize = get_move_resize_data (GDK_SURFACE_DISPLAY (surface), TRUE);
|
||||
|
||||
@ -4338,17 +4338,21 @@ _should_perform_ewmh_drag (GdkSurface *surface,
|
||||
|
||||
static void
|
||||
gdk_x11_surface_begin_resize_drag (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
int root_x, root_y;
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (surface) ||
|
||||
!SURFACE_IS_TOPLEVEL (surface))
|
||||
return;
|
||||
|
||||
gdk_surface_x11_get_root_coords (surface, x, y, &root_x, &root_y);
|
||||
|
||||
/* Avoid EWMH for touch devices */
|
||||
if (_should_perform_ewmh_drag (surface, device))
|
||||
wmspec_resize_drag (surface, edge, device, button, root_x, root_y, timestamp);
|
||||
@ -4358,12 +4362,13 @@ gdk_x11_surface_begin_resize_drag (GdkSurface *surface,
|
||||
|
||||
static void
|
||||
gdk_x11_surface_begin_move_drag (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
int root_x, root_y;
|
||||
gint direction;
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface))
|
||||
@ -4374,6 +4379,8 @@ gdk_x11_surface_begin_move_drag (GdkSurface *surface,
|
||||
else
|
||||
direction = _NET_WM_MOVERESIZE_MOVE;
|
||||
|
||||
gdk_surface_x11_get_root_coords (surface, x, y, &root_x, &root_y);
|
||||
|
||||
/* Avoid EWMH for touch devices */
|
||||
if (_should_perform_ewmh_drag (surface, device))
|
||||
wmspec_moveresize (surface, direction, device, button, root_x, root_y, timestamp);
|
||||
|
@ -625,39 +625,7 @@ gtk_widget_accessible_set_extents (AtkComponent *component,
|
||||
gint height,
|
||||
AtkCoordType coord_type)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
|
||||
if (widget == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gtk_widget_is_toplevel (widget))
|
||||
return FALSE;
|
||||
|
||||
if (coord_type == ATK_XY_WINDOW)
|
||||
{
|
||||
gint x_current, y_current;
|
||||
GdkSurface *surface = gtk_widget_get_surface (widget);
|
||||
|
||||
gdk_surface_get_origin (surface, &x_current, &y_current);
|
||||
x_current += x;
|
||||
y_current += y;
|
||||
if (x_current < 0 || y_current < 0)
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
gtk_window_move (GTK_WINDOW (widget), x_current, y_current);
|
||||
gtk_widget_set_size_request (widget, width, height);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (coord_type == ATK_XY_SCREEN)
|
||||
{
|
||||
gtk_window_move (GTK_WINDOW (widget), x, y);
|
||||
gtk_widget_set_size_request (widget, width, height);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -666,37 +634,7 @@ gtk_widget_accessible_set_position (AtkComponent *component,
|
||||
gint y,
|
||||
AtkCoordType coord_type)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
|
||||
if (widget == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (gtk_widget_is_toplevel (widget))
|
||||
{
|
||||
if (coord_type == ATK_XY_WINDOW)
|
||||
{
|
||||
gint x_current, y_current;
|
||||
GdkSurface *surface = gtk_widget_get_surface (widget);
|
||||
|
||||
gdk_surface_get_origin (surface, &x_current, &y_current);
|
||||
x_current += x;
|
||||
y_current += y;
|
||||
if (x_current < 0 || y_current < 0)
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
gtk_window_move (GTK_WINDOW (widget), x_current, y_current);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (coord_type == ATK_XY_SCREEN)
|
||||
{
|
||||
gtk_window_move (GTK_WINDOW (widget), x, y);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -704,18 +642,6 @@ gtk_widget_accessible_set_size (AtkComponent *component,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
|
||||
if (widget == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (gtk_widget_is_toplevel (widget))
|
||||
{
|
||||
gtk_widget_set_size_request (widget, width, height);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
14
gtk/gtkdnd.c
14
gtk/gtkdnd.c
@ -886,6 +886,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
||||
GtkDragSourceInfo *info;
|
||||
GtkWidget *toplevel;
|
||||
GdkDrag *drag;
|
||||
double px, py;
|
||||
int dx, dy;
|
||||
GtkDragContent *content;
|
||||
|
||||
@ -893,14 +894,13 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
||||
device = gdk_device_get_associated_device (device);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
gtk_widget_translate_coordinates (widget, toplevel,
|
||||
x, y, &x, &y);
|
||||
gtk_widget_translate_coordinates (widget, toplevel, x, y, &x, &y);
|
||||
gdk_surface_get_device_position (gtk_widget_get_surface (toplevel),
|
||||
device,
|
||||
&dx, &dy,
|
||||
NULL);
|
||||
dx -= x;
|
||||
dy -= y;
|
||||
device,
|
||||
&px, &py,
|
||||
NULL);
|
||||
dx = round (px) - x;
|
||||
dy = round (py) - y;
|
||||
|
||||
content = g_object_new (GTK_TYPE_DRAG_CONTENT, NULL);
|
||||
content->widget = g_object_ref (widget);
|
||||
|
@ -581,39 +581,9 @@ gtk_file_chooser_dialog_map (GtkWidget *widget)
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
save_dialog_geometry (GtkFileChooserDialog *dialog)
|
||||
{
|
||||
GtkWindow *window;
|
||||
GSettings *settings;
|
||||
int old_x, old_y, old_width, old_height;
|
||||
int x, y, width, height;
|
||||
|
||||
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (dialog));
|
||||
|
||||
window = GTK_WINDOW (dialog);
|
||||
|
||||
gtk_window_get_position (window, &x, &y);
|
||||
gtk_window_get_size (window, &width, &height);
|
||||
|
||||
g_settings_get (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", &old_x, &old_y);
|
||||
if (old_x != x || old_y != y)
|
||||
g_settings_set (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", x, y);
|
||||
|
||||
g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &old_width, &old_height);
|
||||
if (old_width != width || old_height != height)
|
||||
g_settings_set (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", width, height);
|
||||
|
||||
g_settings_apply (settings);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_dialog_unmap (GtkWidget *widget)
|
||||
{
|
||||
GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
|
||||
|
||||
save_dialog_geometry (dialog);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
@ -627,8 +597,6 @@ gtk_file_chooser_dialog_size_allocate (GtkWidget *widget,
|
||||
width,
|
||||
height,
|
||||
baseline);
|
||||
if (gtk_widget_is_drawable (widget))
|
||||
save_dialog_geometry (GTK_FILE_CHOOSER_DIALOG (widget));
|
||||
}
|
||||
|
||||
/* We do a signal connection here rather than overriding the method in
|
||||
|
@ -40,7 +40,6 @@ G_BEGIN_DECLS
|
||||
#define SETTINGS_KEY_SHOW_SIZE_COLUMN "show-size-column"
|
||||
#define SETTINGS_KEY_SORT_COLUMN "sort-column"
|
||||
#define SETTINGS_KEY_SORT_ORDER "sort-order"
|
||||
#define SETTINGS_KEY_WINDOW_POSITION "window-position"
|
||||
#define SETTINGS_KEY_WINDOW_SIZE "window-size"
|
||||
#define SETTINGS_KEY_SIDEBAR_WIDTH "sidebar-width"
|
||||
#define SETTINGS_KEY_STARTUP_MODE "startup-mode"
|
||||
|
@ -6068,15 +6068,14 @@ gtk_file_chooser_widget_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser_embed);
|
||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||
GtkRequisition req;
|
||||
int x, y, width, height;
|
||||
int width, height;
|
||||
GSettings *settings;
|
||||
|
||||
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
|
||||
|
||||
g_settings_get (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", &x, &y);
|
||||
g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
|
||||
|
||||
if (x >= 0 && y >= 0 && width > 0 && height > 0)
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
*default_width = width;
|
||||
*default_height = height;
|
||||
|
@ -1823,7 +1823,12 @@ gtk_menu_popup_at_pointer (GtkMenu *menu,
|
||||
device = gdk_device_get_associated_device (device);
|
||||
|
||||
if (device)
|
||||
gdk_surface_get_device_position (rect_surface, device, &rect.x, &rect.y, NULL);
|
||||
{
|
||||
double px, py;
|
||||
gdk_surface_get_device_position (rect_surface, device, &px, &py, NULL);
|
||||
rect.x = round (px);
|
||||
rect.y = round (py);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3137,11 +3137,11 @@ gtk_notebook_drag_end (GtkWidget *widget,
|
||||
if (priv->rootwindow_drop)
|
||||
{
|
||||
GtkNotebook *dest_notebook = NULL;
|
||||
gint x, y;
|
||||
double x, y;
|
||||
|
||||
gdk_device_get_position (gdk_drag_get_device (drag), &x, &y);
|
||||
g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0,
|
||||
priv->detached_tab->child, x, y, &dest_notebook);
|
||||
priv->detached_tab->child, round (x), round (y), &dest_notebook);
|
||||
|
||||
if (dest_notebook)
|
||||
do_detach_tab (notebook, dest_notebook, priv->detached_tab->child);
|
||||
@ -3186,12 +3186,12 @@ gtk_notebook_drag_failed (GtkWidget *widget,
|
||||
if (result == GTK_DRAG_RESULT_NO_TARGET)
|
||||
{
|
||||
GtkNotebook *dest_notebook = NULL;
|
||||
gint x, y;
|
||||
double x, y;
|
||||
|
||||
gdk_device_get_position (gdk_drag_get_device (drag), &x, &y);
|
||||
|
||||
g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0,
|
||||
priv->detached_tab->child, x, y, &dest_notebook);
|
||||
priv->detached_tab->child, round (x), round (y), &dest_notebook);
|
||||
|
||||
if (dest_notebook)
|
||||
do_detach_tab (notebook, dest_notebook, priv->detached_tab->child);
|
||||
|
@ -382,7 +382,7 @@ void
|
||||
gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
gint x, y;
|
||||
double x, y;
|
||||
GdkSurface *surface;
|
||||
GdkDevice *device;
|
||||
GtkWidget *toplevel;
|
||||
@ -403,7 +403,7 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
|
||||
if (gtk_widget_get_surface (toplevel) != surface)
|
||||
return;
|
||||
|
||||
gtk_widget_translate_coordinates (toplevel, widget, x, y, &dx, &dy);
|
||||
gtk_widget_translate_coordinates (toplevel, widget, round (x), round (y), &dx, &dy);
|
||||
|
||||
gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, widget, dx, dy);
|
||||
}
|
||||
@ -618,6 +618,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
|
||||
const int max_x_distance = 32;
|
||||
/* Max 48x48 icon + default padding */
|
||||
const int max_anchor_rect_height = 48 + 8;
|
||||
double px, py;
|
||||
int pointer_x, pointer_y;
|
||||
|
||||
/*
|
||||
@ -633,9 +634,9 @@ gtk_tooltip_position (GtkTooltip *tooltip,
|
||||
* far away from the pointer position.
|
||||
*/
|
||||
effective_toplevel = _gtk_widget_get_surface (toplevel);
|
||||
gdk_surface_get_device_position (effective_toplevel,
|
||||
device,
|
||||
&pointer_x, &pointer_y, NULL);
|
||||
gdk_surface_get_device_position (effective_toplevel, device, &px, &py, NULL);
|
||||
pointer_x = round (px);
|
||||
pointer_y = round (py);
|
||||
|
||||
if (anchor_rect.height > max_anchor_rect_height)
|
||||
{
|
||||
@ -674,6 +675,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
|
||||
static void
|
||||
gtk_tooltip_show_tooltip (GdkDisplay *display)
|
||||
{
|
||||
double px, py;
|
||||
gint x, y;
|
||||
GdkSurface *surface;
|
||||
GtkWidget *tooltip_widget;
|
||||
@ -693,7 +695,9 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
|
||||
|
||||
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
|
||||
|
||||
gdk_surface_get_device_position (surface, device, &x, &y, NULL);
|
||||
gdk_surface_get_device_position (surface, device, &px, &py, NULL);
|
||||
x = round (px);
|
||||
y = round (py);
|
||||
|
||||
gdk_surface_get_root_coords (surface, x, y, &tx, &ty);
|
||||
tooltip_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y);
|
||||
|
@ -6717,57 +6717,6 @@ remove_info (GtkTreeView *tree_view)
|
||||
g_object_set_data (G_OBJECT (tree_view), I_("gtk-tree-view-drag-info"), NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static gint
|
||||
drag_scan_timeout (gpointer data)
|
||||
{
|
||||
GtkTreeView *tree_view;
|
||||
gint x, y;
|
||||
GdkModifierType state;
|
||||
GtkTreePath *path = NULL;
|
||||
GtkTreeViewColumn *column = NULL;
|
||||
GdkRectangle visible_rect;
|
||||
GdkSeat *seat;
|
||||
|
||||
tree_view = GTK_TREE_VIEW (data);
|
||||
|
||||
seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (tree_view)));
|
||||
gdk_surface_get_device_position (tree_view->priv->bin_window,
|
||||
gdk_seat_get_pointer (seat),
|
||||
&x, &y, &state);
|
||||
|
||||
gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
|
||||
|
||||
/* See if we are near the edge. */
|
||||
if ((x - visible_rect.x) < SCROLL_EDGE_SIZE ||
|
||||
(visible_rect.x + visible_rect.width - x) < SCROLL_EDGE_SIZE ||
|
||||
(y - visible_rect.y) < SCROLL_EDGE_SIZE ||
|
||||
(visible_rect.y + visible_rect.height - y) < SCROLL_EDGE_SIZE)
|
||||
{
|
||||
gtk_tree_view_get_path_at_pos (tree_view,
|
||||
tree_view->priv->bin_window,
|
||||
x, y,
|
||||
&path,
|
||||
&column,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (path != NULL)
|
||||
{
|
||||
gtk_tree_view_scroll_to_cell (tree_view,
|
||||
path,
|
||||
column,
|
||||
TRUE,
|
||||
0.5, 0.5);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
static void
|
||||
add_scroll_timeout (GtkTreeView *tree_view)
|
||||
{
|
||||
@ -13795,39 +13744,6 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
|
||||
GtkWidget *search_window,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint x, y;
|
||||
GtkAllocation allocation;
|
||||
GdkDisplay *display;
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle workarea;
|
||||
GdkSurface *tree_surface = gtk_widget_get_surface (GTK_WIDGET (tree_view));
|
||||
GtkRequisition requisition;
|
||||
|
||||
gtk_widget_realize (search_window);
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (tree_view));
|
||||
monitor = gdk_display_get_monitor_at_surface (display, tree_surface);
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
gdk_monitor_get_workarea (monitor, &workarea);
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
|
||||
gtk_widget_get_preferred_size (search_window, &requisition, NULL);
|
||||
|
||||
if (allocation.x + allocation.width > workarea.x + workarea.width)
|
||||
x = workarea.x + workarea.width - requisition.width;
|
||||
else if (allocation.x + allocation.width - requisition.width < workarea.x)
|
||||
x = workarea.x;
|
||||
else
|
||||
x = allocation.x + allocation.width - requisition.width;
|
||||
|
||||
if (allocation.y + allocation.height + requisition.height > workarea.y + workarea.height)
|
||||
y = workarea.y + workarea.height - requisition.height;
|
||||
else if (allocation.y + allocation.height < workarea.y) /* isn't really possible ... */
|
||||
y = workarea.y;
|
||||
else
|
||||
y = allocation.y + allocation.height;
|
||||
|
||||
gtk_window_move (GTK_WINDOW (search_window), x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -8642,14 +8642,14 @@ synth_crossing (GtkWidget *widget,
|
||||
event->any.send_event = TRUE;
|
||||
event->crossing.child_surface = g_object_ref (surface);
|
||||
event->crossing.time = GDK_CURRENT_TIME;
|
||||
gdk_device_get_position_double (device,
|
||||
&event->crossing.x_root,
|
||||
&event->crossing.y_root);
|
||||
gdk_surface_get_device_position_double (surface,
|
||||
device,
|
||||
&event->crossing.x,
|
||||
&event->crossing.y,
|
||||
NULL);
|
||||
gdk_device_get_position (device,
|
||||
&event->crossing.x_root,
|
||||
&event->crossing.y_root);
|
||||
gdk_surface_get_device_position (surface,
|
||||
device,
|
||||
&event->crossing.x,
|
||||
&event->crossing.y,
|
||||
NULL);
|
||||
event->crossing.mode = mode;
|
||||
event->crossing.detail = detail;
|
||||
event->crossing.focus = FALSE;
|
||||
|
504
gtk/gtkwindow.c
504
gtk/gtkwindow.c
@ -330,7 +330,6 @@ enum {
|
||||
PROP_FOCUS_ON_MAP,
|
||||
PROP_DECORATED,
|
||||
PROP_DELETABLE,
|
||||
PROP_GRAVITY,
|
||||
PROP_TRANSIENT_FOR,
|
||||
PROP_ATTACHED_TO,
|
||||
PROP_APPLICATION,
|
||||
@ -1037,20 +1036,6 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWindow:gravity:
|
||||
*
|
||||
* The window gravity of the window. See gtk_window_move() and #GdkGravity for
|
||||
* more details about window gravity.
|
||||
*/
|
||||
window_props[PROP_GRAVITY] =
|
||||
g_param_spec_enum ("gravity",
|
||||
P_("Gravity"),
|
||||
P_("The window gravity of the window"),
|
||||
GDK_TYPE_GRAVITY,
|
||||
GDK_GRAVITY_NORTH_WEST,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWindow:transient-for:
|
||||
*
|
||||
@ -1480,16 +1465,15 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
|
||||
default:
|
||||
if (!priv->maximized)
|
||||
{
|
||||
gdouble x_root, y_root;
|
||||
|
||||
double tx, ty;
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
gdk_event_get_root_coords (event, &x_root, &y_root);
|
||||
gdk_event_get_coords (event, &tx, &ty);
|
||||
gdk_surface_begin_resize_drag_for_device (_gtk_widget_get_surface (widget),
|
||||
(GdkSurfaceEdge) region,
|
||||
gdk_event_get_device ((GdkEvent *) event),
|
||||
GDK_BUTTON_PRIMARY,
|
||||
x_root, y_root,
|
||||
tx, ty,
|
||||
gdk_event_get_time (event));
|
||||
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
@ -1565,7 +1549,6 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
gdouble start_x, start_y;
|
||||
gint x_root, y_root;
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
|
||||
@ -1595,13 +1578,11 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||
gdk_surface_get_root_coords (_gtk_widget_get_surface (GTK_WIDGET (window)),
|
||||
start_x, start_y, &x_root, &y_root);
|
||||
|
||||
gdk_surface_begin_move_drag_for_device (_gtk_widget_get_surface (GTK_WIDGET (window)),
|
||||
gtk_gesture_get_device (GTK_GESTURE (gesture)),
|
||||
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
|
||||
x_root, y_root,
|
||||
(int)start_x, (int)start_y,
|
||||
gtk_get_current_event_time ());
|
||||
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
@ -2052,9 +2033,6 @@ gtk_window_set_property (GObject *object,
|
||||
case PROP_DELETABLE:
|
||||
gtk_window_set_deletable (window, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_GRAVITY:
|
||||
gtk_window_set_gravity (window, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_TRANSIENT_FOR:
|
||||
gtk_window_set_transient_for (window, g_value_get_object (value));
|
||||
break;
|
||||
@ -2167,9 +2145,6 @@ gtk_window_get_property (GObject *object,
|
||||
case PROP_DELETABLE:
|
||||
g_value_set_boolean (value, gtk_window_get_deletable (window));
|
||||
break;
|
||||
case PROP_GRAVITY:
|
||||
g_value_set_enum (value, gtk_window_get_gravity (window));
|
||||
break;
|
||||
case PROP_TRANSIENT_FOR:
|
||||
g_value_set_object (value, gtk_window_get_transient_for (window));
|
||||
break;
|
||||
@ -4964,362 +4939,6 @@ gtk_window_get_size (GtkWindow *window,
|
||||
*height = h;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_translate_csd_pos (GtkWindow *window,
|
||||
gint *root_x,
|
||||
gint *root_y,
|
||||
gint apply)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
if (priv->type != GTK_WINDOW_TOPLEVEL)
|
||||
return;
|
||||
|
||||
if (priv->decorated &&
|
||||
!priv->fullscreen)
|
||||
{
|
||||
GtkBorder window_border = { 0 };
|
||||
gint title_height = 0;
|
||||
gint dx;
|
||||
gint dy;
|
||||
|
||||
get_shadow_width (window, &window_border);
|
||||
if (priv->title_box != NULL &&
|
||||
gtk_widget_get_visible (priv->title_box) &&
|
||||
gtk_widget_get_child_visible (priv->title_box))
|
||||
{
|
||||
gint minimum_height;
|
||||
|
||||
gtk_widget_measure (priv->title_box, GTK_ORIENTATION_VERTICAL, -1,
|
||||
&minimum_height, &title_height,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
switch (priv->gravity)
|
||||
{
|
||||
case GDK_GRAVITY_NORTH:
|
||||
case GDK_GRAVITY_CENTER:
|
||||
case GDK_GRAVITY_SOUTH:
|
||||
dx = (window_border.left + window_border.right) / 2;
|
||||
break;
|
||||
|
||||
case GDK_GRAVITY_NORTH_WEST:
|
||||
case GDK_GRAVITY_WEST:
|
||||
case GDK_GRAVITY_SOUTH_WEST:
|
||||
case GDK_GRAVITY_SOUTH_EAST:
|
||||
case GDK_GRAVITY_EAST:
|
||||
case GDK_GRAVITY_NORTH_EAST:
|
||||
dx = window_border.left;
|
||||
break;
|
||||
|
||||
default:
|
||||
dx = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (priv->gravity)
|
||||
{
|
||||
case GDK_GRAVITY_WEST:
|
||||
case GDK_GRAVITY_CENTER:
|
||||
case GDK_GRAVITY_EAST:
|
||||
dy = (window_border.top + title_height + window_border.bottom) / 2;
|
||||
break;
|
||||
|
||||
case GDK_GRAVITY_NORTH_WEST:
|
||||
case GDK_GRAVITY_NORTH:
|
||||
case GDK_GRAVITY_NORTH_EAST:
|
||||
dy = window_border.top;
|
||||
break;
|
||||
|
||||
case GDK_GRAVITY_SOUTH_WEST:
|
||||
case GDK_GRAVITY_SOUTH:
|
||||
case GDK_GRAVITY_SOUTH_EAST:
|
||||
dy = window_border.top + title_height;
|
||||
break;
|
||||
|
||||
default:
|
||||
dy = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (root_x)
|
||||
*root_x = *root_x + (dx * apply);
|
||||
if (root_y)
|
||||
*root_y = *root_y + (dy * apply);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_move:
|
||||
* @window: a #GtkWindow
|
||||
* @x: X coordinate to move window to
|
||||
* @y: Y coordinate to move window to
|
||||
*
|
||||
* Asks the [window manager][gtk-X11-arch] to move
|
||||
* @window to the given position. Window managers are free to ignore
|
||||
* this; most window managers ignore requests for initial window
|
||||
* positions (instead using a user-defined placement algorithm) and
|
||||
* honor requests after the window has already been shown.
|
||||
*
|
||||
* Note: the position is the position of the gravity-determined
|
||||
* reference point for the window. The gravity determines two things:
|
||||
* first, the location of the reference point in root window
|
||||
* coordinates; and second, which point on the window is positioned at
|
||||
* the reference point.
|
||||
*
|
||||
* By default the gravity is #GDK_GRAVITY_NORTH_WEST, so the reference
|
||||
* point is simply the @x, @y supplied to gtk_window_move(). The
|
||||
* top-left corner of the window decorations (aka window frame or
|
||||
* border) will be placed at @x, @y. Therefore, to position a window
|
||||
* at the top left of the screen, you want to use the default gravity
|
||||
* (which is #GDK_GRAVITY_NORTH_WEST) and move the window to 0,0.
|
||||
*
|
||||
* To position a window at the bottom right corner of the screen, you
|
||||
* would set #GDK_GRAVITY_SOUTH_EAST, which means that the reference
|
||||
* point is at @x + the window width and @y + the window height, and
|
||||
* the bottom-right corner of the window border will be placed at that
|
||||
* reference point. So, to place a window in the bottom right corner
|
||||
* you would first set gravity to south east, then write:
|
||||
* `gtk_window_move (window, gdk_screen_width () - window_width,
|
||||
* gdk_screen_height () - window_height)` (note that this
|
||||
* example does not take multi-head scenarios into account).
|
||||
*
|
||||
* The [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec)
|
||||
* has a nice table of gravities in the “implementation notes” section.
|
||||
*
|
||||
* The gtk_window_get_position() documentation may also be relevant.
|
||||
*/
|
||||
void
|
||||
gtk_window_move (GtkWindow *window,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GtkWindowGeometryInfo *info;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
widget = GTK_WIDGET (window);
|
||||
|
||||
info = gtk_window_get_geometry_info (window, TRUE);
|
||||
gtk_window_translate_csd_pos (window, &x, &y, EXCLUDE_CSD_SIZE);
|
||||
|
||||
if (_gtk_widget_get_mapped (widget))
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
/* we have now sent a request with this position
|
||||
* with currently-active constraints, so toggle flag.
|
||||
*/
|
||||
info->position_constraints_changed = FALSE;
|
||||
|
||||
/* we only constrain if mapped - if not mapped,
|
||||
* then gtk_window_compute_configure_request()
|
||||
* will apply the constraints later, and we
|
||||
* don't want to lose information about
|
||||
* what position the user set before then.
|
||||
* i.e. if you do a move() then turn off POS_CENTER
|
||||
* then show the window, your move() will work.
|
||||
*/
|
||||
gtk_window_constrain_position (window,
|
||||
allocation.width, allocation.height,
|
||||
&x, &y);
|
||||
|
||||
/* Note that this request doesn't go through our standard request
|
||||
* framework, e.g. doesn't increment configure_request_count,
|
||||
* doesn't set info->last, etc.; that's because
|
||||
* we don't save the info needed to arrive at this same request
|
||||
* again.
|
||||
*
|
||||
* To gtk_window_move_resize(), this will end up looking exactly
|
||||
* the same as the position being changed by the window
|
||||
* manager.
|
||||
*/
|
||||
gdk_surface_move (_gtk_widget_get_surface (GTK_WIDGET (window)), x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Save this position to apply on mapping */
|
||||
gtk_widget_queue_resize (widget);
|
||||
info->initial_x = x;
|
||||
info->initial_y = y;
|
||||
info->initial_pos_set = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_get_position:
|
||||
* @window: a #GtkWindow
|
||||
* @root_x: (out) (optional): return location for X coordinate of
|
||||
* gravity-determined reference point, or %NULL
|
||||
* @root_y: (out) (optional): return location for Y coordinate of
|
||||
* gravity-determined reference point, or %NULL
|
||||
*
|
||||
* This function returns the position you need to pass to
|
||||
* gtk_window_move() to keep @window in its current position.
|
||||
* This means that the meaning of the returned value varies with
|
||||
* window gravity. See gtk_window_move() for more details.
|
||||
*
|
||||
* The reliability of this function depends on the windowing system
|
||||
* currently in use. Some windowing systems, such as Wayland, do not
|
||||
* support a global coordinate system, and thus the position of the
|
||||
* window will always be (0, 0). Others, like X11, do not have a reliable
|
||||
* way to obtain the geometry of the decorations of a window if they are
|
||||
* provided by the window manager. Additionally, on X11, window manager
|
||||
* have been known to mismanage window gravity, which result in windows
|
||||
* moving even if you use the coordinates of the current position as
|
||||
* returned by this function.
|
||||
*
|
||||
* If you haven’t changed the window gravity, its gravity will be
|
||||
* #GDK_GRAVITY_NORTH_WEST. This means that gtk_window_get_position()
|
||||
* gets the position of the top-left corner of the window manager
|
||||
* frame for the window. gtk_window_move() sets the position of this
|
||||
* same top-left corner.
|
||||
*
|
||||
* If a window has gravity #GDK_GRAVITY_STATIC the window manager
|
||||
* frame is not relevant, and thus gtk_window_get_position() will
|
||||
* always produce accurate results. However you can’t use static
|
||||
* gravity to do things like place a window in a corner of the screen,
|
||||
* because static gravity ignores the window manager decorations.
|
||||
*
|
||||
* Ideally, this function should return appropriate values if the
|
||||
* window has client side decorations, assuming that the windowing
|
||||
* system supports global coordinates.
|
||||
*
|
||||
* In practice, saving the window position should not be left to
|
||||
* applications, as they lack enough knowledge of the windowing
|
||||
* system and the window manager state to effectively do so. The
|
||||
* appropriate way to implement saving the window position is to
|
||||
* use a platform-specific protocol, wherever that is available.
|
||||
*/
|
||||
void
|
||||
gtk_window_get_position (GtkWindow *window,
|
||||
gint *root_x,
|
||||
gint *root_y)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
GtkWidget *widget;
|
||||
GdkSurface *surface;
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
widget = GTK_WIDGET (window);
|
||||
surface = _gtk_widget_get_surface (widget);
|
||||
|
||||
if (priv->gravity == GDK_GRAVITY_STATIC)
|
||||
{
|
||||
if (_gtk_widget_get_mapped (widget))
|
||||
{
|
||||
/* This does a server round-trip, which is sort of wrong;
|
||||
* but a server round-trip is inevitable for
|
||||
* gdk_surface_get_frame_extents() in the usual
|
||||
* NorthWestGravity case below, so not sure what else to
|
||||
* do. We should likely be consistent about whether we get
|
||||
* the client-side info or the server-side info.
|
||||
*/
|
||||
gdk_surface_get_origin (surface, root_x, root_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRectangle configure_request;
|
||||
|
||||
gtk_window_compute_configure_request (window,
|
||||
&configure_request,
|
||||
NULL, NULL);
|
||||
|
||||
*root_x = configure_request.x;
|
||||
*root_y = configure_request.y;
|
||||
}
|
||||
gtk_window_translate_csd_pos (window, root_x, root_y, INCLUDE_CSD_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRectangle frame_extents;
|
||||
|
||||
gint x, y;
|
||||
gint w, h;
|
||||
|
||||
if (_gtk_widget_get_mapped (widget))
|
||||
{
|
||||
gdk_surface_get_frame_extents (surface, &frame_extents);
|
||||
x = frame_extents.x;
|
||||
y = frame_extents.y;
|
||||
gtk_window_get_size (window, &w, &h);
|
||||
/* gtk_window_get_size() will have already taken into account
|
||||
* the padding added by the CSD shadow and title bar, so we need
|
||||
* to revert it here, otherwise we'll end up counting it twice...
|
||||
*/
|
||||
gtk_window_update_csd_size (window, &w, &h, INCLUDE_CSD_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We just say the frame has 0 size on all sides.
|
||||
* Not sure what else to do.
|
||||
*/
|
||||
gtk_window_compute_configure_request (window,
|
||||
&frame_extents,
|
||||
NULL, NULL);
|
||||
x = frame_extents.x;
|
||||
y = frame_extents.y;
|
||||
w = frame_extents.width;
|
||||
h = frame_extents.height;
|
||||
}
|
||||
|
||||
gtk_window_translate_csd_pos (window, &x, &y, INCLUDE_CSD_SIZE);
|
||||
switch (priv->gravity)
|
||||
{
|
||||
case GDK_GRAVITY_NORTH:
|
||||
case GDK_GRAVITY_CENTER:
|
||||
case GDK_GRAVITY_SOUTH:
|
||||
/* Find center of frame. */
|
||||
x += frame_extents.width / 2;
|
||||
/* Center client window on that point. */
|
||||
x -= w / 2;
|
||||
break;
|
||||
|
||||
case GDK_GRAVITY_SOUTH_EAST:
|
||||
case GDK_GRAVITY_EAST:
|
||||
case GDK_GRAVITY_NORTH_EAST:
|
||||
/* Find right edge of frame */
|
||||
x += frame_extents.width;
|
||||
/* Align left edge of client at that point. */
|
||||
x -= w;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (priv->gravity)
|
||||
{
|
||||
case GDK_GRAVITY_WEST:
|
||||
case GDK_GRAVITY_CENTER:
|
||||
case GDK_GRAVITY_EAST:
|
||||
/* Find center of frame. */
|
||||
y += frame_extents.height / 2;
|
||||
/* Center client window there. */
|
||||
y -= h / 2;
|
||||
break;
|
||||
case GDK_GRAVITY_SOUTH_WEST:
|
||||
case GDK_GRAVITY_SOUTH:
|
||||
case GDK_GRAVITY_SOUTH_EAST:
|
||||
/* Find south edge of frame */
|
||||
y += frame_extents.height;
|
||||
/* Place bottom edge of client there */
|
||||
y -= h;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (root_x)
|
||||
*root_x = x;
|
||||
if (root_y)
|
||||
*root_y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_destroy (GtkWidget *widget)
|
||||
{
|
||||
@ -7642,13 +7261,13 @@ static GdkMonitor *
|
||||
get_monitor_containing_pointer (GtkWindow *window)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
gint px, py;
|
||||
double px, py;
|
||||
GdkDevice *pointer;
|
||||
|
||||
pointer = gdk_seat_get_pointer (gdk_display_get_default_seat (priv->display));
|
||||
gdk_device_get_position (pointer, &px, &py);
|
||||
|
||||
return gdk_display_get_monitor_at_point (priv->display, px, py);
|
||||
return gdk_display_get_monitor_at_point (priv->display, round (px), round (py));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -7809,15 +7428,15 @@ gtk_window_compute_configure_request (GtkWindow *window,
|
||||
GdkRectangle area;
|
||||
GdkDevice *pointer;
|
||||
GdkMonitor *monitor;
|
||||
gint px, py;
|
||||
double px, py;
|
||||
|
||||
pointer = gdk_seat_get_pointer (gdk_display_get_default_seat (priv->display));
|
||||
|
||||
gdk_device_get_position (pointer, &px, &py);
|
||||
monitor = gdk_display_get_monitor_at_point (priv->display, px, py);
|
||||
monitor = gdk_display_get_monitor_at_point (priv->display, round (px), round (py));
|
||||
|
||||
x = px - w / 2;
|
||||
y = py - h / 2;
|
||||
x = round (px) - w / 2;
|
||||
y = round (py) - h / 2;
|
||||
|
||||
/* Clamp onto current monitor, ignoring _NET_WM_STRUT and
|
||||
* WM decorations.
|
||||
@ -9070,80 +8689,25 @@ gtk_window_get_resizable (GtkWindow *window)
|
||||
return priv->resizable;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_set_gravity:
|
||||
* @window: a #GtkWindow
|
||||
* @gravity: window gravity
|
||||
*
|
||||
* Window gravity defines the meaning of coordinates passed to
|
||||
* gtk_window_move(). See gtk_window_move() and #GdkGravity for
|
||||
* more details.
|
||||
*
|
||||
* The default window gravity is #GDK_GRAVITY_NORTH_WEST which will
|
||||
* typically “do what you mean.”
|
||||
*
|
||||
**/
|
||||
void
|
||||
gtk_window_set_gravity (GtkWindow *window,
|
||||
GdkGravity gravity)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
if (gravity != priv->gravity)
|
||||
{
|
||||
priv->gravity = gravity;
|
||||
|
||||
/* gtk_window_move_resize() will adapt gravity
|
||||
*/
|
||||
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (window));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_GRAVITY]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_get_gravity:
|
||||
* @window: a #GtkWindow
|
||||
*
|
||||
* Gets the value set by gtk_window_set_gravity().
|
||||
*
|
||||
* Returns: (transfer none): window gravity
|
||||
**/
|
||||
GdkGravity
|
||||
gtk_window_get_gravity (GtkWindow *window)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
|
||||
|
||||
return priv->gravity;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_begin_resize_drag:
|
||||
* @window: a #GtkWindow
|
||||
* @button: mouse button that initiated the drag
|
||||
* @edge: position of the resize control
|
||||
* @root_x: X position where the user clicked to initiate the drag, in root window coordinates
|
||||
* @root_y: Y position where the user clicked to initiate the drag
|
||||
* @x: X position where the user clicked to initiate the drag, in window coordinates
|
||||
* @y: Y position where the user clicked to initiate the drag
|
||||
* @timestamp: timestamp from the click event that initiated the drag
|
||||
*
|
||||
* Starts resizing a window. This function is used if an application
|
||||
* has window resizing controls. When GDK can support it, the resize
|
||||
* will be done using the standard mechanism for the
|
||||
* [window manager][gtk-X11-arch] or windowing
|
||||
* system. Otherwise, GDK will try to emulate window resizing,
|
||||
* potentially not all that well, depending on the windowing system.
|
||||
* has window resizing controls.
|
||||
*/
|
||||
void
|
||||
gtk_window_begin_resize_drag (GtkWindow *window,
|
||||
GdkSurfaceEdge edge,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
gtk_window_begin_resize_drag (GtkWindow *window,
|
||||
GdkSurfaceEdge edge,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkSurface *toplevel;
|
||||
@ -9154,33 +8718,26 @@ gtk_window_begin_resize_drag (GtkWindow *window,
|
||||
|
||||
toplevel = _gtk_widget_get_surface (widget);
|
||||
|
||||
gdk_surface_begin_resize_drag (toplevel,
|
||||
edge, button,
|
||||
root_x, root_y,
|
||||
timestamp);
|
||||
gdk_surface_begin_resize_drag (toplevel, edge, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_begin_move_drag:
|
||||
* @window: a #GtkWindow
|
||||
* @button: mouse button that initiated the drag
|
||||
* @root_x: X position where the user clicked to initiate the drag, in root window coordinates
|
||||
* @root_y: Y position where the user clicked to initiate the drag
|
||||
* @x: X position where the user clicked to initiate the drag, in window coordinates
|
||||
* @y: Y position where the user clicked to initiate the drag
|
||||
* @timestamp: timestamp from the click event that initiated the drag
|
||||
*
|
||||
* Starts moving a window. This function is used if an application has
|
||||
* window movement grips. When GDK can support it, the window movement
|
||||
* will be done using the standard mechanism for the
|
||||
* [window manager][gtk-X11-arch] or windowing
|
||||
* system. Otherwise, GDK will try to emulate window movement,
|
||||
* potentially not all that well, depending on the windowing system.
|
||||
* window movement grips.
|
||||
*/
|
||||
void
|
||||
gtk_window_begin_move_drag (GtkWindow *window,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
guint32 timestamp)
|
||||
gtk_window_begin_move_drag (GtkWindow *window,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkSurface *toplevel;
|
||||
@ -9191,10 +8748,7 @@ gtk_window_begin_move_drag (GtkWindow *window,
|
||||
|
||||
toplevel = _gtk_widget_get_surface (widget);
|
||||
|
||||
gdk_surface_begin_move_drag (toplevel,
|
||||
button,
|
||||
root_x, root_y,
|
||||
timestamp);
|
||||
gdk_surface_begin_move_drag (toplevel, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,12 +244,6 @@ void gtk_window_set_resizable (GtkWindow *window,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_window_get_resizable (GtkWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_gravity (GtkWindow *window,
|
||||
GdkGravity gravity);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkGravity gtk_window_get_gravity (GtkWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_display (GtkWindow *window,
|
||||
GdkDisplay *display);
|
||||
@ -355,14 +349,14 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_begin_resize_drag (GtkWindow *window,
|
||||
GdkSurfaceEdge edge,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_begin_move_drag (GtkWindow *window,
|
||||
gint button,
|
||||
gint root_x,
|
||||
gint root_y,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
|
||||
/* Set initial default size of the window (does not constrain user
|
||||
@ -384,14 +378,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_get_size (GtkWindow *window,
|
||||
gint *width,
|
||||
gint *height);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_move (GtkWindow *window,
|
||||
gint x,
|
||||
gint y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_get_position (GtkWindow *window,
|
||||
gint *root_x,
|
||||
gint *root_y);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWindowGroup *gtk_window_get_group (GtkWindow *window);
|
||||
|
@ -52,8 +52,8 @@ find_widget_at_pointer (GdkDevice *device)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
gdk_surface_get_device_position_double (gtk_widget_get_surface (widget),
|
||||
device, &x, &y, NULL);
|
||||
gdk_surface_get_device_position (gtk_widget_get_surface (widget),
|
||||
device, &x, &y, NULL);
|
||||
|
||||
widget = gtk_widget_pick (widget, x, y);
|
||||
}
|
||||
|
@ -189,9 +189,6 @@ main(int argc, char **argv)
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
frame_stats_ensure (GTK_WINDOW (window));
|
||||
|
||||
gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), on_draw, NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), da);
|
||||
@ -207,10 +204,6 @@ main(int argc, char **argv)
|
||||
monitor = gdk_display_get_primary_monitor (display);
|
||||
gdk_monitor_get_geometry (monitor, &monitor_bounds);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window),
|
||||
monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
|
||||
monitor_bounds.y + (monitor_bounds.height - window_height) / 2);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
gtk_main ();
|
||||
|
@ -89,7 +89,6 @@ gtk_tests = [
|
||||
['testtreesort'],
|
||||
['testverticalcells'],
|
||||
['treestoretest'],
|
||||
['testxinerama'],
|
||||
['testgrouping'],
|
||||
['testtooltips'],
|
||||
['testexpand'],
|
||||
@ -130,6 +129,7 @@ gtk_tests = [
|
||||
['testoutsetshadowdrawing'],
|
||||
['testblur'],
|
||||
['testtexture'],
|
||||
['testwindowdrag'],
|
||||
]
|
||||
|
||||
if os_unix
|
||||
|
@ -5253,14 +5253,8 @@ size_allocate_callback (GtkWidget *widget,
|
||||
{
|
||||
GtkWidget *label = data;
|
||||
gchar *msg;
|
||||
gint x, y;
|
||||
|
||||
gtk_window_get_position (GTK_WINDOW (widget), &x, &y);
|
||||
|
||||
msg = g_strdup_printf ("size: %d x %d\n"
|
||||
"position: %d, %d",
|
||||
allocation->width, allocation->height,
|
||||
x, y);
|
||||
msg = g_strdup_printf ("size: %d x %d\n", allocation->width, allocation->height);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (label), msg);
|
||||
|
||||
@ -5333,31 +5327,6 @@ set_size_request_callback (GtkWidget *widget,
|
||||
w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
set_location_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint x, y;
|
||||
|
||||
get_ints (data, &x, &y);
|
||||
|
||||
gtk_window_move (g_object_get_data (data, "target"), x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
move_to_position_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint x, y;
|
||||
GtkWindow *window;
|
||||
|
||||
window = g_object_get_data (data, "target");
|
||||
|
||||
gtk_window_get_position (window, &x, &y);
|
||||
|
||||
gtk_window_move (window, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
resizable_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
@ -5367,14 +5336,6 @@ resizable_callback (GtkWidget *widget,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gravity_selected (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_window_set_gravity (GTK_WINDOW (g_object_get_data (data, "target")),
|
||||
gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) + GDK_GRAVITY_NORTH_WEST);
|
||||
}
|
||||
|
||||
static void
|
||||
pos_selected (GtkWidget *widget,
|
||||
gpointer data)
|
||||
@ -5478,20 +5439,6 @@ window_controls (GtkWidget *window)
|
||||
control_window);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Move");
|
||||
g_signal_connect (button,
|
||||
"clicked",
|
||||
G_CALLBACK (set_location_callback),
|
||||
control_window);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Move to current position");
|
||||
g_signal_connect (button,
|
||||
"clicked",
|
||||
G_CALLBACK (move_to_position_callback),
|
||||
control_window);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
button = gtk_check_button_new_with_label ("Allow resize");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
g_signal_connect (button,
|
||||
@ -5545,37 +5492,6 @@ window_controls (GtkWidget *window)
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), om);
|
||||
|
||||
om = gtk_combo_box_text_new ();
|
||||
i = 0;
|
||||
while (i < 10)
|
||||
{
|
||||
static gchar *names[] = {
|
||||
"GDK_GRAVITY_NORTH_WEST",
|
||||
"GDK_GRAVITY_NORTH",
|
||||
"GDK_GRAVITY_NORTH_EAST",
|
||||
"GDK_GRAVITY_WEST",
|
||||
"GDK_GRAVITY_CENTER",
|
||||
"GDK_GRAVITY_EAST",
|
||||
"GDK_GRAVITY_SOUTH_WEST",
|
||||
"GDK_GRAVITY_SOUTH",
|
||||
"GDK_GRAVITY_SOUTH_EAST",
|
||||
"GDK_GRAVITY_STATIC",
|
||||
NULL
|
||||
};
|
||||
|
||||
g_assert (names[i]);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (om), names[i]);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
g_signal_connect (om,
|
||||
"changed",
|
||||
G_CALLBACK (gravity_selected),
|
||||
control_window);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), om);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
return control_window;
|
||||
@ -6613,7 +6529,6 @@ create_main_window (void)
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_name (window, "main_window");
|
||||
gtk_window_move (GTK_WINDOW (window), 50, 20);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
|
||||
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
@ -79,7 +79,6 @@ window_creation_function (GtkNotebook *source_notebook,
|
||||
gtk_container_add (GTK_CONTAINER (window), notebook);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
return GTK_NOTEBOOK (notebook);
|
||||
|
@ -17,16 +17,6 @@ place_popup (GtkEventControllerMotion *motion,
|
||||
gdouble y,
|
||||
GtkWidget *popup)
|
||||
{
|
||||
gint width, height, win_x, win_y;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (motion));
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
|
||||
gtk_window_get_position (GTK_WINDOW (widget), &win_x, &win_y);
|
||||
gtk_window_move (GTK_WINDOW (popup),
|
||||
(int) win_x + x - width / 2,
|
||||
(int) win_y + y - height / 2);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
140
tests/testwindowdrag.c
Normal file
140
tests/testwindowdrag.c
Normal file
@ -0,0 +1,140 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
start_resize (GtkGestureMultiPress *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
GdkSurfaceEdge edge = GPOINTER_TO_INT (data);
|
||||
GdkSurface *surface;
|
||||
GdkEvent *event;
|
||||
guint button;
|
||||
guint32 timestamp;
|
||||
int xx = x;
|
||||
int yy = y;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
surface = gtk_widget_get_surface (widget);
|
||||
event = gtk_get_current_event ();
|
||||
gdk_event_get_button (event, &button);
|
||||
timestamp = gdk_event_get_time (event);
|
||||
|
||||
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
|
||||
xx, yy, &xx, &yy);
|
||||
gdk_surface_begin_resize_drag (surface, edge, button, xx, yy, timestamp);
|
||||
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
resize_button (GdkSurfaceEdge edge)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkGesture *gesture;
|
||||
|
||||
button = gtk_image_new_from_icon_name ("view-fullscreen-symbolic");
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gesture = gtk_gesture_multi_press_new ();
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (start_resize), GINT_TO_POINTER (edge));
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static void
|
||||
start_move (GtkGestureMultiPress *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
GdkSurface *surface;
|
||||
GdkEvent *event;
|
||||
guint button;
|
||||
guint32 timestamp;
|
||||
int xx = x;
|
||||
int yy = y;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
surface = gtk_widget_get_surface (widget);
|
||||
event = gtk_get_current_event ();
|
||||
gdk_event_get_button (event, &button);
|
||||
timestamp = gdk_event_get_time (event);
|
||||
|
||||
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
|
||||
xx, yy, &xx, &yy);
|
||||
gdk_surface_begin_move_drag (surface, button, xx, yy, timestamp);
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
move_button (void)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkGesture *gesture;
|
||||
|
||||
button = gtk_image_new_from_icon_name ("view-grid-symbolic");
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gesture = gtk_gesture_multi_press_new ();
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (start_move), NULL);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *grid;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), gtk_header_bar_new ());
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), grid);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_NORTH_WEST),
|
||||
0, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_NORTH),
|
||||
1, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_NORTH_EAST),
|
||||
2, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_WEST),
|
||||
0, 1, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
move_button (),
|
||||
1, 1, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_EAST),
|
||||
2, 1, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_SOUTH_WEST),
|
||||
0, 2, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_SOUTH),
|
||||
1, 2, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid),
|
||||
resize_button (GDK_SURFACE_EDGE_SOUTH_EAST),
|
||||
2, 2, 1, 1);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/* testmultidisplay.c
|
||||
* Copyright (C) 2001 Sun Microsystems Inc.
|
||||
* Author: Erwann Chenede <erwann.chenede@sun.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
label_set_text_for_monitor (GtkLabel *label,
|
||||
GdkMonitor *monitor)
|
||||
{
|
||||
GdkRectangle monitor_geom;
|
||||
gchar *str;
|
||||
|
||||
gdk_monitor_get_geometry (monitor, &monitor_geom);
|
||||
|
||||
str = g_strdup_printf ("<big><span foreground='white' background='black'>"
|
||||
"%s %s</span></big>\n"
|
||||
"<i>Width - Height </i>: (%d,%d)\n"
|
||||
"<i>Top left coordinate </i>: (%d,%d)\n"
|
||||
"<i>Primary monitor</i>: %s",
|
||||
gdk_monitor_get_manufacturer (monitor),
|
||||
gdk_monitor_get_model (monitor),
|
||||
monitor_geom.width, monitor_geom.height,
|
||||
monitor_geom.x, monitor_geom.y,
|
||||
gdk_monitor_is_primary (monitor) ? "YES" : "no");
|
||||
gtk_label_set_markup (label, str);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
request (GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkDisplay *display = gtk_widget_get_display (widget);
|
||||
GdkMonitor *monitor = gdk_display_get_monitor_at_surface (display,
|
||||
gtk_widget_get_surface (widget));
|
||||
|
||||
if (monitor == NULL)
|
||||
gtk_label_set_markup (GTK_LABEL (user_data),
|
||||
"<big><span foreground='white' background='black'>Not on a monitor </span></big>");
|
||||
else
|
||||
label_set_text_for_monitor (GTK_LABEL (user_data), monitor);
|
||||
}
|
||||
|
||||
static void
|
||||
monitor_changed_cb (GdkMonitor *monitor,
|
||||
GParamSpec *pspec,
|
||||
GtkWidget *label)
|
||||
{
|
||||
request (label, label);
|
||||
}
|
||||
|
||||
static void
|
||||
monitor_added (GdkDisplay *display,
|
||||
GdkMonitor *monitor,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkWidget *window, *label, *vbox, *button;
|
||||
GdkRectangle monitor_geom;
|
||||
|
||||
gdk_monitor_get_geometry (monitor, &monitor_geom);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
|
||||
gtk_window_move (GTK_WINDOW (window), (monitor_geom.width - 200) / 2 + monitor_geom.x,
|
||||
(monitor_geom.height - 200) / 2 + monitor_geom.y);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
label_set_text_for_monitor (GTK_LABEL (label), monitor);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
button = gtk_button_new_with_label ("Query current monitor");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (request), label);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_signal_connect (monitor, "notify",
|
||||
G_CALLBACK (monitor_changed_cb), label);
|
||||
g_signal_connect_swapped (monitor, "invalidate",
|
||||
G_CALLBACK (gtk_widget_destroy), window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GdkDisplay *display;
|
||||
gint i, num_monitors;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
g_signal_connect (display, "monitor-added", G_CALLBACK (monitor_added), NULL);
|
||||
|
||||
num_monitors = gdk_display_get_n_monitors (display);
|
||||
if (num_monitors == 1)
|
||||
g_warning ("The current display only has one monitor.");
|
||||
|
||||
for (i = 0; i < num_monitors; i++)
|
||||
{
|
||||
GdkMonitor *monitor;
|
||||
|
||||
monitor = gdk_display_get_monitor (display, i);
|
||||
monitor_added (display, monitor, NULL);
|
||||
}
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -190,18 +190,13 @@ static void
|
||||
test_resize_popup (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
gint x, y, w, h;
|
||||
gint w, h;
|
||||
|
||||
/* testcase for the dnd window */
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gdk_display_get_default ());
|
||||
gtk_window_resize (GTK_WINDOW (window), 1, 1);
|
||||
gtk_window_move (GTK_WINDOW (window), -99, -99);
|
||||
|
||||
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
|
||||
g_assert_cmpint (x, ==, -99);
|
||||
g_assert_cmpint (y, ==, -99);
|
||||
g_assert_cmpint (w, ==, 1);
|
||||
g_assert_cmpint (h, ==, 1);
|
||||
|
||||
@ -210,10 +205,7 @@ test_resize_popup (void)
|
||||
g_timeout_add (200, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
|
||||
g_assert_cmpint (x, ==, -99);
|
||||
g_assert_cmpint (y, ==, -99);
|
||||
g_assert_cmpint (w, ==, 1);
|
||||
g_assert_cmpint (h, ==, 1);
|
||||
|
||||
@ -260,94 +252,6 @@ test_show_hide (void)
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_show_hide2 (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
gint x, y, w, h, w1, h1;
|
||||
|
||||
g_test_bug ("696882");
|
||||
|
||||
/* test that hide/show does not affect the size,
|
||||
* even when get_position/move is called
|
||||
*/
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
|
||||
gtk_widget_hide (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
|
||||
g_assert_cmpint (w, ==, w1);
|
||||
g_assert_cmpint (h, ==, h1);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
|
||||
g_assert_cmpint (w, ==, w1);
|
||||
g_assert_cmpint (h, ==, h1);
|
||||
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_show_hide3 (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
gint x, y, w, h, w1, h1;
|
||||
|
||||
g_test_bug ("696882");
|
||||
|
||||
/* test that hide/show does not affect the size,
|
||||
* even when get_position/move is called and
|
||||
* a default size is set
|
||||
*/
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
|
||||
gtk_widget_hide (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
|
||||
g_assert_cmpint (w, ==, w1);
|
||||
g_assert_cmpint (h, ==, h1);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_timeout_add (100, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
|
||||
g_assert_cmpint (w, ==, w1);
|
||||
g_assert_cmpint (h, ==, h1);
|
||||
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -366,8 +270,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/window/resize", test_resize);
|
||||
g_test_add_func ("/window/resize-popup", test_resize_popup);
|
||||
g_test_add_func ("/window/show-hide", test_show_hide);
|
||||
g_test_add_func ("/window/show-hide2", test_show_hide2);
|
||||
g_test_add_func ("/window/show-hide3", test_show_hide3);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user