2008-07-01 22:57:50 +00:00
|
|
|
|
/* GDK - The GIMP Drawing Kit
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball,
|
|
|
|
|
* Josh MacDonald, Ryan Lortie
|
|
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
1998-03-17 07:54:57 +00:00
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
2010-05-14 15:23:33 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2010-10-14 11:25:23 +00:00
|
|
|
|
#include <cairo-gobject.h>
|
|
|
|
|
|
2018-03-20 10:46:11 +00:00
|
|
|
|
#include "gdksurface.h"
|
2010-05-14 15:23:33 +00:00
|
|
|
|
|
2022-09-24 03:23:27 +00:00
|
|
|
|
#include "gdkprivate.h"
|
2021-09-24 19:11:00 +00:00
|
|
|
|
#include "gdkcontentprovider.h"
|
2020-02-29 14:34:11 +00:00
|
|
|
|
#include "gdkdeviceprivate.h"
|
|
|
|
|
#include "gdkdisplayprivate.h"
|
2020-03-03 23:55:45 +00:00
|
|
|
|
#include "gdkdragsurfaceprivate.h"
|
2019-06-13 19:37:16 +00:00
|
|
|
|
#include "gdkeventsprivate.h"
|
2020-02-29 14:34:11 +00:00
|
|
|
|
#include "gdkframeclockidleprivate.h"
|
|
|
|
|
#include "gdkglcontextprivate.h"
|
2022-09-24 03:33:42 +00:00
|
|
|
|
#include <glib/gi18n-lib.h>
|
2010-05-14 15:23:33 +00:00
|
|
|
|
#include "gdkmarshalers.h"
|
2020-02-29 14:34:11 +00:00
|
|
|
|
#include "gdkpopupprivate.h"
|
|
|
|
|
#include "gdkrectangle.h"
|
2020-02-29 15:07:43 +00:00
|
|
|
|
#include "gdktoplevelprivate.h"
|
2021-09-24 19:11:00 +00:00
|
|
|
|
#include "gdkvulkancontext.h"
|
2010-05-14 15:23:33 +00:00
|
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2021-10-03 19:58:57 +00:00
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
|
#include <epoxy/egl.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-05-13 02:51:37 +00:00
|
|
|
|
/**
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* GdkSurface:
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* A `GdkSurface` is a rectangular region on the screen.
|
2020-10-29 17:57:22 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* It’s a low-level object, used to implement high-level objects
|
|
|
|
|
* such as [class@Gtk.Window] or [class@Gtk.Dialog] in GTK.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-11-07 18:22:10 +00:00
|
|
|
|
* The surfaces you see in practice are either [iface@Gdk.Toplevel] or
|
|
|
|
|
* [iface@Gdk.Popup], and those interfaces provide much of the required
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* API to interact with these surfaces. Other, more specialized surface
|
|
|
|
|
* types exist, but you will rarely interact with them directly.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*/
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2021-10-03 06:20:30 +00:00
|
|
|
|
typedef struct _GdkSurfacePrivate GdkSurfacePrivate;
|
|
|
|
|
|
|
|
|
|
struct _GdkSurfacePrivate
|
|
|
|
|
{
|
2021-10-03 19:58:57 +00:00
|
|
|
|
gpointer egl_native_window;
|
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
|
EGLSurface egl_surface;
|
2021-10-06 16:25:30 +00:00
|
|
|
|
gboolean egl_surface_high_depth;
|
2021-10-03 19:58:57 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2021-10-03 06:20:30 +00:00
|
|
|
|
gpointer widget;
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-04 18:15:29 +00:00
|
|
|
|
enum {
|
2020-11-24 17:33:05 +00:00
|
|
|
|
LAYOUT,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
RENDER,
|
|
|
|
|
EVENT,
|
2017-11-29 03:36:17 +00:00
|
|
|
|
ENTER_MONITOR,
|
|
|
|
|
LEAVE_MONITOR,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
LAST_SIGNAL
|
2009-06-04 18:15:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-07-16 06:16:01 +00:00
|
|
|
|
enum {
|
2019-04-06 16:36:51 +00:00
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_CURSOR,
|
|
|
|
|
PROP_DISPLAY,
|
2019-04-22 01:14:28 +00:00
|
|
|
|
PROP_FRAME_CLOCK,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
PROP_MAPPED,
|
2020-08-08 03:38:28 +00:00
|
|
|
|
PROP_WIDTH,
|
|
|
|
|
PROP_HEIGHT,
|
2021-01-16 20:16:36 +00:00
|
|
|
|
PROP_SCALE_FACTOR,
|
2023-04-01 18:51:11 +00:00
|
|
|
|
PROP_SCALE,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
LAST_PROP
|
2009-07-16 06:16:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
/* Global info */
|
Bug 318807 – Offscreen windows and window redirection.
2008-03-18 10:49:20 Tim Janik <timj@imendio.com>
* Applied pixmap redirection patch by Alexander Larsson with
various updates from:
Bug 318807 – Offscreen windows and window redirection.
Updates:
* updated docs to mention "Since 2.16".
* tests/testgtk.c: fixed snapshooting pixmap leak.
convert pixmap to pixbuf after snapshooting, to compensate for different
bit depths (occurs when snapshooting ARGB visuals and displaying the
pixmap in an RGB visual).
* gdk/gdkwindow.[hc]: made GdkWindowRedirect private.
* gdk/gdkwindow.c: removed damage idle handler, there's no aparent
need for it. enqueue damage notification as GDK_DAMAGE events
for each painting redirection at the start of the event queue.
consider windows with a redirection fully visible when invalidating,
and when updating from backing store. cleaned up stale variables.
* gdk/gdkevents.c: added _gdk_event_queue_prepend().
* gtk/gtkwidget.c: fixed coordinates for !NO_WINDOW widgets in
gtk_widget_get_snapshot; this fixes garbage snap offsets for gammacurve,
tree, drawingarea, text, handlebox, etc.
clip the redirected window hierarchy to window sizes, the visible
rectangles don't need to be taken into account here.
extended snapshooting docs to recommend gdk_pixbuf_get_from_drawable()
in case pixmap visuals could mismatch.
* gdk/x11/gdkwindow-x11.c: removed _gdk_windowing_window_get_visible_rect().
Base patch:
* tests/testgtk.c: add a "Snapshot" test to demonstrate snapshooting
of possibly obscured widgets into an offscreen pixmap.
* gtk/gtkwidget.[hc]: add GtkWidget::damage-event signal, add
gtk_widget_get_snapshot() to render a widget's contents to a GdkPixmap.
* gtk/gtkmain.c: dispatch GDK_DAMAGE events.
* gdk/gdkwindow.c: moved outer gdk_window_new() and gdk_window_reparent()
implementations here, adapted them to propagate redirects to child windows.
gdk_window_end_paint(): copy repainted window contents to redirection pixmap,
clipped to visible region. queue GDK_DAMAGE event delivery.
gdk_window_redirect_to_drawable(): install window painting redirection.
gdk_window_remove_redirection(): remove previously installed redirection.
* gdk/x11/gdkwindow-x11.c: added _gdk_windowing_window_get_visible_rect(),
renamed _gdk_window_new() and _gdk_window_reparent().
* gdk/gdkwindow.h: added GdkWindowRedirect* to GdkWindowObject, export
gdk_window_redirect_to_drawable() and gdk_window_remove_redirection().
* gdk/gdkevents.h: added GDK_DAMAGE event type.
* gdk/gdkevents.c: extract time and state from GDK_DAMAGE events.
* gdk/gdkinternals.h: added internal prototypes.
svn path=/trunk/; revision=20122
2008-05-21 19:04:24 +00:00
|
|
|
|
|
2019-05-22 22:04:45 +00:00
|
|
|
|
static void gdk_surface_finalize (GObject *object);
|
2009-07-16 06:16:01 +00:00
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
|
static void gdk_surface_set_property (GObject *object,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2018-03-20 10:40:08 +00:00
|
|
|
|
static void gdk_surface_get_property (GObject *object,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2009-07-16 06:16:01 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
static void update_cursor (GdkDisplay *display,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDevice *device);
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
static void gdk_surface_queue_set_is_mapped (GdkSurface *surface,
|
|
|
|
|
gboolean is_mapped);
|
|
|
|
|
|
2014-10-09 08:45:44 +00:00
|
|
|
|
|
2009-06-04 18:15:29 +00:00
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
2015-09-06 19:02:34 +00:00
|
|
|
|
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
2006-05-31 03:34:04 +00:00
|
|
|
|
|
2021-10-03 06:20:30 +00:00
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkSurface, gdk_surface, G_TYPE_OBJECT)
|
1999-10-03 22:12:41 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_surface_real_beep (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkDisplay *
|
|
|
|
|
get_display_for_surface (GdkSurface *primary,
|
|
|
|
|
GdkSurface *secondary)
|
|
|
|
|
{
|
2019-06-01 21:55:14 +00:00
|
|
|
|
GdkDisplay *display = primary->display;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
|
return display;
|
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
display = secondary->display;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
|
return display;
|
|
|
|
|
|
|
|
|
|
g_warning ("no display for surface, using default");
|
|
|
|
|
return gdk_display_get_default ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkMonitor *
|
2020-07-29 13:47:48 +00:00
|
|
|
|
get_monitor_for_rect (GdkDisplay *display,
|
|
|
|
|
const GdkRectangle *rect,
|
|
|
|
|
void (*get_bounds) (GdkMonitor *monitor,
|
|
|
|
|
GdkRectangle *bounds))
|
2019-04-22 01:14:46 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int biggest_area = G_MININT;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GdkMonitor *best_monitor = NULL;
|
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
|
GdkRectangle workarea;
|
|
|
|
|
GdkRectangle intersection;
|
2020-05-17 03:58:20 +00:00
|
|
|
|
GListModel *monitors;
|
|
|
|
|
guint i;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
|
monitors = gdk_display_get_monitors (display);
|
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
2019-04-22 01:14:46 +00:00
|
|
|
|
{
|
2020-05-17 03:58:20 +00:00
|
|
|
|
monitor = g_list_model_get_item (monitors, i);
|
2020-07-29 13:47:48 +00:00
|
|
|
|
get_bounds (monitor, &workarea);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
|
|
if (gdk_rectangle_intersect (&workarea, rect, &intersection))
|
|
|
|
|
{
|
|
|
|
|
if (intersection.width * intersection.height > biggest_area)
|
|
|
|
|
{
|
|
|
|
|
biggest_area = intersection.width * intersection.height;
|
|
|
|
|
best_monitor = monitor;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-17 03:58:20 +00:00
|
|
|
|
g_object_unref (monitor);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 05:50:48 +00:00
|
|
|
|
return best_monitor;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2019-04-22 01:14:46 +00:00
|
|
|
|
get_anchor_x_sign (GdkGravity anchor)
|
|
|
|
|
{
|
|
|
|
|
switch (anchor)
|
|
|
|
|
{
|
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2019-04-22 01:14:46 +00:00
|
|
|
|
get_anchor_y_sign (GdkGravity anchor)
|
|
|
|
|
{
|
|
|
|
|
switch (anchor)
|
|
|
|
|
{
|
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
|
|
|
|
maybe_flip_position (int bounds_pos,
|
|
|
|
|
int bounds_size,
|
|
|
|
|
int rect_pos,
|
|
|
|
|
int rect_size,
|
|
|
|
|
int surface_size,
|
|
|
|
|
int rect_sign,
|
|
|
|
|
int surface_sign,
|
|
|
|
|
int offset,
|
2019-04-22 01:14:46 +00:00
|
|
|
|
gboolean flip,
|
|
|
|
|
gboolean *flipped)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int primary;
|
|
|
|
|
int secondary;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
|
|
*flipped = FALSE;
|
|
|
|
|
primary = rect_pos + (1 + rect_sign) * rect_size / 2 + offset - (1 + surface_sign) * surface_size / 2;
|
|
|
|
|
|
|
|
|
|
if (!flip || (primary >= bounds_pos && primary + surface_size <= bounds_pos + bounds_size))
|
|
|
|
|
return primary;
|
|
|
|
|
|
|
|
|
|
*flipped = TRUE;
|
|
|
|
|
secondary = rect_pos + (1 - rect_sign) * rect_size / 2 - offset - (1 - surface_sign) * surface_size / 2;
|
|
|
|
|
|
|
|
|
|
if (secondary >= bounds_pos && secondary + surface_size <= bounds_pos + bounds_size)
|
|
|
|
|
return secondary;
|
|
|
|
|
|
|
|
|
|
*flipped = FALSE;
|
|
|
|
|
return primary;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
GdkMonitor *
|
|
|
|
|
gdk_surface_get_layout_monitor (GdkSurface *surface,
|
|
|
|
|
GdkPopupLayout *layout,
|
|
|
|
|
void (*get_bounds) (GdkMonitor *monitor,
|
|
|
|
|
GdkRectangle *bounds))
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkRectangle root_rect;
|
|
|
|
|
|
|
|
|
|
root_rect = *gdk_popup_layout_get_anchor_rect (layout);
|
|
|
|
|
gdk_surface_get_root_coords (surface->parent,
|
|
|
|
|
root_rect.x,
|
|
|
|
|
root_rect.y,
|
|
|
|
|
&root_rect.x,
|
|
|
|
|
&root_rect.y);
|
|
|
|
|
|
2020-08-03 01:27:03 +00:00
|
|
|
|
root_rect.width = MAX (1, root_rect.width);
|
|
|
|
|
root_rect.height = MAX (1, root_rect.height);
|
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
display = get_display_for_surface (surface, surface->transient_for);
|
|
|
|
|
return get_monitor_for_rect (display, &root_rect, get_bounds);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-15 09:35:24 +00:00
|
|
|
|
void
|
2020-02-16 11:59:24 +00:00
|
|
|
|
gdk_surface_layout_popup_helper (GdkSurface *surface,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
2020-12-02 13:58:45 +00:00
|
|
|
|
int shadow_left,
|
|
|
|
|
int shadow_right,
|
|
|
|
|
int shadow_top,
|
|
|
|
|
int shadow_bottom,
|
2020-07-29 13:47:48 +00:00
|
|
|
|
GdkMonitor *monitor,
|
|
|
|
|
GdkRectangle *bounds,
|
2020-02-16 11:59:24 +00:00
|
|
|
|
GdkPopupLayout *layout,
|
|
|
|
|
GdkRectangle *out_final_rect)
|
|
|
|
|
{
|
|
|
|
|
GdkRectangle root_rect;
|
|
|
|
|
GdkGravity rect_anchor;
|
|
|
|
|
GdkGravity surface_anchor;
|
|
|
|
|
int rect_anchor_dx;
|
|
|
|
|
int rect_anchor_dy;
|
|
|
|
|
GdkAnchorHints anchor_hints;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GdkRectangle final_rect;
|
|
|
|
|
gboolean flipped_x;
|
|
|
|
|
gboolean flipped_y;
|
2019-05-22 23:47:59 +00:00
|
|
|
|
int x, y;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-03-09 20:00:08 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_POPUP (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
root_rect = *gdk_popup_layout_get_anchor_rect (layout);
|
|
|
|
|
gdk_surface_get_root_coords (surface->parent,
|
2019-04-22 15:17:53 +00:00
|
|
|
|
root_rect.x,
|
|
|
|
|
root_rect.y,
|
|
|
|
|
&root_rect.x,
|
|
|
|
|
&root_rect.y);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
rect_anchor = gdk_popup_layout_get_rect_anchor (layout);
|
|
|
|
|
surface_anchor = gdk_popup_layout_get_surface_anchor (layout);
|
|
|
|
|
gdk_popup_layout_get_offset (layout, &rect_anchor_dx, &rect_anchor_dy);
|
|
|
|
|
anchor_hints = gdk_popup_layout_get_anchor_hints (layout);
|
|
|
|
|
|
2020-12-02 13:58:45 +00:00
|
|
|
|
final_rect.width = width - shadow_left - shadow_right;
|
|
|
|
|
final_rect.height = height - shadow_top - shadow_bottom;
|
2020-07-29 13:47:48 +00:00
|
|
|
|
final_rect.x = maybe_flip_position (bounds->x,
|
|
|
|
|
bounds->width,
|
2020-02-16 11:59:24 +00:00
|
|
|
|
root_rect.x,
|
|
|
|
|
root_rect.width,
|
|
|
|
|
final_rect.width,
|
|
|
|
|
get_anchor_x_sign (rect_anchor),
|
|
|
|
|
get_anchor_x_sign (surface_anchor),
|
|
|
|
|
rect_anchor_dx,
|
|
|
|
|
anchor_hints & GDK_ANCHOR_FLIP_X,
|
|
|
|
|
&flipped_x);
|
2020-07-29 13:47:48 +00:00
|
|
|
|
final_rect.y = maybe_flip_position (bounds->y,
|
|
|
|
|
bounds->height,
|
2020-02-16 11:59:24 +00:00
|
|
|
|
root_rect.y,
|
|
|
|
|
root_rect.height,
|
|
|
|
|
final_rect.height,
|
|
|
|
|
get_anchor_y_sign (rect_anchor),
|
|
|
|
|
get_anchor_y_sign (surface_anchor),
|
|
|
|
|
rect_anchor_dy,
|
|
|
|
|
anchor_hints & GDK_ANCHOR_FLIP_Y,
|
|
|
|
|
&flipped_y);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_X)
|
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.x + final_rect.width > bounds->x + bounds->width)
|
|
|
|
|
final_rect.x = bounds->x + bounds->width - final_rect.width;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.x < bounds->x)
|
|
|
|
|
final_rect.x = bounds->x;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_Y)
|
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.y + final_rect.height > bounds->y + bounds->height)
|
|
|
|
|
final_rect.y = bounds->y + bounds->height - final_rect.height;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.y < bounds->y)
|
|
|
|
|
final_rect.y = bounds->y;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_X)
|
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.x < bounds->x)
|
2019-04-22 01:14:46 +00:00
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
final_rect.width -= bounds->x - final_rect.x;
|
|
|
|
|
final_rect.x = bounds->x;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.x + final_rect.width > bounds->x + bounds->width)
|
|
|
|
|
final_rect.width = bounds->x + bounds->width - final_rect.x;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_Y)
|
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.y < bounds->y)
|
2019-04-22 01:14:46 +00:00
|
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
|
final_rect.height -= bounds->y - final_rect.y;
|
|
|
|
|
final_rect.y = bounds->y;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
|
if (final_rect.y + final_rect.height > bounds->y + bounds->height)
|
|
|
|
|
final_rect.height = bounds->y + bounds->height - final_rect.y;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 13:58:45 +00:00
|
|
|
|
final_rect.x -= shadow_left;
|
|
|
|
|
final_rect.y -= shadow_top;
|
|
|
|
|
final_rect.width += shadow_left + shadow_right;
|
|
|
|
|
final_rect.height += shadow_top + shadow_bottom;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
gdk_surface_get_origin (surface->parent, &x, &y);
|
2019-05-22 23:47:59 +00:00
|
|
|
|
final_rect.x -= x;
|
|
|
|
|
final_rect.y -= y;
|
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
if (flipped_x)
|
|
|
|
|
{
|
|
|
|
|
rect_anchor = gdk_gravity_flip_horizontally (rect_anchor);
|
|
|
|
|
surface_anchor = gdk_gravity_flip_horizontally (surface_anchor);
|
|
|
|
|
}
|
|
|
|
|
if (flipped_y)
|
|
|
|
|
{
|
|
|
|
|
rect_anchor = gdk_gravity_flip_vertically (rect_anchor);
|
|
|
|
|
surface_anchor = gdk_gravity_flip_vertically (surface_anchor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surface->popup.rect_anchor = rect_anchor;
|
|
|
|
|
surface->popup.surface_anchor = surface_anchor;
|
2019-07-15 09:35:24 +00:00
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
*out_final_rect = final_rect;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-19 11:18:24 +00:00
|
|
|
|
/* Since GdkEvent is a GTypeInstance, GValue can only store it as a pointer,
|
|
|
|
|
* and GClosure does not know how to handle its memory management. To avoid
|
|
|
|
|
* the event going away in the middle of the signal emission, we provide a
|
|
|
|
|
* marshaller that keeps the event alive for the duration of the closure.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
gdk_surface_event_marshaller (GClosure *closure,
|
|
|
|
|
GValue *return_value,
|
|
|
|
|
guint n_param_values,
|
|
|
|
|
const GValue *param_values,
|
|
|
|
|
gpointer invocation_hint,
|
|
|
|
|
gpointer marshal_data)
|
|
|
|
|
{
|
|
|
|
|
GdkEvent *event = g_value_get_pointer (¶m_values[1]);
|
|
|
|
|
|
|
|
|
|
gdk_event_ref (event);
|
|
|
|
|
|
|
|
|
|
_gdk_marshal_BOOLEAN__POINTER (closure,
|
|
|
|
|
return_value,
|
|
|
|
|
n_param_values,
|
|
|
|
|
param_values,
|
|
|
|
|
invocation_hint,
|
|
|
|
|
marshal_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gdk_event_unref (event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_surface_event_marshallerv (GClosure *closure,
|
|
|
|
|
GValue *return_value,
|
|
|
|
|
gpointer instance,
|
|
|
|
|
va_list args,
|
|
|
|
|
gpointer marshal_data,
|
|
|
|
|
int n_params,
|
|
|
|
|
GType *param_types)
|
|
|
|
|
{
|
|
|
|
|
va_list args_copy;
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
|
|
G_VA_COPY (args_copy, args);
|
|
|
|
|
event = va_arg (args_copy, gpointer);
|
|
|
|
|
|
|
|
|
|
gdk_event_ref (event);
|
|
|
|
|
|
|
|
|
|
_gdk_marshal_BOOLEAN__POINTERv (closure,
|
|
|
|
|
return_value,
|
|
|
|
|
instance,
|
|
|
|
|
args,
|
|
|
|
|
marshal_data,
|
|
|
|
|
n_params,
|
|
|
|
|
param_types);
|
|
|
|
|
|
|
|
|
|
gdk_event_unref (event);
|
|
|
|
|
|
|
|
|
|
va_end (args_copy);
|
|
|
|
|
}
|
|
|
|
|
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_init (GdkSurface *surface)
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
/* 0-initialization is good for all other fields. */
|
1998-03-07 18:38:18 +00:00
|
|
|
|
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
surface->state = 0;
|
2019-04-06 16:36:51 +00:00
|
|
|
|
surface->fullscreen_mode = GDK_FULLSCREEN_ON_CURRENT_MONITOR;
|
|
|
|
|
surface->width = 1;
|
|
|
|
|
surface->height = 1;
|
2011-05-03 22:01:10 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
surface->alpha = 255;
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
surface->device_cursor = g_hash_table_new_full (NULL, NULL,
|
|
|
|
|
NULL, g_object_unref);
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
}
|
1999-01-17 22:58:59 +00:00
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
static double
|
|
|
|
|
gdk_surface_real_get_scale (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-20 21:26:49 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_surface_constructed (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
G_GNUC_UNUSED GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
|
|
g_assert (surface->frame_clock != NULL);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_surface_parent_class)->constructed (object);
|
|
|
|
|
}
|
|
|
|
|
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_class_init (GdkSurfaceClass *klass)
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2023-04-20 21:26:49 +00:00
|
|
|
|
object_class->constructed = gdk_surface_constructed;
|
2019-04-06 16:36:51 +00:00
|
|
|
|
object_class->finalize = gdk_surface_finalize;
|
|
|
|
|
object_class->set_property = gdk_surface_set_property;
|
|
|
|
|
object_class->get_property = gdk_surface_get_property;
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
klass->beep = gdk_surface_real_beep;
|
2023-04-01 18:51:11 +00:00
|
|
|
|
klass->get_scale = gdk_surface_real_get_scale;
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:cursor: (attributes org.gtk.Property.get=gdk_surface_get_cursor org.gtk.Property.set=gdk_surface_set_cursor)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The mouse pointer for the `GdkSurface`.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*/
|
|
|
|
|
properties[PROP_CURSOR] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("cursor", NULL, NULL,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GDK_TYPE_CURSOR,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:display: (attributes org.gtk.Property.get=gdk_surface_get_display)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The `GdkDisplay` connection of the surface.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*/
|
|
|
|
|
properties[PROP_DISPLAY] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("display", NULL, NULL,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GDK_TYPE_DISPLAY,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:frame-clock: (attributes org.gtk.Property.get=gdk_surface_get_frame_clock)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The `GdkFrameClock` of the surface.
|
|
|
|
|
*/
|
2019-04-22 01:14:28 +00:00
|
|
|
|
properties[PROP_FRAME_CLOCK] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("frame-clock", NULL, NULL,
|
2019-04-22 01:14:28 +00:00
|
|
|
|
GDK_TYPE_FRAME_CLOCK,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:mapped: (attributes org.gtk.Property.get=gdk_surface_get_mapped)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the surface is mapped.
|
|
|
|
|
*/
|
2019-04-06 16:36:51 +00:00
|
|
|
|
properties[PROP_MAPPED] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("mapped", NULL, NULL,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:width: (attributes org.gtk.Property.get=gdk_surface_get_width)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The width of the surface in pixels.
|
|
|
|
|
*/
|
2020-08-08 03:38:28 +00:00
|
|
|
|
properties[PROP_WIDTH] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("width", NULL, NULL,
|
2020-08-08 03:38:28 +00:00
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:height: (attributes org.gtk.Property.get=gdk_surface_get_height)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The height of the surface, in pixels.
|
|
|
|
|
*/
|
2020-08-08 03:38:28 +00:00
|
|
|
|
properties[PROP_HEIGHT] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("height", NULL, NULL,
|
2020-08-08 03:38:28 +00:00
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* GdkSurface:scale-factor: (attributes org.gtk.Property.get=gdk_surface_get_scale_factor)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The scale factor of the surface.
|
2023-04-02 17:17:36 +00:00
|
|
|
|
*
|
|
|
|
|
* The scale factor is the next larger integer,
|
|
|
|
|
* compared to [property@Gdk.Surface:scale].
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2021-01-16 20:16:36 +00:00
|
|
|
|
properties[PROP_SCALE_FACTOR] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("scale-factor", NULL, NULL,
|
2021-01-16 20:16:36 +00:00
|
|
|
|
1, G_MAXINT, 1,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkSurface:scale: (attributes org.gtk.Property.get=gdk_surface_get_scale)
|
|
|
|
|
*
|
|
|
|
|
* The scale of the surface.
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.12
|
|
|
|
|
*/
|
|
|
|
|
properties[PROP_SCALE] =
|
|
|
|
|
g_param_spec_double ("scale", NULL, NULL,
|
|
|
|
|
1., G_MAXDOUBLE, 1.,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
|
|
|
|
|
2020-11-24 17:33:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkSurface::layout:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: the `GdkSurface`
|
2020-11-24 17:33:05 +00:00
|
|
|
|
* @width: the current width
|
|
|
|
|
* @height: the current height
|
|
|
|
|
*
|
|
|
|
|
* Emitted when the size of @surface is changed, or when relayout should
|
|
|
|
|
* be performed.
|
|
|
|
|
*
|
|
|
|
|
* Surface size is reported in ”application pixels”, not
|
|
|
|
|
* ”device pixels” (see gdk_surface_get_scale_factor()).
|
|
|
|
|
*/
|
|
|
|
|
signals[LAYOUT] =
|
|
|
|
|
g_signal_new (g_intern_static_string ("layout"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2021-12-08 06:21:19 +00:00
|
|
|
|
_gdk_marshal_VOID__INT_INT,
|
2020-11-24 17:33:05 +00:00
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
2,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT);
|
2021-12-08 06:21:19 +00:00
|
|
|
|
g_signal_set_va_marshaller (signals[LAYOUT],
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
_gdk_marshal_VOID__INT_INTv);
|
2020-11-24 17:33:05 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkSurface::render:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: the `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @region: the region that needs to be redrawn
|
|
|
|
|
*
|
|
|
|
|
* Emitted when part of the surface needs to be redrawn.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE to indicate that the signal has been handled
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2019-04-06 16:36:51 +00:00
|
|
|
|
signals[RENDER] =
|
|
|
|
|
g_signal_new (g_intern_static_string ("render"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
g_signal_accumulator_true_handled,
|
|
|
|
|
NULL,
|
2019-05-28 17:18:35 +00:00
|
|
|
|
_gdk_marshal_BOOLEAN__BOXED,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
|
1,
|
|
|
|
|
CAIRO_GOBJECT_TYPE_REGION);
|
2019-05-28 17:18:35 +00:00
|
|
|
|
g_signal_set_va_marshaller (signals[RENDER],
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
_gdk_marshal_BOOLEAN__BOXEDv);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GdkSurface::event:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: the `GdkSurface`
|
2020-05-20 06:43:46 +00:00
|
|
|
|
* @event: (type Gdk.Event): an input event
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Emitted when GDK receives an input event for @surface.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE to indicate that the event has been handled
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2019-04-06 16:36:51 +00:00
|
|
|
|
signals[EVENT] =
|
|
|
|
|
g_signal_new (g_intern_static_string ("event"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
g_signal_accumulator_true_handled,
|
|
|
|
|
NULL,
|
2020-05-19 11:18:24 +00:00
|
|
|
|
gdk_surface_event_marshaller,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
|
1,
|
2020-05-19 11:18:24 +00:00
|
|
|
|
G_TYPE_POINTER);
|
2019-05-28 17:18:35 +00:00
|
|
|
|
g_signal_set_va_marshaller (signals[EVENT],
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
2020-05-19 11:18:24 +00:00
|
|
|
|
gdk_surface_event_marshallerv);
|
2017-11-29 03:36:17 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2020-05-28 08:00:03 +00:00
|
|
|
|
* GdkSurface::enter-monitor:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: the `GdkSurface`
|
2017-11-29 03:36:17 +00:00
|
|
|
|
* @monitor: the monitor
|
|
|
|
|
*
|
|
|
|
|
* Emitted when @surface starts being present on the monitor.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2017-11-29 03:36:17 +00:00
|
|
|
|
signals[ENTER_MONITOR] =
|
|
|
|
|
g_signal_new (g_intern_static_string ("enter-monitor"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
1,
|
|
|
|
|
GDK_TYPE_MONITOR);
|
|
|
|
|
|
|
|
|
|
/**
|
2020-05-28 08:00:03 +00:00
|
|
|
|
* GdkSurface::leave-monitor:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: the `GdkSurface`
|
2017-11-29 03:36:17 +00:00
|
|
|
|
* @monitor: the monitor
|
|
|
|
|
*
|
|
|
|
|
* Emitted when @surface stops being present on the monitor.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2017-11-29 03:36:17 +00:00
|
|
|
|
signals[LEAVE_MONITOR] =
|
|
|
|
|
g_signal_new (g_intern_static_string ("leave-monitor"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
1,
|
|
|
|
|
GDK_TYPE_MONITOR);
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
}
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
static void
|
2015-12-15 22:22:00 +00:00
|
|
|
|
seat_removed_cb (GdkDisplay *display,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSeat *seat,
|
|
|
|
|
GdkSurface *surface)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDevice *device = gdk_seat_get_pointer (seat);
|
2015-12-15 22:22:00 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
surface->devices_inside = g_list_remove (surface->devices_inside, device);
|
|
|
|
|
g_hash_table_remove (surface->device_cursor, device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_finalize (GObject *object)
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-12-08 20:33:06 +00:00
|
|
|
|
g_clear_handle_id (&surface->request_motion_id, g_source_remove);
|
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (surface->display,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
seat_removed_cb, surface);
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("losing last reference to undestroyed surface");
|
|
|
|
|
_gdk_surface_destroy (surface, FALSE);
|
|
|
|
|
}
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2021-09-24 17:43:15 +00:00
|
|
|
|
g_clear_pointer (&surface->input_region, cairo_region_destroy);
|
|
|
|
|
g_clear_object (&surface->cursor);
|
|
|
|
|
g_clear_pointer (&surface->device_cursor, g_hash_table_destroy);
|
|
|
|
|
g_clear_pointer (&surface->devices_inside, g_list_free);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_clear_object (&surface->display);
|
2016-10-27 13:38:41 +00:00
|
|
|
|
|
2021-09-24 17:43:15 +00:00
|
|
|
|
g_clear_pointer (&surface->opaque_region, cairo_region_destroy);
|
2017-08-18 10:01:54 +00:00
|
|
|
|
|
2019-05-22 22:04:45 +00:00
|
|
|
|
if (surface->parent)
|
|
|
|
|
surface->parent->children = g_list_remove (surface->parent->children, surface);
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
G_OBJECT_CLASS (gdk_surface_parent_class)->finalize (object);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 06:16:01 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_set_property (GObject *object,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2019-03-25 12:33:56 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_CURSOR:
|
|
|
|
|
gdk_surface_set_cursor (surface, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
|
surface->display = g_value_dup_object (value);
|
|
|
|
|
g_assert (surface->display != NULL);
|
2019-05-26 03:55:08 +00:00
|
|
|
|
g_signal_connect (surface->display, "seat-removed",
|
|
|
|
|
G_CALLBACK (seat_removed_cb), surface);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2019-04-22 01:14:28 +00:00
|
|
|
|
case PROP_FRAME_CLOCK:
|
|
|
|
|
gdk_surface_set_frame_clock (surface, GDK_FRAME_CLOCK (g_value_get_object (value)));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-07-16 06:16:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
|
#define GDK_SURFACE_IS_STICKY(surface) (((surface)->state & GDK_TOPLEVEL_STATE_STICKY))
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
2009-07-16 06:16:01 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_get_property (GObject *object,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2009-07-16 06:16:01 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
2009-07-16 06:16:01 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_CURSOR:
|
|
|
|
|
g_value_set_object (value, gdk_surface_get_cursor (surface));
|
|
|
|
|
break;
|
2009-07-16 06:16:01 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
|
g_value_set_object (value, surface->display);
|
|
|
|
|
break;
|
2016-10-27 13:38:41 +00:00
|
|
|
|
|
2019-04-22 01:14:28 +00:00
|
|
|
|
case PROP_FRAME_CLOCK:
|
|
|
|
|
g_value_set_object (value, surface->frame_clock);
|
|
|
|
|
break;
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
case PROP_MAPPED:
|
|
|
|
|
g_value_set_boolean (value, GDK_SURFACE_IS_MAPPED (surface));
|
|
|
|
|
break;
|
2018-07-15 18:23:54 +00:00
|
|
|
|
|
2020-08-08 03:38:28 +00:00
|
|
|
|
case PROP_WIDTH:
|
|
|
|
|
g_value_set_int (value, surface->width);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_HEIGHT:
|
|
|
|
|
g_value_set_int (value, surface->height);
|
|
|
|
|
break;
|
|
|
|
|
|
2021-01-16 20:16:36 +00:00
|
|
|
|
case PROP_SCALE_FACTOR:
|
|
|
|
|
g_value_set_int (value, gdk_surface_get_scale_factor (surface));
|
|
|
|
|
break;
|
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
case PROP_SCALE:
|
|
|
|
|
g_value_set_double (value, gdk_surface_get_scale (surface));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-07-16 06:16:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
_gdk_surface_update_size (GdkSurface *surface)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GSList *l;
|
2018-04-08 22:35:32 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
for (l = surface->draw_contexts; l; l = l->next)
|
|
|
|
|
gdk_draw_context_surface_resized (l->data);
|
2020-08-08 03:38:28 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "width");
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "height");
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 16:40:59 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_new_toplevel: (constructor)
|
|
|
|
|
* @display: the display to create the surface on
|
|
|
|
|
*
|
2019-04-21 16:51:10 +00:00
|
|
|
|
* Creates a new toplevel surface.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Returns: (transfer full): the new `GdkSurface`
|
|
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GdkSurface *
|
2020-07-30 21:06:59 +00:00
|
|
|
|
gdk_surface_new_toplevel (GdkDisplay *display)
|
2016-11-06 16:40:59 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
2016-11-06 16:40:59 +00:00
|
|
|
|
|
2023-04-21 03:41:48 +00:00
|
|
|
|
return g_object_new (GDK_DISPLAY_GET_CLASS (display)->toplevel_type,
|
|
|
|
|
"display", display,
|
|
|
|
|
NULL);
|
2016-11-06 16:40:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-20 00:05:17 +00:00
|
|
|
|
/**
|
2019-04-21 16:51:10 +00:00
|
|
|
|
* gdk_surface_new_popup: (constructor)
|
2019-03-20 00:05:17 +00:00
|
|
|
|
* @parent: the parent surface to attach the surface to
|
2019-04-22 21:31:33 +00:00
|
|
|
|
* @autohide: whether to hide the surface on outside clicks
|
2019-03-20 00:05:17 +00:00
|
|
|
|
*
|
|
|
|
|
* Create a new popup surface.
|
2019-04-22 21:31:33 +00:00
|
|
|
|
*
|
2020-08-05 19:42:27 +00:00
|
|
|
|
* The surface will be attached to @parent and can be positioned
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* relative to it using [method@Gdk.Popup.present].
|
2019-03-20 00:05:17 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Returns: (transfer full): a new `GdkSurface`
|
2019-03-20 00:05:17 +00:00
|
|
|
|
*/
|
|
|
|
|
GdkSurface *
|
2020-02-21 20:13:09 +00:00
|
|
|
|
gdk_surface_new_popup (GdkSurface *parent,
|
2019-04-22 21:31:33 +00:00
|
|
|
|
gboolean autohide)
|
2019-03-20 00:05:17 +00:00
|
|
|
|
{
|
|
|
|
|
GdkSurface *surface;
|
2023-04-21 03:41:48 +00:00
|
|
|
|
GdkDisplay *display;
|
2019-03-20 00:05:17 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL);
|
|
|
|
|
|
2023-04-21 03:41:48 +00:00
|
|
|
|
display = gdk_surface_get_display (parent);
|
|
|
|
|
|
|
|
|
|
surface = g_object_new (GDK_DISPLAY_GET_CLASS (display)->popup_type,
|
|
|
|
|
"display", display,
|
|
|
|
|
"parent", parent,
|
|
|
|
|
NULL);
|
2019-04-21 16:51:10 +00:00
|
|
|
|
|
2019-04-22 21:31:33 +00:00
|
|
|
|
surface->autohide = autohide;
|
|
|
|
|
|
2019-03-20 00:05:17 +00:00
|
|
|
|
return surface;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
static void
|
|
|
|
|
update_pointer_info_foreach (GdkDisplay *display,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkPointerSurfaceInfo *pointer_info,
|
|
|
|
|
gpointer user_data)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSurface *surface = user_data;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (pointer_info->surface_under_pointer == surface)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (pointer_info->surface_under_pointer);
|
|
|
|
|
pointer_info->surface_under_pointer = NULL;
|
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface_remove_from_pointer_info (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDisplay *display)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
_gdk_display_pointer_info_foreach (display,
|
|
|
|
|
update_pointer_info_foreach,
|
|
|
|
|
surface);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* _gdk_surface_destroy_hierarchy:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
* @recursing_native: If %TRUE, then this is being called because a native
|
|
|
|
|
* parent was destroyed. This generally means that the call to the windowing
|
|
|
|
|
* system to destroy the surface can be omitted, since it will be destroyed
|
|
|
|
|
* as a result of the parent being destroyed. Unless @foreign_destroy.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @foreign_destroy: If %TRUE, the surface or a parent was destroyed by some
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* external agency. The surface has already been destroyed and no windowing
|
|
|
|
|
* system calls should be made. (This may never happen for some windowing
|
|
|
|
|
* systems.)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Internal function to destroy a surface. Like gdk_surface_destroy(),
|
|
|
|
|
* but does not drop the reference count created by gdk_surface_new().
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2000-05-15 16:09:53 +00:00
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
_gdk_surface_destroy_hierarchy (GdkSurface *surface,
|
2021-10-03 19:58:57 +00:00
|
|
|
|
gboolean foreign_destroy)
|
2000-05-15 16:09:53 +00:00
|
|
|
|
{
|
2021-10-03 19:58:57 +00:00
|
|
|
|
G_GNUC_UNUSED GdkSurfacePrivate *priv = gdk_surface_get_instance_private (surface);
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2009-02-28 05:24:07 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
|
return;
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-05-24 01:56:35 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->destroy (surface, foreign_destroy);
|
|
|
|
|
|
2021-10-03 19:58:57 +00:00
|
|
|
|
/* backend must have unset this */
|
|
|
|
|
g_assert (priv->egl_native_window == NULL);
|
|
|
|
|
|
2019-03-24 20:24:30 +00:00
|
|
|
|
if (surface->gl_paint_context)
|
2000-05-15 16:09:53 +00:00
|
|
|
|
{
|
2019-03-24 20:24:30 +00:00
|
|
|
|
/* Make sure to destroy if current */
|
|
|
|
|
g_object_run_dispose (G_OBJECT (surface->gl_paint_context));
|
|
|
|
|
g_object_unref (surface->gl_paint_context);
|
|
|
|
|
surface->gl_paint_context = NULL;
|
|
|
|
|
}
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
2019-03-24 20:24:30 +00:00
|
|
|
|
if (surface->frame_clock)
|
|
|
|
|
{
|
2019-05-20 13:19:12 +00:00
|
|
|
|
if (surface->parent == NULL)
|
|
|
|
|
g_object_run_dispose (G_OBJECT (surface->frame_clock));
|
2019-03-24 20:24:30 +00:00
|
|
|
|
gdk_surface_set_frame_clock (surface, NULL);
|
|
|
|
|
}
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
2019-03-24 20:24:30 +00:00
|
|
|
|
_gdk_surface_clear_update_area (surface);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
g_clear_handle_id (&surface->set_is_mapped_source_id, g_source_remove);
|
|
|
|
|
surface->is_mapped = FALSE;
|
|
|
|
|
surface->pending_is_mapped = FALSE;
|
|
|
|
|
|
2019-03-24 20:24:30 +00:00
|
|
|
|
surface->destroyed = TRUE;
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
surface_remove_from_pointer_info (surface, surface->display);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
if (GDK_IS_TOPLEVEL (surface))
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "state");
|
2019-03-24 20:24:30 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
|
2000-05-15 16:09:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* _gdk_surface_destroy:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @foreign_destroy: If %TRUE, the surface or a parent was destroyed by some
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* external agency. The surface has already been destroyed and no windowing
|
|
|
|
|
* system calls should be made. (This may never happen for some windowing
|
|
|
|
|
* systems.)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Internal function to destroy a surface. Like gdk_surface_destroy(),
|
|
|
|
|
* but does not drop the reference count created by gdk_surface_new().
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2000-05-15 16:09:53 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
_gdk_surface_destroy (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
gboolean foreign_destroy)
|
2000-05-15 16:09:53 +00:00
|
|
|
|
{
|
2019-03-24 20:24:30 +00:00
|
|
|
|
_gdk_surface_destroy_hierarchy (surface, foreign_destroy);
|
2000-05-15 16:09:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-03 18:19:48 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_destroy:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Destroys the window system resources associated with @surface and
|
|
|
|
|
* decrements @surface's reference count.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The window system resources for all children of @surface are also
|
|
|
|
|
* destroyed, but the children’s reference counts are not decremented.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Note that a surface will not be destroyed automatically when its
|
|
|
|
|
* reference count reaches zero. You must call this function yourself
|
|
|
|
|
* before that happens.
|
|
|
|
|
*/
|
2000-05-15 16:09:53 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_destroy (GdkSurface *surface)
|
2000-05-15 16:09:53 +00:00
|
|
|
|
{
|
2019-03-24 20:24:30 +00:00
|
|
|
|
_gdk_surface_destroy_hierarchy (surface, FALSE);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_object_unref (surface);
|
2000-05-15 16:09:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
2021-10-03 06:20:30 +00:00
|
|
|
|
gdk_surface_set_widget (GdkSurface *self,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
gpointer widget)
|
1998-01-01 20:38:21 +00:00
|
|
|
|
{
|
2021-10-03 06:20:30 +00:00
|
|
|
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
priv->widget = widget;
|
1998-01-01 20:38:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-23 23:56:02 +00:00
|
|
|
|
gpointer
|
2021-10-03 06:20:30 +00:00
|
|
|
|
gdk_surface_get_widget (GdkSurface *self)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2021-10-03 06:20:30 +00:00
|
|
|
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
return priv->widget;
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-29 00:03:19 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_display: (attributes org.gtk.Method.get_property=display)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Gets the `GdkDisplay` associated with a `GdkSurface`.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the `GdkDisplay` associated with @surface
|
|
|
|
|
*/
|
2010-08-29 00:03:19 +00:00
|
|
|
|
GdkDisplay *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_display (GdkSurface *surface)
|
2010-08-29 00:03:19 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2010-08-29 00:03:19 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return surface->display;
|
2010-08-29 00:03:19 +00:00
|
|
|
|
}
|
2009-09-04 15:49:57 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_is_destroyed:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Check to see if a surface is destroyed.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the surface is destroyed
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2009-09-04 15:49:57 +00:00
|
|
|
|
gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_is_destroyed (GdkSurface *surface)
|
2009-09-04 15:49:57 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return GDK_SURFACE_DESTROYED (surface);
|
2009-09-04 15:49:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-24 22:59:12 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_mapped: (attributes org.gtk.Method.get_property=mapped)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Checks whether the surface has been mapped.
|
2020-02-24 22:59:12 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* A surface is mapped with [method@Gdk.Toplevel.present]
|
|
|
|
|
* or [method@Gdk.Popup.present].
|
2020-02-24 22:59:12 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the surface is mapped
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2020-02-24 22:59:12 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gdk_surface_get_mapped (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_SURFACE_IS_MAPPED (surface);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-03 19:58:57 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_set_egl_native_window (GdkSurface *self,
|
|
|
|
|
gpointer native_window)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
/* This checks that all EGL platforms we support conform to the same struct sizes.
|
|
|
|
|
* When this ever fails, there will be some fun times happening for whoever tries
|
|
|
|
|
* this weird EGL backend... */
|
|
|
|
|
G_STATIC_ASSERT (sizeof (gpointer) == sizeof (EGLNativeWindowType));
|
|
|
|
|
|
|
|
|
|
if (priv->egl_surface != NULL)
|
|
|
|
|
{
|
2021-12-22 18:49:13 +00:00
|
|
|
|
gdk_gl_context_clear_current_if_surface (self);
|
2021-10-03 19:58:57 +00:00
|
|
|
|
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
|
|
|
|
|
priv->egl_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->egl_native_window = native_window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpointer /* EGLSurface */
|
|
|
|
|
gdk_surface_get_egl_surface (GdkSurface *self)
|
|
|
|
|
{
|
|
|
|
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
|
|
|
|
|
2021-10-06 01:33:24 +00:00
|
|
|
|
return priv->egl_surface;
|
|
|
|
|
}
|
2021-10-03 19:58:57 +00:00
|
|
|
|
|
2021-10-06 01:33:24 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_ensure_egl_surface (GdkSurface *self,
|
2021-10-06 16:25:30 +00:00
|
|
|
|
gboolean high_depth)
|
2021-10-06 01:33:24 +00:00
|
|
|
|
{
|
|
|
|
|
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
|
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (self);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (priv->egl_native_window != NULL);
|
|
|
|
|
|
2021-10-06 16:25:30 +00:00
|
|
|
|
if (priv->egl_surface_high_depth != high_depth &&
|
2021-10-06 01:33:24 +00:00
|
|
|
|
priv->egl_surface != NULL &&
|
2021-10-06 16:25:30 +00:00
|
|
|
|
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
|
2021-10-03 19:58:57 +00:00
|
|
|
|
{
|
2021-12-22 18:49:13 +00:00
|
|
|
|
gdk_gl_context_clear_current_if_surface (self);
|
2022-03-22 07:11:18 +00:00
|
|
|
|
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
|
2021-10-06 01:33:24 +00:00
|
|
|
|
priv->egl_surface = NULL;
|
|
|
|
|
}
|
2021-10-03 19:58:57 +00:00
|
|
|
|
|
2021-10-06 01:33:24 +00:00
|
|
|
|
if (priv->egl_surface == NULL)
|
|
|
|
|
{
|
2021-10-03 19:58:57 +00:00
|
|
|
|
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
2021-10-06 16:25:30 +00:00
|
|
|
|
high_depth ? gdk_display_get_egl_config_high_depth (display)
|
|
|
|
|
: gdk_display_get_egl_config (display),
|
2021-10-03 19:58:57 +00:00
|
|
|
|
(EGLNativeWindowType) priv->egl_native_window,
|
|
|
|
|
NULL);
|
2021-10-06 16:25:30 +00:00
|
|
|
|
priv->egl_surface_high_depth = high_depth;
|
2021-10-03 19:58:57 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-09 08:45:44 +00:00
|
|
|
|
GdkGLContext *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_paint_gl_context (GdkSurface *surface,
|
2021-07-04 23:57:03 +00:00
|
|
|
|
GError **error)
|
2019-03-25 12:33:56 +00:00
|
|
|
|
{
|
2021-07-04 23:57:03 +00:00
|
|
|
|
if (!gdk_display_prepare_gl (surface->display, error))
|
|
|
|
|
return NULL;
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
if (surface->gl_paint_context == NULL)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
{
|
2021-07-09 00:50:32 +00:00
|
|
|
|
surface->gl_paint_context = gdk_surface_create_gl_context (surface, error);
|
|
|
|
|
if (surface->gl_paint_context == NULL)
|
|
|
|
|
return NULL;
|
2019-04-06 16:36:51 +00:00
|
|
|
|
}
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2021-07-09 00:50:32 +00:00
|
|
|
|
if (!gdk_gl_context_realize (surface->gl_paint_context, error))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
{
|
2021-07-09 00:50:32 +00:00
|
|
|
|
g_clear_object (&surface->gl_paint_context);
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
return surface->gl_paint_context;
|
2014-10-09 08:45:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_create_gl_context:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @error: return location for an error
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Creates a new `GdkGLContext` for the `GdkSurface`.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The context is disconnected from any particular surface or surface.
|
|
|
|
|
* If the creation of the `GdkGLContext` failed, @error will be set.
|
|
|
|
|
* Before using the returned `GdkGLContext`, you will need to
|
|
|
|
|
* call [method@Gdk.GLContext.make_current] or [method@Gdk.GLContext.realize].
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-10-20 18:02:26 +00:00
|
|
|
|
* Returns: (transfer full): the newly created `GdkGLContext`
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2014-10-09 08:45:44 +00:00
|
|
|
|
GdkGLContext *
|
2018-04-11 22:16:43 +00:00
|
|
|
|
gdk_surface_create_gl_context (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GError **error)
|
2014-10-09 08:45:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2014-10-09 08:45:44 +00:00
|
|
|
|
|
2021-07-06 02:50:01 +00:00
|
|
|
|
if (!gdk_display_prepare_gl (surface->display, error))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return NULL;
|
2014-10-09 08:45:44 +00:00
|
|
|
|
|
2021-10-20 18:03:00 +00:00
|
|
|
|
return gdk_gl_context_new (surface->display, surface);
|
2018-04-11 22:16:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-12 14:48:31 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_create_cairo_context:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Creates a new `GdkCairoContext` for rendering on @surface.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Returns: (transfer full): the newly created `GdkCairoContext`
|
|
|
|
|
*/
|
2018-04-11 22:16:43 +00:00
|
|
|
|
GdkCairoContext *
|
|
|
|
|
gdk_surface_create_cairo_context (GdkSurface *surface)
|
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDisplay *display;
|
2018-04-12 14:48:31 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2018-04-12 14:48:31 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
display = surface->display;
|
2018-04-12 14:48:31 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return g_object_new (GDK_DISPLAY_GET_CLASS (display)->cairo_context_type,
|
|
|
|
|
"surface", surface,
|
|
|
|
|
NULL);
|
2014-10-09 08:45:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 15:34:01 +00:00
|
|
|
|
/**
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_create_vulkan_context:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @error: return location for an error
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Creates a new `GdkVulkanContext` for rendering on @surface.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* If the creation of the `GdkVulkanContext` failed, @error will be set.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Returns: (transfer full): the newly created `GdkVulkanContext`, or
|
|
|
|
|
* %NULL on error
|
|
|
|
|
*/
|
2016-11-28 15:34:01 +00:00
|
|
|
|
GdkVulkanContext *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_create_vulkan_context (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GError **error)
|
2016-11-28 15:34:01 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkDisplay *display;
|
2016-11-28 15:34:01 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2016-11-28 15:34:01 +00:00
|
|
|
|
|
2022-09-22 00:51:35 +00:00
|
|
|
|
if (gdk_display_get_debug_flags (surface->display) & GDK_DEBUG_VULKAN_DISABLE)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
{
|
|
|
|
|
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
|
|
|
|
_("Vulkan support disabled via GDK_DEBUG"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2016-11-29 14:35:04 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
display = surface->display;
|
2016-11-28 15:34:01 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (GDK_DISPLAY_GET_CLASS (display)->vk_extension_name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
|
|
|
|
|
"The %s backend has no Vulkan support.", G_OBJECT_TYPE_NAME (display));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2016-11-28 15:34:01 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return g_initable_new (GDK_DISPLAY_GET_CLASS (display)->vk_context_type,
|
|
|
|
|
NULL,
|
|
|
|
|
error,
|
|
|
|
|
"surface", surface,
|
|
|
|
|
NULL);
|
2016-11-28 15:34:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-12 17:13:24 +00:00
|
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_is_toplevel_frozen (GdkSurface *surface)
|
2007-09-12 17:13:24 +00:00
|
|
|
|
{
|
2019-03-22 18:24:39 +00:00
|
|
|
|
return surface->update_and_descendants_freeze_count > 0;
|
2007-09-12 17:13:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-26 14:09:08 +00:00
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_schedule_update (GdkSurface *surface)
|
2004-08-26 14:09:08 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkFrameClock *frame_clock;
|
2013-01-30 20:09:44 +00:00
|
|
|
|
|
2019-06-28 16:45:44 +00:00
|
|
|
|
g_return_if_fail (surface);
|
|
|
|
|
|
2021-04-07 19:04:28 +00:00
|
|
|
|
surface->pending_phases |= GDK_FRAME_CLOCK_PHASE_PAINT;
|
|
|
|
|
|
2019-06-28 16:45:44 +00:00
|
|
|
|
if (surface->update_freeze_count ||
|
|
|
|
|
gdk_surface_is_toplevel_frozen (surface))
|
2021-04-07 19:04:28 +00:00
|
|
|
|
return;
|
2004-08-26 14:09:08 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
/* If there's no frame clock (a foreign surface), then the invalid
|
|
|
|
|
* region will just stick around unless gdk_surface_process_updates()
|
|
|
|
|
* is called. */
|
|
|
|
|
frame_clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
|
if (frame_clock)
|
|
|
|
|
gdk_frame_clock_request_phase (gdk_surface_get_frame_clock (surface),
|
|
|
|
|
GDK_FRAME_CLOCK_PHASE_PAINT);
|
2004-08-26 14:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 21:02:53 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_surface_layout_on_clock (GdkFrameClock *clock,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2020-11-24 22:16:48 +00:00
|
|
|
|
GdkSurfaceClass *class;
|
2020-11-24 21:02:53 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
|
|
|
|
|
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!GDK_SURFACE_IS_MAPPED (surface))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-12-02 08:39:48 +00:00
|
|
|
|
surface->pending_phases &= ~GDK_FRAME_CLOCK_PHASE_LAYOUT;
|
|
|
|
|
|
2020-11-24 22:16:48 +00:00
|
|
|
|
class = GDK_SURFACE_GET_CLASS (surface);
|
|
|
|
|
if (class->compute_size)
|
2020-12-04 23:11:08 +00:00
|
|
|
|
{
|
|
|
|
|
if (class->compute_size (surface))
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-24 22:16:48 +00:00
|
|
|
|
|
2020-11-24 21:02:53 +00:00
|
|
|
|
g_signal_emit (surface, signals[LAYOUT], 0, surface->width, surface->height);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-15 19:14:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_surface_request_layout:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Request a layout phase from the surface's frame clock.
|
2020-12-15 19:14:49 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* See [method@Gdk.FrameClock.request_phase].
|
2020-12-15 19:14:49 +00:00
|
|
|
|
*/
|
2020-11-24 21:02:53 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_request_layout (GdkSurface *surface)
|
|
|
|
|
{
|
2020-12-02 08:12:01 +00:00
|
|
|
|
GdkSurfaceClass *class;
|
2020-11-24 21:02:53 +00:00
|
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
|
|
2020-12-02 08:12:01 +00:00
|
|
|
|
class = GDK_SURFACE_GET_CLASS (surface);
|
|
|
|
|
if (class->request_layout)
|
|
|
|
|
class->request_layout (surface);
|
|
|
|
|
|
2020-11-24 21:02:53 +00:00
|
|
|
|
frame_clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
|
g_return_if_fail (frame_clock);
|
|
|
|
|
|
|
|
|
|
gdk_frame_clock_request_phase (frame_clock,
|
|
|
|
|
GDK_FRAME_CLOCK_PHASE_LAYOUT);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-30 16:46:22 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_paint_on_clock (GdkFrameClock *clock,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
void *data)
|
2013-06-26 08:03:51 +00:00
|
|
|
|
{
|
2019-05-22 20:58:24 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2023-04-22 14:33:35 +00:00
|
|
|
|
cairo_region_t *expose_region;
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-10-21 21:42:39 +00:00
|
|
|
|
|
2023-04-22 14:33:35 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
|
!surface->update_area ||
|
|
|
|
|
surface->update_freeze_count ||
|
|
|
|
|
gdk_surface_is_toplevel_frozen (surface))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return;
|
2009-08-20 15:09:08 +00:00
|
|
|
|
|
2023-04-22 14:33:35 +00:00
|
|
|
|
surface->pending_phases &= ~GDK_FRAME_CLOCK_PHASE_PAINT;
|
|
|
|
|
expose_region = surface->update_area;
|
|
|
|
|
surface->update_area = NULL;
|
2023-04-22 14:29:58 +00:00
|
|
|
|
|
2023-04-22 14:33:35 +00:00
|
|
|
|
if (GDK_SURFACE_IS_MAPPED (surface))
|
|
|
|
|
{
|
|
|
|
|
gboolean handled;
|
2023-04-22 14:29:58 +00:00
|
|
|
|
|
2023-04-22 14:35:16 +00:00
|
|
|
|
g_object_ref (surface);
|
|
|
|
|
|
2023-04-22 14:33:35 +00:00
|
|
|
|
g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
|
2023-04-22 14:35:16 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (surface);
|
2023-04-22 14:33:35 +00:00
|
|
|
|
}
|
2023-04-22 14:29:58 +00:00
|
|
|
|
|
2023-04-22 14:33:35 +00:00
|
|
|
|
cairo_region_destroy (expose_region);
|
2000-03-28 01:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 02:40:01 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_invalidate_rect:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @rect: (nullable): rectangle to invalidate or %NULL to
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* invalidate the whole surface
|
|
|
|
|
*
|
|
|
|
|
* Invalidate a rectangular region of @surface.
|
|
|
|
|
*
|
|
|
|
|
* This is a convenience wrapper around
|
|
|
|
|
* [method@Gdk.Surface.invalidate_region].
|
|
|
|
|
*/
|
2018-03-21 03:07:37 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_invalidate_rect (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
const GdkRectangle *rect)
|
2000-03-28 01:24:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkRectangle surface_rect;
|
|
|
|
|
cairo_region_t *region;
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2020-05-16 22:41:44 +00:00
|
|
|
|
if (!GDK_SURFACE_IS_MAPPED (surface))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return;
|
2000-07-31 17:18:36 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (!rect)
|
|
|
|
|
{
|
|
|
|
|
surface_rect.x = 0;
|
|
|
|
|
surface_rect.y = 0;
|
|
|
|
|
surface_rect.width = surface->width;
|
|
|
|
|
surface_rect.height = surface->height;
|
|
|
|
|
rect = &surface_rect;
|
|
|
|
|
}
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
region = cairo_region_create_rectangle (rect);
|
|
|
|
|
gdk_surface_invalidate_region (surface, region);
|
|
|
|
|
cairo_region_destroy (region);
|
2000-03-28 01:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 11:28:38 +00:00
|
|
|
|
static void
|
2018-03-28 14:42:26 +00:00
|
|
|
|
impl_surface_add_update_area (GdkSurface *impl_surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
cairo_region_t *region)
|
2009-09-14 11:28:38 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (impl_surface->update_area)
|
|
|
|
|
cairo_region_union (impl_surface->update_area, region);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
impl_surface->update_area = cairo_region_copy (region);
|
|
|
|
|
gdk_surface_schedule_update (impl_surface);
|
|
|
|
|
}
|
2009-09-14 11:28:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-28 14:42:26 +00:00
|
|
|
|
/**
|
2020-07-30 02:40:01 +00:00
|
|
|
|
* gdk_surface_queue_render:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Forces a [signal@Gdk.Surface::render] signal emission for @surface
|
2020-07-30 02:40:01 +00:00
|
|
|
|
* to be scheduled.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is useful for implementations that track invalid
|
|
|
|
|
* regions on their own.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2018-03-28 14:42:26 +00:00
|
|
|
|
void
|
2020-07-30 02:40:01 +00:00
|
|
|
|
gdk_surface_queue_render (GdkSurface *surface)
|
2018-03-28 14:42:26 +00:00
|
|
|
|
{
|
2020-11-05 00:28:13 +00:00
|
|
|
|
cairo_region_t *region;
|
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2018-03-28 14:42:26 +00:00
|
|
|
|
|
2020-11-05 00:28:13 +00:00
|
|
|
|
region = cairo_region_create ();
|
|
|
|
|
impl_surface_add_update_area (surface, region);
|
|
|
|
|
cairo_region_destroy (region);
|
2018-03-28 14:42:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 02:30:44 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_invalidate_region:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
* @region: a `cairo_region_t`
|
|
|
|
|
*
|
|
|
|
|
* Adds @region to the update area for @surface.
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The update area is the region that needs to be redrawn,
|
|
|
|
|
* or “dirty region.”
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* GDK will process all updates whenever the frame clock schedules
|
|
|
|
|
* a redraw, so there’s no need to do forces redraws manually, you
|
|
|
|
|
* just need to invalidate regions that you know should be redrawn.
|
|
|
|
|
*/
|
2018-03-21 03:07:37 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_invalidate_region (GdkSurface *surface,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
const cairo_region_t *region)
|
2000-03-28 01:24:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
cairo_region_t *visible_region;
|
|
|
|
|
cairo_rectangle_int_t r;
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2009-05-27 15:08:09 +00:00
|
|
|
|
|
2020-05-16 22:41:44 +00:00
|
|
|
|
if (!GDK_SURFACE_IS_MAPPED (surface))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return;
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2020-05-16 22:41:44 +00:00
|
|
|
|
if (cairo_region_is_empty (region))
|
2019-04-06 16:36:51 +00:00
|
|
|
|
return;
|
2013-04-20 23:27:07 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
r.x = 0;
|
|
|
|
|
r.y = 0;
|
2019-03-23 13:13:37 +00:00
|
|
|
|
r.width = surface->width;
|
|
|
|
|
r.height = surface->height;
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
visible_region = cairo_region_copy (region);
|
2009-05-27 15:08:09 +00:00
|
|
|
|
|
2019-03-23 13:13:37 +00:00
|
|
|
|
cairo_region_intersect_rectangle (visible_region, &r);
|
|
|
|
|
impl_surface_add_update_area (surface, visible_region);
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
cairo_region_destroy (visible_region);
|
2000-03-28 01:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 02:30:44 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* _gdk_surface_clear_update_area:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2020-07-30 02:40:01 +00:00
|
|
|
|
* Internal function to clear the update area for a surface.
|
|
|
|
|
* This is called when the surface is hidden or destroyed.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2000-05-15 16:09:53 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
_gdk_surface_clear_update_area (GdkSurface *surface)
|
2000-05-15 16:09:53 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2000-05-15 16:09:53 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (surface->update_area)
|
|
|
|
|
{
|
|
|
|
|
cairo_region_destroy (surface->update_area);
|
|
|
|
|
surface->update_area = NULL;
|
|
|
|
|
}
|
2000-05-15 16:09:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 02:30:44 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_freeze_updates:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Temporarily freezes a surface such that it won’t receive expose
|
|
|
|
|
* events. The surface will begin receiving expose events again when
|
|
|
|
|
* gdk_surface_thaw_updates() is called. If gdk_surface_freeze_updates()
|
2020-07-30 02:40:01 +00:00
|
|
|
|
* has been called more than once, gdk_surface_thaw_updates() must be
|
|
|
|
|
* called an equal number of times to begin processing exposes.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2000-03-28 01:24:44 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_freeze_updates (GdkSurface *surface)
|
2000-03-28 01:24:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2023-05-09 12:55:54 +00:00
|
|
|
|
if (GDK_DEBUG_CHECK (NO_VSYNC))
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
surface->update_freeze_count++;
|
2019-06-28 16:45:44 +00:00
|
|
|
|
if (surface->update_freeze_count == 1)
|
|
|
|
|
_gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
|
2000-03-28 01:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-12 00:36:16 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
request_motion_cb (void *data)
|
|
|
|
|
{
|
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
|
|
|
|
|
|
if (clock)
|
|
|
|
|
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
|
|
|
|
surface->request_motion_id = 0;
|
|
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-07-30 02:30:44 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_thaw_updates:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-04-06 16:36:51 +00:00
|
|
|
|
*
|
2019-06-28 16:45:44 +00:00
|
|
|
|
* Thaws a surface frozen with gdk_surface_freeze_updates(). Note that this
|
|
|
|
|
* will not necessarily schedule updates if the surface freeze count reaches
|
|
|
|
|
* zero.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2000-03-28 01:24:44 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_thaw_updates (GdkSurface *surface)
|
2000-03-28 01:24:44 +00:00
|
|
|
|
{
|
2019-04-06 16:36:51 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2000-03-28 01:24:44 +00:00
|
|
|
|
|
2023-05-09 12:55:54 +00:00
|
|
|
|
if (GDK_DEBUG_CHECK (NO_VSYNC))
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
g_return_if_fail (surface->update_freeze_count > 0);
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
if (--surface->update_freeze_count == 0)
|
2019-06-28 16:45:44 +00:00
|
|
|
|
{
|
2020-11-24 21:00:38 +00:00
|
|
|
|
GdkFrameClock *frame_clock = surface->frame_clock;
|
2019-06-28 16:45:44 +00:00
|
|
|
|
|
2020-11-24 21:00:38 +00:00
|
|
|
|
_gdk_frame_clock_inhibit_freeze (frame_clock);
|
2019-06-28 16:45:44 +00:00
|
|
|
|
|
2020-11-24 21:00:38 +00:00
|
|
|
|
if (surface->pending_phases)
|
2020-12-02 08:39:48 +00:00
|
|
|
|
gdk_frame_clock_request_phase (frame_clock, surface->pending_phases);
|
2020-12-12 00:36:16 +00:00
|
|
|
|
|
|
|
|
|
if (surface->request_motion && surface->request_motion_id == 0)
|
|
|
|
|
{
|
|
|
|
|
surface->request_motion_id =
|
2022-09-28 16:36:22 +00:00
|
|
|
|
g_idle_add_full (GDK_PRIORITY_REDRAW + 20, request_motion_cb, surface, NULL);
|
|
|
|
|
gdk_source_set_static_name_by_id (surface->request_motion_id, "[gtk] request_motion_cb");
|
2020-12-12 00:36:16 +00:00
|
|
|
|
}
|
2020-11-24 15:03:07 +00:00
|
|
|
|
}
|
2007-09-12 17:13:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-14 01:47:54 +00:00
|
|
|
|
/*
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* gdk_surface_constrain_size:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @geometry: a `GdkGeometry` structure
|
2019-04-06 16:36:51 +00:00
|
|
|
|
* @flags: a mask indicating what portions of @geometry are set
|
|
|
|
|
* @width: desired width of surface
|
|
|
|
|
* @height: desired height of the surface
|
|
|
|
|
* @new_width: (out): location to store resulting width
|
|
|
|
|
* @new_height: (out): location to store resulting height
|
|
|
|
|
*
|
|
|
|
|
* Constrains a desired width and height according to a
|
|
|
|
|
* set of geometry hints (such as minimum and maximum size).
|
|
|
|
|
*/
|
2001-03-29 21:17:45 +00:00
|
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_constrain_size (GdkGeometry *geometry,
|
2019-04-06 16:36:51 +00:00
|
|
|
|
GdkSurfaceHints flags,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int *new_width,
|
|
|
|
|
int *new_height)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
{
|
|
|
|
|
/* This routine is partially borrowed from fvwm.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1993, Robert Nation
|
|
|
|
|
* You may use this code for any purpose, as long as the original
|
|
|
|
|
* copyright remains in the source code and all documentation
|
|
|
|
|
*
|
|
|
|
|
* which in turn borrows parts of the algorithm from uwm
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int min_width = 0;
|
|
|
|
|
int min_height = 0;
|
|
|
|
|
int max_width = G_MAXINT;
|
|
|
|
|
int max_height = G_MAXINT;
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2020-07-30 02:42:11 +00:00
|
|
|
|
if (flags & GDK_HINT_MIN_SIZE)
|
2019-04-06 16:36:51 +00:00
|
|
|
|
{
|
|
|
|
|
min_width = geometry->min_width;
|
|
|
|
|
min_height = geometry->min_height;
|
|
|
|
|
}
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
if (flags & GDK_HINT_MAX_SIZE)
|
|
|
|
|
{
|
|
|
|
|
max_width = geometry->max_width ;
|
|
|
|
|
max_height = geometry->max_height;
|
|
|
|
|
}
|
2019-03-25 12:33:56 +00:00
|
|
|
|
|
2019-04-06 16:36:51 +00:00
|
|
|
|
/* clamp width and height to min and max values
|
|
|
|
|
*/
|
|
|
|
|
width = CLAMP (width, min_width, max_width);
|
|
|
|
|
height = CLAMP (height, min_height, max_height);
|
|
|
|
|
|
|
|
|
|
*new_width = width;
|
|
|
|
|
*new_height = height;
|
2001-03-29 21:17:45 +00:00
|
|
|
|
}
|
2001-07-05 13:41:34 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
/**
|
2019-03-25 14:12:01 +00:00
|
|
|
|
* gdk_surface_get_device_position:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
* @device: pointer `GdkDevice` to query to
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* @x: (out) (optional): return location for the X coordinate of @device
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @y: (out) (optional): return location for the Y coordinate of @device
|
|
|
|
|
* @mask: (out) (optional): return location for the modifier mask
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Obtains the current device position and modifier state.
|
2019-03-25 14:12:01 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The position is given in coordinates relative to the upper
|
|
|
|
|
* left corner of @surface.
|
2020-08-26 13:01:48 +00:00
|
|
|
|
*
|
|
|
|
|
* Return: %TRUE if the device is over the surface
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2020-08-26 13:01:48 +00:00
|
|
|
|
gboolean
|
2019-03-25 14:12:01 +00:00
|
|
|
|
gdk_surface_get_device_position (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
double *x,
|
|
|
|
|
double *y,
|
|
|
|
|
GdkModifierType *mask)
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double tmp_x, tmp_y;
|
2019-03-25 14:12:01 +00:00
|
|
|
|
GdkModifierType tmp_mask;
|
2020-08-26 13:01:48 +00:00
|
|
|
|
gboolean ret;
|
2019-03-25 14:12:01 +00:00
|
|
|
|
|
2020-08-26 13:01:48 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
|
|
|
|
|
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
|
2019-03-25 14:12:01 +00:00
|
|
|
|
|
2020-08-26 13:01:48 +00:00
|
|
|
|
tmp_x = 0;
|
|
|
|
|
tmp_y = 0;
|
2019-03-25 14:12:01 +00:00
|
|
|
|
tmp_mask = 0;
|
2020-08-26 13:01:48 +00:00
|
|
|
|
|
|
|
|
|
ret = GDK_SURFACE_GET_CLASS (surface)->get_device_state (surface,
|
|
|
|
|
device,
|
|
|
|
|
&tmp_x, &tmp_y,
|
|
|
|
|
&tmp_mask);
|
2019-03-24 19:42:32 +00:00
|
|
|
|
|
2019-03-25 14:12:01 +00:00
|
|
|
|
if (x)
|
|
|
|
|
*x = tmp_x;
|
|
|
|
|
if (y)
|
|
|
|
|
*y = tmp_y;
|
|
|
|
|
if (mask)
|
|
|
|
|
*mask = tmp_mask;
|
2020-08-26 13:01:48 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
2013-07-03 09:52:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 14:27:44 +00:00
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_hide:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Hide the surface.
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* For toplevel surfaces, withdraws them, so they will no longer be
|
|
|
|
|
* known to the window manager; for all surfaces, unmaps them, so
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* they won’t be displayed. Normally done automatically as
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* part of [method@Gtk.Widget.hide].
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_hide (GdkSurface *surface)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
{
|
2019-03-24 19:42:32 +00:00
|
|
|
|
gboolean was_mapped;
|
2008-06-27 14:27:44 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-06-27 14:27:44 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (surface->destroyed)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
gdk_surface_queue_set_is_mapped (surface, FALSE);
|
2017-05-14 19:30:16 +00:00
|
|
|
|
|
|
|
|
|
if (was_mapped)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
2016-10-26 10:21:39 +00:00
|
|
|
|
GdkSeat *seat;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GList *devices, *d;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
/* May need to break grabs on children */
|
2019-06-01 21:55:14 +00:00
|
|
|
|
display = surface->display;
|
2016-10-26 10:21:39 +00:00
|
|
|
|
seat = gdk_display_get_default_seat (display);
|
2020-05-15 01:27:45 +00:00
|
|
|
|
if (seat)
|
|
|
|
|
{
|
2020-07-30 15:52:28 +00:00
|
|
|
|
devices = gdk_seat_get_devices (seat, GDK_SEAT_CAPABILITY_ALL);
|
2020-05-15 01:27:45 +00:00
|
|
|
|
devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat));
|
|
|
|
|
devices = g_list_prepend (devices, gdk_seat_get_pointer (seat));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
devices = NULL;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
for (d = devices; d; d = d->next)
|
|
|
|
|
{
|
|
|
|
|
GdkDevice *device = d->data;
|
|
|
|
|
|
2010-12-13 19:05:59 +00:00
|
|
|
|
if (_gdk_display_end_device_grab (display,
|
|
|
|
|
device,
|
|
|
|
|
_gdk_display_get_next_serial (display),
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
TRUE))
|
2016-10-26 22:06:36 +00:00
|
|
|
|
{
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
gdk_device_ungrab (device, GDK_CURRENT_TIME);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
g_list_free (devices);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->hide (surface);
|
2020-02-19 08:31:32 +00:00
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
|
surface->popup.rect_anchor = 0;
|
|
|
|
|
surface->popup.surface_anchor = 0;
|
2020-02-19 08:31:32 +00:00
|
|
|
|
surface->x = 0;
|
|
|
|
|
surface->y = 0;
|
2008-06-27 14:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_cursor_internal (GdkSurface *surface,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkCursor *cursor)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-06-25 22:47:40 +00:00
|
|
|
|
GdkPointerSurfaceInfo *pointer_info;
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2011-05-03 22:01:10 +00:00
|
|
|
|
return;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
g_assert (surface->display == gdk_device_get_display (device));
|
2019-03-23 13:13:37 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
pointer_info = _gdk_display_get_pointer_info (surface->display, device);
|
2011-05-03 22:01:10 +00:00
|
|
|
|
|
2019-03-23 13:13:37 +00:00
|
|
|
|
if (surface == pointer_info->surface_under_pointer)
|
2019-06-01 21:55:14 +00:00
|
|
|
|
update_cursor (surface->display, device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 06:16:01 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_cursor: (attributes org.gtk.Method.get_property=cursor)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Retrieves a `GdkCursor` pointer for the cursor currently set on the
|
|
|
|
|
* `GdkSurface`.
|
2009-07-16 06:16:01 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* If the return value is %NULL then there is no custom cursor set on
|
|
|
|
|
* the surface, and it is using the cursor for its parent surface.
|
2009-07-16 06:16:01 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Use [method@Gdk.Surface.set_cursor] to unset the cursor of the surface.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): a `GdkCursor`
|
2009-07-16 06:16:01 +00:00
|
|
|
|
*/
|
|
|
|
|
GdkCursor *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_cursor (GdkSurface *surface)
|
2009-07-16 06:16:01 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2009-07-16 06:16:01 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
return surface->cursor;
|
2009-07-16 06:16:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 14:27:44 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_set_cursor: (attributes org.gtk.Method.set_property=cursor)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @cursor: (nullable): a `GdkCursor`
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the default mouse pointer for a `GdkSurface`.
|
2014-10-28 04:44:33 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Passing %NULL for the @cursor argument means that @surface will use
|
|
|
|
|
* the cursor of its parent surface. Most surfaces should use this default.
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Note that @cursor must be for the same display as @surface.
|
2014-10-28 04:44:33 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Use [ctor@Gdk.Cursor.new_from_name] or [ctor@Gdk.Cursor.new_from_texture]
|
|
|
|
|
* to create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_cursor (GdkSurface *surface,
|
2021-02-21 05:13:57 +00:00
|
|
|
|
GdkCursor *cursor)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-06-27 14:27:44 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (surface->cursor)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_object_unref (surface->cursor);
|
|
|
|
|
surface->cursor = NULL;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2015-12-15 22:20:40 +00:00
|
|
|
|
GdkDevice *device;
|
|
|
|
|
GList *seats, *s;
|
2011-05-03 22:01:10 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (cursor)
|
2018-03-21 08:06:31 +00:00
|
|
|
|
surface->cursor = g_object_ref (cursor);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
seats = gdk_display_list_seats (surface->display);
|
2011-05-03 22:01:10 +00:00
|
|
|
|
|
2015-12-15 22:20:40 +00:00
|
|
|
|
for (s = seats; s; s = s->next)
|
2011-05-03 22:01:10 +00:00
|
|
|
|
{
|
2017-07-25 13:37:10 +00:00
|
|
|
|
GList *devices, *d;
|
|
|
|
|
|
2015-12-15 22:20:40 +00:00
|
|
|
|
device = gdk_seat_get_pointer (s->data);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_cursor_internal (surface, device, surface->cursor);
|
2017-07-25 13:37:10 +00:00
|
|
|
|
|
2020-07-30 15:52:28 +00:00
|
|
|
|
devices = gdk_seat_get_devices (s->data, GDK_SEAT_CAPABILITY_TABLET_STYLUS);
|
2017-07-25 13:37:10 +00:00
|
|
|
|
for (d = devices; d; d = d->next)
|
|
|
|
|
{
|
2020-07-30 12:26:51 +00:00
|
|
|
|
device = d->data;
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_cursor_internal (surface, device, surface->cursor);
|
2017-07-25 13:37:10 +00:00
|
|
|
|
}
|
|
|
|
|
g_list_free (devices);
|
2011-05-03 22:01:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-15 22:20:40 +00:00
|
|
|
|
g_list_free (seats);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_CURSOR]);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
2008-06-27 14:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_get_device_cursor:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
* @device: a pointer `GdkDevice`
|
|
|
|
|
*
|
|
|
|
|
* Retrieves a `GdkCursor` pointer for the @device currently set on the
|
|
|
|
|
* specified `GdkSurface`.
|
|
|
|
|
*
|
|
|
|
|
* If the return value is %NULL then there is no custom cursor set on the
|
|
|
|
|
* specified surface, and it is using the cursor for its parent surface.
|
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Use [method@Gdk.Surface.set_cursor] to unset the cursor of the surface.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): a `GdkCursor`
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkCursor *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_device_cursor (GdkSurface *surface,
|
2021-02-21 05:13:57 +00:00
|
|
|
|
GdkDevice *device)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
2010-12-20 22:04:44 +00:00
|
|
|
|
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
return g_hash_table_lookup (surface->device_cursor, device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_set_device_cursor:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
|
|
|
|
* @device: a pointer `GdkDevice`
|
|
|
|
|
* @cursor: a `GdkCursor`
|
|
|
|
|
*
|
|
|
|
|
* Sets a specific `GdkCursor` for a given device when it gets inside @surface.
|
|
|
|
|
*
|
|
|
|
|
* Passing %NULL for the @cursor argument means that @surface will use the
|
|
|
|
|
* cursor of its parent surface. Most surfaces should use this default.
|
|
|
|
|
*
|
|
|
|
|
* Use [ctor@Gdk.Cursor.new_from_name] or [ctor@Gdk.Cursor.new_from_texture]
|
|
|
|
|
* to create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
|
|
|
|
|
*/
|
2010-05-25 22:38:44 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_device_cursor (GdkSurface *surface,
|
2021-02-21 05:13:57 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkCursor *cursor)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-05-26 11:22:25 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
2010-12-20 22:04:44 +00:00
|
|
|
|
g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
if (!cursor)
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_hash_table_remove (surface->device_cursor, device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
else
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_hash_table_replace (surface->device_cursor, device, g_object_ref (cursor));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_cursor_internal (surface, device, cursor);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 18:03:20 +00:00
|
|
|
|
/*
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_get_geometry:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @x: (out) (optional): return location for X coordinate of surface (relative to its parent)
|
|
|
|
|
* @y: (out) (optional): return location for Y coordinate of surface (relative to its parent)
|
|
|
|
|
* @width: (out) (optional): return location for width of surface
|
|
|
|
|
* @height: (out) (optional): return location for height of surface
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Get the geometry of the surface.
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* The X and Y coordinates returned are relative to the parent surface
|
|
|
|
|
* of @surface, which for toplevels usually means relative to the
|
|
|
|
|
* surface decorations (titlebar, etc.) rather than relative to the
|
2008-06-27 14:27:44 +00:00
|
|
|
|
* root window (screen-size background window).
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* On the X11 platform, the geometry is obtained from the X server, so
|
|
|
|
|
* reflects the latest position of @surface; this may be out-of-sync with
|
|
|
|
|
* the position of @surface delivered in the most-recently-processed
|
|
|
|
|
* `GdkEventConfigure`. [method@Gdk.Surface.get_position] in contrast gets
|
|
|
|
|
* the position from the most recent configure event.
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Any of the return location arguments to this function may be %NULL,
|
|
|
|
|
* if you aren’t interested in getting the value of that field.
|
|
|
|
|
*
|
|
|
|
|
* Note: If @surface is not a toplevel, it is much better to call
|
|
|
|
|
* [method@Gdk.Surface.get_position], [method@Gdk.Surface.get_width] and
|
|
|
|
|
* [method@Gdk.Surface.get_height] instead, because it avoids the roundtrip
|
|
|
|
|
* to the X server and because these functions support the full 32-bit
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* coordinate space, whereas gdk_surface_get_geometry() is restricted to
|
2010-09-20 10:53:46 +00:00
|
|
|
|
* the 16-bit coordinates of X11.
|
2014-02-02 06:22:14 +00:00
|
|
|
|
*/
|
2008-06-27 14:27:44 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_geometry (GdkSurface *surface,
|
2021-02-21 05:13:57 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y,
|
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-06-27 14:27:44 +00:00
|
|
|
|
|
2019-03-23 13:13:37 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->get_geometry (surface, x, y, width, height);
|
2008-06-27 14:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-20 09:10:37 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_width: (attributes org.gtk.Method.get_property=width)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Returns the width of the given @surface.
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*
|
2020-04-13 13:29:11 +00:00
|
|
|
|
* Surface size is reported in ”application pixels”, not
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* ”device pixels” (see [method@Gdk.Surface.get_scale_factor]).
|
2010-09-28 00:59:08 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Returns: The width of @surface
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*/
|
|
|
|
|
int
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_width (GdkSurface *surface)
|
2010-09-20 09:10:37 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), 0);
|
2010-09-20 09:10:37 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
return surface->width;
|
2010-09-20 09:10:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_height: (attributes org.gtk.Method.get_property=height)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Returns the height of the given @surface.
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*
|
2020-04-13 13:29:11 +00:00
|
|
|
|
* Surface size is reported in ”application pixels”, not
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* ”device pixels” (see [method@Gdk.Surface.get_scale_factor]).
|
2010-09-28 00:59:08 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Returns: The height of @surface
|
2010-09-20 09:10:37 +00:00
|
|
|
|
*/
|
|
|
|
|
int
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_height (GdkSurface *surface)
|
2010-09-20 09:10:37 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), 0);
|
2010-09-20 09:10:37 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
return surface->height;
|
2010-09-20 09:10:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 06:05:40 +00:00
|
|
|
|
/*
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_get_origin:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2019-05-29 06:05:40 +00:00
|
|
|
|
* @x: (out): return location for X coordinate
|
|
|
|
|
* @y: (out): return location for Y coordinate
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Obtains the position of a surface in root window coordinates.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* (Compare with gdk_surface_get_position() and
|
2019-05-29 06:05:40 +00:00
|
|
|
|
* gdk_surface_get_geometry() which return the position
|
|
|
|
|
* of a surface relative to its parent surface.)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
*/
|
2019-05-29 06:05:40 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_origin (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2008-06-27 14:27:44 +00:00
|
|
|
|
{
|
2019-05-29 06:05:40 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-06-27 14:27:44 +00:00
|
|
|
|
|
2019-05-29 06:05:40 +00:00
|
|
|
|
gdk_surface_get_root_coords (surface, 0, 0, x, y);
|
2009-06-08 15:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 06:05:40 +00:00
|
|
|
|
/*
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_get_root_coords:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* @x: X coordinate in surface
|
|
|
|
|
* @y: Y coordinate in surface
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* @root_x: (out): return location for X coordinate
|
|
|
|
|
* @root_y: (out): return location for Y coordinate
|
2009-06-08 15:03:47 +00:00
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* Obtains the position of a surface position in root
|
2009-06-08 15:03:47 +00:00
|
|
|
|
* window coordinates. This is similar to
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_get_origin() but allows you to pass
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* in any position in the surface, not just the origin.
|
2009-06-08 15:03:47 +00:00
|
|
|
|
*/
|
2009-06-30 07:30:53 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_root_coords (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int *root_x,
|
|
|
|
|
int *root_y)
|
2009-06-08 15:03:47 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2009-06-08 15:03:47 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2009-06-30 07:30:53 +00:00
|
|
|
|
{
|
2011-09-28 22:16:30 +00:00
|
|
|
|
*root_x = 0;
|
|
|
|
|
*root_y = 0;
|
2009-06-30 07:30:53 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-07 18:22:10 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->get_root_coords (surface, x, y, root_x, root_y);
|
2008-06-27 14:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-17 10:24:46 +00:00
|
|
|
|
/**
|
2020-03-01 19:29:06 +00:00
|
|
|
|
* gdk_surface_set_input_region:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2020-03-01 19:29:06 +00:00
|
|
|
|
* @region: region of surface to be reactive
|
2009-06-01 10:04:36 +00:00
|
|
|
|
*
|
2019-12-05 13:57:19 +00:00
|
|
|
|
* Apply the region to the surface for the purpose of event
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* handling.
|
2008-12-17 10:24:46 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Mouse events which happen while the pointer position corresponds
|
|
|
|
|
* to an unset bit in the mask will be passed on the surface below
|
|
|
|
|
* @surface.
|
2008-12-17 10:24:46 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* An input region is typically used with RGBA surfaces. The alpha
|
|
|
|
|
* channel of the surface defines which pixels are invisible and
|
|
|
|
|
* allows for nicely antialiased borders, and the input region
|
|
|
|
|
* controls where the surface is “clickable”.
|
|
|
|
|
*
|
|
|
|
|
* Use [method@Gdk.Display.supports_input_shapes] to find out if
|
2020-05-18 01:46:54 +00:00
|
|
|
|
* a particular backend supports input regions.
|
2008-12-17 10:24:46 +00:00
|
|
|
|
*/
|
2009-06-01 10:04:36 +00:00
|
|
|
|
void
|
2020-03-01 19:29:06 +00:00
|
|
|
|
gdk_surface_set_input_region (GdkSurface *surface,
|
|
|
|
|
cairo_region_t *region)
|
2008-12-17 10:24:46 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2008-12-17 10:24:46 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2008-12-17 10:24:46 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-20 14:55:27 +00:00
|
|
|
|
if (cairo_region_equal (surface->input_region, region))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-03-01 19:29:06 +00:00
|
|
|
|
if (surface->input_region)
|
|
|
|
|
cairo_region_destroy (surface->input_region);
|
2008-12-17 10:24:46 +00:00
|
|
|
|
|
2020-03-01 19:29:06 +00:00
|
|
|
|
if (region)
|
|
|
|
|
surface->input_region = cairo_region_copy (region);
|
2008-12-17 10:24:46 +00:00
|
|
|
|
else
|
2020-03-01 19:29:06 +00:00
|
|
|
|
surface->input_region = NULL;
|
2008-12-17 10:24:46 +00:00
|
|
|
|
|
2020-03-01 19:29:06 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->set_input_region (surface, surface->input_region);
|
2008-12-17 10:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-08 13:57:59 +00:00
|
|
|
|
static void
|
2010-05-25 22:38:44 +00:00
|
|
|
|
update_cursor (GdkDisplay *display,
|
|
|
|
|
GdkDevice *device)
|
2009-06-08 13:57:59 +00:00
|
|
|
|
{
|
2019-03-23 13:13:37 +00:00
|
|
|
|
GdkSurface *cursor_surface;
|
2018-03-20 14:14:10 +00:00
|
|
|
|
GdkSurface *pointer_surface;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GdkPointerSurfaceInfo *pointer_info;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDeviceGrabInfo *grab;
|
2010-08-17 13:39:03 +00:00
|
|
|
|
GdkCursor *cursor;
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
2020-10-15 16:51:51 +00:00
|
|
|
|
g_assert (display);
|
|
|
|
|
g_assert (device);
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
pointer_info = _gdk_display_get_pointer_info (display, device);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
pointer_surface = pointer_info->surface_under_pointer;
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
|
|
|
|
/* We ignore the serials here and just pick the last grab
|
|
|
|
|
we've sent, as that would shortly be used anyway. */
|
2010-05-25 22:38:44 +00:00
|
|
|
|
grab = _gdk_display_get_last_device_grab (display, device);
|
2019-03-23 13:13:37 +00:00
|
|
|
|
if (grab != NULL)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
/* use the cursor from the grab surface */
|
|
|
|
|
cursor_surface = grab->surface;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2009-09-08 09:48:20 +00:00
|
|
|
|
else
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
/* otherwise use the cursor from the pointer surface */
|
|
|
|
|
cursor_surface = pointer_surface;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2009-09-08 09:48:20 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
cursor = g_hash_table_lookup (cursor_surface->device_cursor, device);
|
2010-08-17 13:39:03 +00:00
|
|
|
|
|
|
|
|
|
if (!cursor)
|
2018-03-20 14:14:10 +00:00
|
|
|
|
cursor = cursor_surface->cursor;
|
2010-08-17 13:39:03 +00:00
|
|
|
|
|
2019-03-23 13:13:37 +00:00
|
|
|
|
GDK_DEVICE_GET_CLASS (device)->set_surface_cursor (device, pointer_surface, cursor);
|
2009-06-08 13:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 20:11:48 +00:00
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_beep:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a toplevel `GdkSurface`
|
|
|
|
|
*
|
|
|
|
|
* Emits a short beep associated to @surface.
|
2009-06-11 20:11:48 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* If the display of @surface does not support per-surface beeps,
|
|
|
|
|
* emits a short beep on the display just as [method@Gdk.Display.beep].
|
|
|
|
|
*/
|
2009-06-11 20:11:48 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_beep (GdkSurface *surface)
|
2009-06-11 20:11:48 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2009-06-11 20:11:48 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2009-06-11 20:11:48 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
if (GDK_SURFACE_GET_CLASS (surface)->beep (surface))
|
2019-03-23 13:13:37 +00:00
|
|
|
|
return;
|
2018-03-21 08:06:31 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
gdk_display_beep (surface->display);
|
2009-06-11 20:11:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 13:02:52 +00:00
|
|
|
|
void
|
2018-03-20 11:05:26 +00:00
|
|
|
|
_gdk_display_set_surface_under_pointer (GdkDisplay *display,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkSurface *surface)
|
2008-12-15 09:24:54 +00:00
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GdkPointerSurfaceInfo *device_info;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
device_info = _gdk_display_get_pointer_info (display, device);
|
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
if (device_info->surface_under_pointer)
|
|
|
|
|
g_object_unref (device_info->surface_under_pointer);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
device_info->surface_under_pointer = surface;
|
2008-12-15 13:02:52 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (surface)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_object_ref (surface);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
update_cursor (display, device);
|
|
|
|
|
}
|
2008-12-15 09:24:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-02 13:57:08 +00:00
|
|
|
|
#define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \
|
2018-03-21 08:06:31 +00:00
|
|
|
|
GDK_BUTTON2_MASK | \
|
|
|
|
|
GDK_BUTTON3_MASK | \
|
|
|
|
|
GDK_BUTTON4_MASK | \
|
|
|
|
|
GDK_BUTTON5_MASK)
|
2009-02-02 13:57:08 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_windowing_got_event (GdkDisplay *display,
|
2012-02-24 03:20:07 +00:00
|
|
|
|
GList *event_link,
|
|
|
|
|
GdkEvent *event,
|
|
|
|
|
gulong serial)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2022-01-26 14:49:29 +00:00
|
|
|
|
GdkSurface *event_surface = NULL;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
gboolean unlink_event = FALSE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDeviceGrabInfo *button_release_grab;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GdkPointerSurfaceInfo *pointer_info = NULL;
|
2020-07-28 22:03:48 +00:00
|
|
|
|
GdkDevice *device;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventType type;
|
2021-03-26 02:39:15 +00:00
|
|
|
|
guint32 timestamp;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2016-02-28 15:22:31 +00:00
|
|
|
|
_gdk_display_update_last_event (display, event);
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
device = gdk_event_get_device (event);
|
2021-03-26 02:39:15 +00:00
|
|
|
|
timestamp = gdk_event_get_time (event);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
|
{
|
2021-03-26 02:39:15 +00:00
|
|
|
|
if (timestamp != GDK_CURRENT_TIME)
|
|
|
|
|
gdk_device_set_timestamp (device, timestamp);
|
|
|
|
|
|
2016-08-04 17:10:21 +00:00
|
|
|
|
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD &&
|
|
|
|
|
gdk_device_get_source (device) != GDK_SOURCE_TABLET_PAD)
|
2011-12-03 14:04:19 +00:00
|
|
|
|
{
|
2011-12-06 19:29:22 +00:00
|
|
|
|
pointer_info = _gdk_display_get_pointer_info (display, device);
|
2020-07-28 22:03:48 +00:00
|
|
|
|
pointer_info->last_physical_device = device;
|
2011-12-03 14:04:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 21:00:02 +00:00
|
|
|
|
_gdk_display_device_grab_update (display, device, serial);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event_surface = gdk_event_get_surface (event);
|
2018-03-20 11:05:26 +00:00
|
|
|
|
if (!event_surface)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
goto out;
|
2009-06-01 10:04:36 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
type = gdk_event_get_event_type (event);
|
|
|
|
|
if (type == GDK_ENTER_NOTIFY)
|
2018-03-20 11:05:26 +00:00
|
|
|
|
_gdk_display_set_surface_under_pointer (display, device, event_surface);
|
2020-02-18 03:11:56 +00:00
|
|
|
|
else if (type == GDK_LEAVE_NOTIFY)
|
2018-03-20 11:05:26 +00:00
|
|
|
|
_gdk_display_set_surface_under_pointer (display, device, NULL);
|
2009-01-31 18:42:44 +00:00
|
|
|
|
|
2020-05-12 08:19:47 +00:00
|
|
|
|
if (type == GDK_BUTTON_PRESS)
|
|
|
|
|
{
|
|
|
|
|
GdkSurface *grab_surface;
|
|
|
|
|
gboolean owner_events;
|
|
|
|
|
|
|
|
|
|
if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events))
|
|
|
|
|
{
|
|
|
|
|
_gdk_display_add_device_grab (display,
|
|
|
|
|
device,
|
|
|
|
|
event_surface,
|
|
|
|
|
FALSE,
|
|
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
|
serial,
|
|
|
|
|
gdk_event_get_time (event),
|
|
|
|
|
TRUE);
|
2020-07-28 21:00:02 +00:00
|
|
|
|
_gdk_display_device_grab_update (display, device, serial);
|
2020-05-12 08:19:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (type == GDK_BUTTON_RELEASE ||
|
|
|
|
|
type == GDK_TOUCH_CANCEL ||
|
|
|
|
|
type == GDK_TOUCH_END)
|
2009-01-31 18:42:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (type == GDK_BUTTON_RELEASE ||
|
2016-05-10 19:16:45 +00:00
|
|
|
|
gdk_event_get_pointer_emulated (event))
|
2012-02-24 03:20:07 +00:00
|
|
|
|
{
|
2011-12-28 23:06:45 +00:00
|
|
|
|
button_release_grab =
|
|
|
|
|
_gdk_display_has_device_grab (display, device, serial);
|
|
|
|
|
|
|
|
|
|
if (button_release_grab &&
|
|
|
|
|
button_release_grab->implicit &&
|
2020-02-18 03:11:56 +00:00
|
|
|
|
(gdk_event_get_modifier_state (event) & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (gdk_button_event_get_button (event) - 1))) == 0)
|
2011-12-28 23:06:45 +00:00
|
|
|
|
{
|
|
|
|
|
button_release_grab->serial_end = serial;
|
|
|
|
|
button_release_grab->implicit_ungrab = FALSE;
|
2020-07-28 21:00:02 +00:00
|
|
|
|
_gdk_display_device_grab_update (display, device, serial);
|
2011-12-28 23:06:45 +00:00
|
|
|
|
}
|
2012-02-24 03:20:07 +00:00
|
|
|
|
}
|
2009-01-31 18:42:44 +00:00
|
|
|
|
}
|
2008-12-09 12:35:46 +00:00
|
|
|
|
|
2009-02-03 19:15:19 +00:00
|
|
|
|
out:
|
2008-12-09 12:35:46 +00:00
|
|
|
|
if (unlink_event)
|
|
|
|
|
{
|
|
|
|
|
_gdk_event_queue_remove_link (display, event_link);
|
|
|
|
|
g_list_free_1 (event_link);
|
2020-02-15 20:07:24 +00:00
|
|
|
|
gdk_event_unref (event);
|
2008-12-09 12:35:46 +00:00
|
|
|
|
}
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
|
|
/* This does two things - first it sees if there are motions at the
|
|
|
|
|
* end of the queue that can be compressed. Second, if there is just
|
|
|
|
|
* a single motion that won't be dispatched because it is a compression
|
|
|
|
|
* candidate it queues up flushing the event queue.
|
|
|
|
|
*/
|
|
|
|
|
_gdk_event_queue_handle_motion_compression (display);
|
2020-06-08 22:07:40 +00:00
|
|
|
|
gdk_event_queue_handle_scroll_compression (display);
|
2022-01-26 14:49:29 +00:00
|
|
|
|
|
|
|
|
|
if (event_surface)
|
|
|
|
|
{
|
|
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (event_surface);
|
|
|
|
|
|
|
|
|
|
if (clock) /* might be NULL if surface was destroyed */
|
|
|
|
|
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
|
|
|
|
}
|
Bug 318807 – Offscreen windows and window redirection.
2008-03-18 10:49:20 Tim Janik <timj@imendio.com>
* Applied pixmap redirection patch by Alexander Larsson with
various updates from:
Bug 318807 – Offscreen windows and window redirection.
Updates:
* updated docs to mention "Since 2.16".
* tests/testgtk.c: fixed snapshooting pixmap leak.
convert pixmap to pixbuf after snapshooting, to compensate for different
bit depths (occurs when snapshooting ARGB visuals and displaying the
pixmap in an RGB visual).
* gdk/gdkwindow.[hc]: made GdkWindowRedirect private.
* gdk/gdkwindow.c: removed damage idle handler, there's no aparent
need for it. enqueue damage notification as GDK_DAMAGE events
for each painting redirection at the start of the event queue.
consider windows with a redirection fully visible when invalidating,
and when updating from backing store. cleaned up stale variables.
* gdk/gdkevents.c: added _gdk_event_queue_prepend().
* gtk/gtkwidget.c: fixed coordinates for !NO_WINDOW widgets in
gtk_widget_get_snapshot; this fixes garbage snap offsets for gammacurve,
tree, drawingarea, text, handlebox, etc.
clip the redirected window hierarchy to window sizes, the visible
rectangles don't need to be taken into account here.
extended snapshooting docs to recommend gdk_pixbuf_get_from_drawable()
in case pixmap visuals could mismatch.
* gdk/x11/gdkwindow-x11.c: removed _gdk_windowing_window_get_visible_rect().
Base patch:
* tests/testgtk.c: add a "Snapshot" test to demonstrate snapshooting
of possibly obscured widgets into an offscreen pixmap.
* gtk/gtkwidget.[hc]: add GtkWidget::damage-event signal, add
gtk_widget_get_snapshot() to render a widget's contents to a GdkPixmap.
* gtk/gtkmain.c: dispatch GDK_DAMAGE events.
* gdk/gdkwindow.c: moved outer gdk_window_new() and gdk_window_reparent()
implementations here, adapted them to propagate redirects to child windows.
gdk_window_end_paint(): copy repainted window contents to redirection pixmap,
clipped to visible region. queue GDK_DAMAGE event delivery.
gdk_window_redirect_to_drawable(): install window painting redirection.
gdk_window_remove_redirection(): remove previously installed redirection.
* gdk/x11/gdkwindow-x11.c: added _gdk_windowing_window_get_visible_rect(),
renamed _gdk_window_new() and _gdk_window_reparent().
* gdk/gdkwindow.h: added GdkWindowRedirect* to GdkWindowObject, export
gdk_window_redirect_to_drawable() and gdk_window_remove_redirection().
* gdk/gdkevents.h: added GDK_DAMAGE event type.
* gdk/gdkevents.c: extract time and state from GDK_DAMAGE events.
* gdk/gdkinternals.h: added internal prototypes.
svn path=/trunk/; revision=20122
2008-05-21 19:04:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-12 21:43:11 +00:00
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_create_similar_surface:
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* @surface: surface to make new surface similar to
|
2010-08-12 21:43:11 +00:00
|
|
|
|
* @content: the content for the new surface
|
|
|
|
|
* @width: width of the new surface
|
|
|
|
|
* @height: height of the new surface
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Create a new Cairo surface that is as compatible as possible with the
|
|
|
|
|
* given @surface.
|
|
|
|
|
*
|
|
|
|
|
* For example the new surface will have the same fallback resolution
|
|
|
|
|
* and font options as @surface. Generally, the new surface will also
|
|
|
|
|
* use the same backend as @surface, unless that is not possible for
|
|
|
|
|
* some reason. The type of the returned surface may be examined with
|
|
|
|
|
* cairo_surface_get_type().
|
2010-08-12 21:43:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Initially the surface contents are all 0 (transparent if contents
|
|
|
|
|
* have transparency, black otherwise.)
|
|
|
|
|
*
|
|
|
|
|
* This function always returns a valid pointer, but it will return a
|
2014-02-05 19:50:22 +00:00
|
|
|
|
* pointer to a “nil” surface if @other is already in an error state
|
2010-08-12 21:43:11 +00:00
|
|
|
|
* or any other error occurs.
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: a pointer to the newly allocated surface. The caller
|
|
|
|
|
* owns the surface and should call cairo_surface_destroy() when done
|
|
|
|
|
* with it.
|
2023-04-02 03:09:19 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 4.12: Create a suitable cairo image surface yourself
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*/
|
2010-08-12 21:43:11 +00:00
|
|
|
|
cairo_surface_t *
|
2023-04-01 18:51:11 +00:00
|
|
|
|
gdk_surface_create_similar_surface (GdkSurface *surface,
|
|
|
|
|
cairo_content_t content,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-08-12 21:43:11 +00:00
|
|
|
|
{
|
2018-04-14 20:45:33 +00:00
|
|
|
|
cairo_surface_t *similar_surface;
|
|
|
|
|
int scale;
|
2010-08-12 21:43:11 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2013-06-04 08:41:44 +00:00
|
|
|
|
|
2018-04-14 20:45:33 +00:00
|
|
|
|
scale = gdk_surface_get_scale_factor (surface);
|
2013-06-04 08:41:44 +00:00
|
|
|
|
|
2018-04-14 20:45:33 +00:00
|
|
|
|
similar_surface = cairo_image_surface_create (content == CAIRO_CONTENT_COLOR ? CAIRO_FORMAT_RGB24 :
|
|
|
|
|
content == CAIRO_CONTENT_ALPHA ? CAIRO_FORMAT_A8 : CAIRO_FORMAT_ARGB32,
|
|
|
|
|
width * scale, height * scale);
|
|
|
|
|
cairo_surface_set_device_scale (similar_surface, scale, scale);
|
2010-08-12 21:43:11 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
return similar_surface;
|
2010-08-12 21:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-05 20:58:23 +00:00
|
|
|
|
/* This function is called when the XWindow is really gone.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_destroy_notify (GdkSurface *surface)
|
2010-12-05 20:58:23 +00:00
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GDK_SURFACE_GET_CLASS (surface)->destroy_notify (surface);
|
2010-12-05 20:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 06:27:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_drag_begin:
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* @surface: the source surface for this drag
|
2015-12-07 18:47:45 +00:00
|
|
|
|
* @device: the device that controls this drag
|
2017-12-13 14:03:53 +00:00
|
|
|
|
* @content: (transfer none): the offered content
|
2017-12-11 00:45:31 +00:00
|
|
|
|
* @actions: the actions supported by this drag
|
2017-12-10 23:55:56 +00:00
|
|
|
|
* @dx: the x offset to @device's position where the drag nominally started
|
|
|
|
|
* @dy: the y offset to @device's position where the drag nominally started
|
2015-12-07 18:47:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Starts a drag and creates a new drag context for it.
|
|
|
|
|
*
|
2020-01-07 07:15:22 +00:00
|
|
|
|
* This function is called by the drag source. After this call, you
|
|
|
|
|
* probably want to set up the drag icon using the surface returned
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* by [method@Gdk.Drag.get_drag_surface].
|
2020-01-07 07:15:22 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* This function returns a reference to the [class@Gdk.Drag] object,
|
|
|
|
|
* but GTK keeps its own reference as well, as long as the DND operation
|
|
|
|
|
* is going on.
|
2020-02-22 23:50:28 +00:00
|
|
|
|
*
|
2020-01-07 07:15:22 +00:00
|
|
|
|
* Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* the [signal@Gdk.Drag::dnd-finished] signal and delete the data at
|
|
|
|
|
* the source if [method@Gdk.Drag.get_selected_action] returns
|
|
|
|
|
* %GDK_ACTION_MOVE.
|
2015-12-07 18:47:45 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (transfer full) (nullable): a newly created `GdkDrag`
|
2015-12-07 18:47:45 +00:00
|
|
|
|
*/
|
2018-06-29 17:34:14 +00:00
|
|
|
|
GdkDrag *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_drag_begin (GdkSurface *surface,
|
2017-12-13 14:03:53 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkContentProvider *content,
|
|
|
|
|
GdkDragAction actions,
|
2020-05-17 21:49:02 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy)
|
2017-12-13 14:03:53 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2017-12-13 14:03:53 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
2019-06-01 21:55:14 +00:00
|
|
|
|
g_return_val_if_fail (surface->display == gdk_device_get_display (device), NULL);
|
2017-12-13 14:03:53 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_CONTENT_PROVIDER (content), NULL);
|
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
return GDK_SURFACE_GET_CLASS (surface)->drag_begin (surface, device, content, actions, dx, dy);
|
2010-12-10 06:27:10 +00:00
|
|
|
|
}
|
2010-12-16 06:21:49 +00:00
|
|
|
|
|
2020-02-21 21:38:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_surface_ensure_motion (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
GdkDevice *device;
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
double x, y;
|
|
|
|
|
GdkModifierType state;
|
2021-04-22 23:51:17 +00:00
|
|
|
|
GdkSurface *grab_surface;
|
2020-02-21 21:38:36 +00:00
|
|
|
|
|
|
|
|
|
if (!surface->request_motion)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
surface->request_motion = FALSE;
|
|
|
|
|
|
|
|
|
|
display = gdk_surface_get_display (surface);
|
|
|
|
|
seat = gdk_display_get_default_seat (display);
|
|
|
|
|
if (!seat)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
device = gdk_seat_get_pointer (seat);
|
|
|
|
|
|
|
|
|
|
if (!gdk_surface_get_device_position (surface, device, &x, &y, &state))
|
|
|
|
|
return;
|
|
|
|
|
|
2021-04-22 23:51:17 +00:00
|
|
|
|
if (gdk_device_grab_info (display, device, &grab_surface, NULL))
|
|
|
|
|
{
|
|
|
|
|
if (grab_surface != surface)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 21:38:36 +00:00
|
|
|
|
event = gdk_motion_event_new (surface,
|
|
|
|
|
device,
|
|
|
|
|
NULL,
|
|
|
|
|
GDK_CURRENT_TIME,
|
|
|
|
|
state,
|
|
|
|
|
x, y,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gdk_surface_handle_event (event);
|
|
|
|
|
gdk_event_unref (event);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-26 14:28:06 +00:00
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_flush_events (GdkFrameClock *clock,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
void *data)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
{
|
2019-06-01 21:55:14 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
2019-06-01 21:55:14 +00:00
|
|
|
|
_gdk_event_queue_flush (surface->display);
|
2020-02-21 21:38:36 +00:00
|
|
|
|
gdk_surface_ensure_motion (surface);
|
2019-06-01 21:55:14 +00:00
|
|
|
|
_gdk_display_pause_events (surface->display);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
|
|
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_RESUME_EVENTS);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface->frame_clock_events_paused = TRUE;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_resume_events (GdkFrameClock *clock,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
void *data)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
{
|
2019-06-01 21:55:14 +00:00
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
2019-12-29 18:31:36 +00:00
|
|
|
|
if (surface->frame_clock_events_paused)
|
|
|
|
|
{
|
|
|
|
|
_gdk_display_unpause_events (surface->display);
|
|
|
|
|
surface->frame_clock_events_paused = FALSE;
|
|
|
|
|
}
|
2012-09-26 14:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-20 21:26:49 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_frame_clock (GdkSurface *surface,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
GdkFrameClock *clock)
|
2012-10-03 22:34:01 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2012-10-03 22:34:01 +00:00
|
|
|
|
g_return_if_fail (clock == NULL || GDK_IS_FRAME_CLOCK (clock));
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (clock == surface->frame_clock)
|
2012-10-03 22:34:01 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (clock)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (clock);
|
2019-06-28 18:54:16 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (clock),
|
|
|
|
|
"flush-events",
|
|
|
|
|
G_CALLBACK (gdk_surface_flush_events),
|
|
|
|
|
surface);
|
|
|
|
|
g_signal_connect (G_OBJECT (clock),
|
|
|
|
|
"resume-events",
|
|
|
|
|
G_CALLBACK (gdk_surface_resume_events),
|
|
|
|
|
surface);
|
2020-11-24 21:02:53 +00:00
|
|
|
|
g_signal_connect (G_OBJECT (clock),
|
|
|
|
|
"layout",
|
|
|
|
|
G_CALLBACK (gdk_surface_layout_on_clock),
|
|
|
|
|
surface);
|
2019-06-28 18:54:16 +00:00
|
|
|
|
g_signal_connect (G_OBJECT (clock),
|
|
|
|
|
"paint",
|
|
|
|
|
G_CALLBACK (gdk_surface_paint_on_clock),
|
|
|
|
|
surface);
|
2019-06-28 16:45:44 +00:00
|
|
|
|
|
|
|
|
|
if (surface->update_freeze_count == 0)
|
|
|
|
|
_gdk_frame_clock_inhibit_freeze (clock);
|
2012-10-03 22:34:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (surface->frame_clock)
|
2012-10-03 22:34:01 +00:00
|
|
|
|
{
|
2019-06-28 18:54:16 +00:00
|
|
|
|
if (surface->frame_clock_events_paused)
|
|
|
|
|
gdk_surface_resume_events (surface->frame_clock, G_OBJECT (surface));
|
|
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (surface->frame_clock),
|
|
|
|
|
G_CALLBACK (gdk_surface_flush_events),
|
|
|
|
|
surface);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (surface->frame_clock),
|
|
|
|
|
G_CALLBACK (gdk_surface_resume_events),
|
|
|
|
|
surface);
|
2020-11-24 21:02:53 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (surface->frame_clock),
|
|
|
|
|
G_CALLBACK (gdk_surface_layout_on_clock),
|
|
|
|
|
surface);
|
2019-06-28 18:54:16 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (surface->frame_clock),
|
|
|
|
|
G_CALLBACK (gdk_surface_paint_on_clock),
|
|
|
|
|
surface);
|
2019-06-28 16:45:44 +00:00
|
|
|
|
|
|
|
|
|
if (surface->update_freeze_count == 0)
|
|
|
|
|
_gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_object_unref (surface->frame_clock);
|
2012-10-03 22:34:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface->frame_clock = clock;
|
2012-10-03 22:34:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_frame_clock: (attributes org.gtk.Method.get_property=frame-clock)
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* @surface: surface to get frame clock for
|
2012-10-03 22:34:01 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Gets the frame clock for the surface.
|
|
|
|
|
*
|
|
|
|
|
* The frame clock for a surface never changes unless the surface is
|
|
|
|
|
* reparented to a new toplevel surface.
|
2012-10-03 22:34:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the frame clock
|
2012-10-03 22:34:01 +00:00
|
|
|
|
*/
|
2021-02-21 05:13:57 +00:00
|
|
|
|
GdkFrameClock *
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_frame_clock (GdkSurface *surface)
|
2012-10-03 22:34:01 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2012-10-03 22:34:01 +00:00
|
|
|
|
|
2019-03-22 18:24:39 +00:00
|
|
|
|
return surface->frame_clock;
|
2012-10-03 22:34:01 +00:00
|
|
|
|
}
|
2013-01-18 14:47:29 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:20 +00:00
|
|
|
|
* gdk_surface_get_scale_factor: (attributes org.gtk.Method.get_property=scale-factor)
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* @surface: surface to get scale factor for
|
2013-01-18 14:47:29 +00:00
|
|
|
|
*
|
2020-05-28 08:00:03 +00:00
|
|
|
|
* Returns the internal scale factor that maps from surface coordinates
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* to the actual device pixels.
|
2013-01-18 14:47:29 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* On traditional systems this is 1, but on very high density outputs
|
|
|
|
|
* this can be a higher value (often 2). A higher value means that drawing
|
|
|
|
|
* is automatically scaled up to a higher resolution, so any code doing
|
|
|
|
|
* drawing will automatically look nicer. However, if you are supplying
|
|
|
|
|
* pixel-based data the scale value can be used to determine whether to
|
|
|
|
|
* use a pixel resource with higher resolution data.
|
2013-01-18 14:47:29 +00:00
|
|
|
|
*
|
2023-04-02 17:17:36 +00:00
|
|
|
|
* The scale factor may change during the lifetime of the surface.
|
2013-01-18 14:47:29 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the scale factor
|
2013-01-18 14:47:29 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_get_scale_factor (GdkSurface *surface)
|
2013-01-18 14:47:29 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), 1);
|
2013-01-18 14:47:29 +00:00
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
return (int) ceil (gdk_surface_get_scale (surface));
|
|
|
|
|
}
|
2013-01-18 14:47:29 +00:00
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_surface_get_scale: (attributes org.gtk.Method.get_property=scale)
|
|
|
|
|
* @surface: surface to get scale for
|
|
|
|
|
*
|
|
|
|
|
* Returns the internal scale that maps from surface coordinates
|
|
|
|
|
* to the actual device pixels.
|
|
|
|
|
*
|
2023-04-02 17:17:36 +00:00
|
|
|
|
* When the scale is bigger than 1, the windowing system prefers to get
|
|
|
|
|
* buffers with a resolution that is bigger than the surface size (e.g.
|
|
|
|
|
* to show the surface on a high-resolution display, or in a magnifier).
|
|
|
|
|
*
|
|
|
|
|
* Compare with [method@Gdk.Surface.get_scale_factor], which returns the
|
|
|
|
|
* next larger integer.
|
|
|
|
|
*
|
2023-04-01 18:51:11 +00:00
|
|
|
|
* The scale may change during the lifetime of the surface.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scale
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.12
|
|
|
|
|
*/
|
|
|
|
|
double
|
|
|
|
|
gdk_surface_get_scale (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), 1.);
|
|
|
|
|
|
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
|
return 1.;
|
2013-01-18 14:47:29 +00:00
|
|
|
|
|
2023-04-01 18:51:11 +00:00
|
|
|
|
return GDK_SURFACE_GET_CLASS (surface)->get_scale (surface);
|
2013-01-18 14:47:29 +00:00
|
|
|
|
}
|
2013-05-14 20:23:33 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* gdk_surface_set_opaque_region:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a top-level `GdkSurface`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @region: (nullable): a region, or %NULL to make the entire
|
|
|
|
|
* surface opaque
|
2013-05-14 20:23:33 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Marks a region of the `GdkSurface` as opaque.
|
|
|
|
|
*
|
2015-04-18 16:54:45 +00:00
|
|
|
|
* For optimisation purposes, compositing window managers may
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* like to not draw obscured regions of surfaces, or turn off blending
|
2013-05-14 20:23:33 +00:00
|
|
|
|
* during for these regions. With RGB windows with no transparency,
|
|
|
|
|
* this is just the shape of the window, but with ARGB32 windows, the
|
|
|
|
|
* compositor does not know what regions of the window are transparent
|
|
|
|
|
* or not.
|
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* This function only works for toplevel surfaces.
|
2013-05-14 20:23:33 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* GTK will update this property automatically if the @surface background
|
|
|
|
|
* is opaque, as we know where the opaque regions are. If your surface
|
|
|
|
|
* background is not opaque, please update this property in your
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* [vfunc@Gtk.Widget.css_changed] handler.
|
2013-05-14 20:23:33 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_opaque_region (GdkSurface *surface,
|
2018-03-21 08:06:31 +00:00
|
|
|
|
cairo_region_t *region)
|
2013-05-14 20:23:33 +00:00
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
|
GdkSurfaceClass *class;
|
2013-05-14 20:23:33 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
|
|
|
|
g_return_if_fail (!GDK_SURFACE_DESTROYED (surface));
|
2013-05-14 20:23:33 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (cairo_region_equal (surface->opaque_region, region))
|
2017-08-18 10:01:54 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_clear_pointer (&surface->opaque_region, cairo_region_destroy);
|
2017-08-18 10:01:54 +00:00
|
|
|
|
|
|
|
|
|
if (region != NULL)
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface->opaque_region = cairo_region_reference (region);
|
2017-08-18 10:01:54 +00:00
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
|
class = GDK_SURFACE_GET_CLASS (surface);
|
|
|
|
|
if (class->set_opaque_region)
|
|
|
|
|
class->set_opaque_region (surface, region);
|
2013-05-14 20:23:33 +00:00
|
|
|
|
}
|
2013-12-13 03:38:12 +00:00
|
|
|
|
|
2017-12-15 03:35:27 +00:00
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_state (GdkSurface *surface,
|
2020-09-10 04:39:03 +00:00
|
|
|
|
GdkToplevelState new_state)
|
2017-12-15 03:35:27 +00:00
|
|
|
|
{
|
2020-02-29 15:07:43 +00:00
|
|
|
|
gboolean was_sticky, sticky;
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2017-12-15 03:35:27 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (new_state == surface->state)
|
2017-12-15 03:35:27 +00:00
|
|
|
|
return; /* No actual work to do, nothing changed. */
|
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
|
/* Actually update the field in GdkSurface, this is sort of an odd
|
2017-12-15 03:35:27 +00:00
|
|
|
|
* place to do it, but seems like the safest since it ensures we expose no
|
|
|
|
|
* inconsistent state to the user.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
was_sticky = GDK_SURFACE_IS_STICKY (surface);
|
2018-07-15 18:23:54 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface->state = new_state;
|
2017-12-15 03:35:27 +00:00
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
sticky = GDK_SURFACE_IS_STICKY (surface);
|
2018-07-15 18:23:54 +00:00
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
if (GDK_IS_TOPLEVEL (surface))
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "state");
|
2018-07-15 18:23:54 +00:00
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
if (was_sticky != sticky)
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "sticky");
|
2017-12-15 03:35:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2020-09-10 04:39:03 +00:00
|
|
|
|
gdk_synthesize_surface_state (GdkSurface *surface,
|
|
|
|
|
GdkToplevelState unset_flags,
|
|
|
|
|
GdkToplevelState set_flags)
|
2017-12-15 03:35:27 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
|
2017-12-15 03:35:27 +00:00
|
|
|
|
}
|
2018-07-16 00:11:56 +00:00
|
|
|
|
|
2020-11-23 15:39:11 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_surface_queue_state_change (GdkSurface *surface,
|
|
|
|
|
GdkToplevelState unset_flags,
|
|
|
|
|
GdkToplevelState set_flags)
|
|
|
|
|
{
|
|
|
|
|
surface->pending_unset_flags |= unset_flags;
|
|
|
|
|
surface->pending_set_flags &= ~unset_flags;
|
|
|
|
|
|
|
|
|
|
surface->pending_set_flags |= set_flags;
|
|
|
|
|
surface->pending_unset_flags &= ~set_flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_surface_apply_state_change (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
if (!surface->pending_unset_flags && !surface->pending_set_flags)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gdk_synthesize_surface_state (surface,
|
|
|
|
|
surface->pending_unset_flags,
|
|
|
|
|
surface->pending_set_flags);
|
|
|
|
|
surface->pending_unset_flags = 0;
|
|
|
|
|
surface->pending_set_flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
set_is_mapped_idle (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GdkSurface *surface = GDK_SURFACE (user_data);
|
|
|
|
|
|
|
|
|
|
surface->set_is_mapped_source_id = 0;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (surface->pending_is_mapped != surface->is_mapped,
|
|
|
|
|
G_SOURCE_REMOVE);
|
|
|
|
|
|
|
|
|
|
surface->is_mapped = surface->pending_is_mapped;
|
|
|
|
|
if (surface->is_mapped)
|
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "mapped");
|
|
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_surface_set_is_mapped (GdkSurface *surface,
|
|
|
|
|
gboolean is_mapped)
|
|
|
|
|
{
|
|
|
|
|
gboolean was_mapped;
|
|
|
|
|
|
|
|
|
|
if (surface->pending_is_mapped != surface->is_mapped)
|
|
|
|
|
g_clear_handle_id (&surface->set_is_mapped_source_id, g_source_remove);
|
|
|
|
|
|
|
|
|
|
surface->pending_is_mapped = is_mapped;
|
|
|
|
|
|
|
|
|
|
was_mapped = surface->is_mapped;
|
|
|
|
|
surface->is_mapped = is_mapped;
|
|
|
|
|
if (surface->is_mapped)
|
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
|
|
|
|
|
|
if (was_mapped != is_mapped)
|
|
|
|
|
g_object_notify (G_OBJECT (surface), "mapped");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_surface_queue_set_is_mapped (GdkSurface *surface,
|
|
|
|
|
gboolean is_mapped)
|
|
|
|
|
{
|
|
|
|
|
if (surface->pending_is_mapped == is_mapped)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
surface->pending_is_mapped = is_mapped;
|
|
|
|
|
|
|
|
|
|
if (surface->is_mapped == surface->pending_is_mapped)
|
|
|
|
|
{
|
|
|
|
|
g_clear_handle_id (&surface->set_is_mapped_source_id, g_source_remove);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (!surface->set_is_mapped_source_id);
|
|
|
|
|
|
|
|
|
|
surface->set_is_mapped_source_id =
|
2022-09-28 16:36:22 +00:00
|
|
|
|
g_idle_add_full (G_PRIORITY_HIGH - 10, set_is_mapped_idle, surface, NULL);
|
|
|
|
|
gdk_source_set_static_name_by_id (surface->set_is_mapped_source_id, "[gtk] set_is_mapped_idle");
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 21:31:33 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
check_autohide (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkDevice *device;
|
2022-12-23 15:04:02 +00:00
|
|
|
|
GdkSurface *grab_surface, *event_surface;
|
|
|
|
|
GdkEventType evtype = gdk_event_get_event_type (event);
|
2019-04-22 21:31:33 +00:00
|
|
|
|
|
2022-12-23 15:04:02 +00:00
|
|
|
|
switch ((guint) evtype)
|
2019-04-22 21:31:33 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
#if 0
|
|
|
|
|
// FIXME: we need to ignore the release that is paired
|
|
|
|
|
// with the press starting the grab - due to implicit
|
|
|
|
|
// grabs, it will be delivered to the same place as the
|
|
|
|
|
// press, and will cause the auto dismissal to be triggered.
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
2022-11-18 14:02:22 +00:00
|
|
|
|
#endif
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
2019-04-22 21:31:33 +00:00
|
|
|
|
case GDK_TOUCHPAD_SWIPE:
|
|
|
|
|
case GDK_TOUCHPAD_PINCH:
|
|
|
|
|
display = gdk_event_get_display (event);
|
|
|
|
|
device = gdk_event_get_device (event);
|
|
|
|
|
if (gdk_device_grab_info (display, device, &grab_surface, NULL))
|
|
|
|
|
{
|
2020-11-03 20:28:40 +00:00
|
|
|
|
event_surface = gdk_event_get_surface (event);
|
2022-12-23 15:04:02 +00:00
|
|
|
|
if (event_surface->autohide &&
|
|
|
|
|
!event_surface->has_pointer)
|
|
|
|
|
event_surface = NULL;
|
|
|
|
|
|
|
|
|
|
if (grab_surface->autohide &&
|
|
|
|
|
(!event_surface ||
|
|
|
|
|
(grab_surface != event_surface &&
|
|
|
|
|
grab_surface != event_surface->parent)))
|
2019-04-22 21:31:33 +00:00
|
|
|
|
{
|
2020-11-03 20:28:40 +00:00
|
|
|
|
GdkSurface *surface = grab_surface;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
gdk_surface_hide (surface);
|
|
|
|
|
surface = surface->parent;
|
|
|
|
|
}
|
|
|
|
|
while (surface->autohide && surface != event_surface);
|
|
|
|
|
|
2019-04-22 21:31:33 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2022-12-23 15:04:02 +00:00
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
event_surface = gdk_event_get_surface (event);
|
|
|
|
|
if (event_surface->autohide &&
|
|
|
|
|
gdk_crossing_event_get_mode (event) == GDK_CROSSING_NORMAL)
|
|
|
|
|
event_surface->has_pointer = evtype == GDK_ENTER_NOTIFY;
|
|
|
|
|
break;
|
2019-04-22 21:31:33 +00:00
|
|
|
|
default:;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
|
static inline void
|
2019-06-13 19:37:16 +00:00
|
|
|
|
add_event_mark (GdkEvent *event,
|
|
|
|
|
gint64 time,
|
2020-08-19 22:49:34 +00:00
|
|
|
|
gint64 end_time)
|
2019-06-13 19:37:16 +00:00
|
|
|
|
{
|
2020-08-19 22:49:34 +00:00
|
|
|
|
#ifdef HAVE_SYSPROF
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *message = NULL;
|
|
|
|
|
const char *kind;
|
2020-02-21 12:23:40 +00:00
|
|
|
|
GEnumClass *class;
|
2019-06-13 19:37:16 +00:00
|
|
|
|
GEnumValue *value;
|
|
|
|
|
GdkEventType event_type;
|
|
|
|
|
|
|
|
|
|
event_type = gdk_event_get_event_type (event);
|
2020-02-21 12:23:40 +00:00
|
|
|
|
class = g_type_class_ref (GDK_TYPE_EVENT_TYPE);
|
|
|
|
|
value = g_enum_get_value (class, event_type);
|
|
|
|
|
g_type_class_unref (class);
|
2020-02-21 12:26:19 +00:00
|
|
|
|
kind = value ? value->value_nick : "event";
|
2019-06-13 19:37:16 +00:00
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
|
switch ((int) event_type)
|
2019-06-13 19:37:16 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
double x, y;
|
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
2020-02-21 12:26:19 +00:00
|
|
|
|
message = g_strdup_printf ("%s {x=%lf, y=%lf, state=0x%x}",
|
|
|
|
|
kind,
|
2020-02-18 03:11:56 +00:00
|
|
|
|
x, y,
|
|
|
|
|
gdk_event_get_modifier_state (event));
|
2019-06-13 19:37:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
double x, y;
|
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
2020-02-21 12:26:19 +00:00
|
|
|
|
message = g_strdup_printf ("%s {button=%u, x=%lf, y=%lf, state=0x%x}",
|
|
|
|
|
kind,
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_button_event_get_button (event),
|
|
|
|
|
x, y,
|
|
|
|
|
gdk_event_get_modifier_state (event));
|
2019-06-13 19:37:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
|
case GDK_KEY_RELEASE:
|
|
|
|
|
{
|
2020-04-05 18:40:55 +00:00
|
|
|
|
message = g_strdup_printf ("%s {keyval=%u, state=0x%x, keycode=%u layout=%u level=%u is_modifier=%u}",
|
2020-02-21 12:26:19 +00:00
|
|
|
|
kind,
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_key_event_get_keyval (event),
|
|
|
|
|
gdk_event_get_modifier_state (event),
|
|
|
|
|
gdk_key_event_get_keycode (event),
|
2020-04-05 18:40:55 +00:00
|
|
|
|
gdk_key_event_get_layout (event),
|
|
|
|
|
gdk_key_event_get_level (event),
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_key_event_is_modifier (event));
|
2019-06-13 19:37:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
case GDK_TOUCHPAD_SWIPE:
|
|
|
|
|
case GDK_TOUCHPAD_PINCH:
|
|
|
|
|
case GDK_SCROLL:
|
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_DRAG_LEAVE:
|
|
|
|
|
case GDK_DRAG_MOTION:
|
|
|
|
|
case GDK_DROP_START:
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
case GDK_PAD_BUTTON_PRESS:
|
|
|
|
|
case GDK_PAD_BUTTON_RELEASE:
|
|
|
|
|
case GDK_PAD_RING:
|
|
|
|
|
case GDK_PAD_STRIP:
|
|
|
|
|
case GDK_PAD_GROUP_MODE:
|
|
|
|
|
case GDK_GRAB_BROKEN:
|
|
|
|
|
case GDK_DELETE:
|
|
|
|
|
case GDK_FOCUS_CHANGE:
|
|
|
|
|
case GDK_PROXIMITY_IN:
|
|
|
|
|
case GDK_PROXIMITY_OUT:
|
|
|
|
|
case GDK_EVENT_LAST:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
|
gdk_profiler_add_mark (time, end_time - time, "event", message ? message : kind);
|
2019-06-13 19:37:16 +00:00
|
|
|
|
|
|
|
|
|
g_free (message);
|
2020-08-19 22:49:34 +00:00
|
|
|
|
#endif
|
2019-06-13 19:37:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-16 00:11:56 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gdk_surface_handle_event (GdkEvent *event)
|
|
|
|
|
{
|
2020-12-02 14:29:54 +00:00
|
|
|
|
GdkSurface *surface = gdk_event_get_surface (event);
|
2020-08-19 22:49:34 +00:00
|
|
|
|
gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
2019-02-23 18:45:10 +00:00
|
|
|
|
gboolean handled = FALSE;
|
2019-04-22 21:31:33 +00:00
|
|
|
|
|
|
|
|
|
if (check_autohide (event))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2020-02-21 21:38:36 +00:00
|
|
|
|
|
2020-12-02 14:29:54 +00:00
|
|
|
|
if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
|
|
|
|
|
surface->request_motion = FALSE;
|
2020-02-21 21:38:36 +00:00
|
|
|
|
|
2020-12-02 14:29:54 +00:00
|
|
|
|
g_signal_emit (surface, signals[EVENT], 0, event, &handled);
|
2018-07-16 00:11:56 +00:00
|
|
|
|
|
2020-02-12 10:05:01 +00:00
|
|
|
|
if (GDK_PROFILER_IS_RUNNING)
|
2020-08-19 22:49:34 +00:00
|
|
|
|
add_event_mark (event, begin_time, GDK_PROFILER_CURRENT_TIME);
|
2019-06-13 19:37:16 +00:00
|
|
|
|
|
2019-02-23 18:45:10 +00:00
|
|
|
|
return handled;
|
2018-07-16 00:11:56 +00:00
|
|
|
|
}
|
2019-05-29 03:41:56 +00:00
|
|
|
|
|
2020-02-21 21:38:36 +00:00
|
|
|
|
/*
|
|
|
|
|
* gdk_surface_request_motion:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @surface: a `GdkSurface`
|
2020-02-21 21:38:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Request that the next frame cycle should deliver a motion
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* event for @surface.
|
|
|
|
|
*
|
|
|
|
|
* The motion event will be delivered if the pointer is over the
|
|
|
|
|
* surface, regardless whether the pointer has moved or not. This
|
|
|
|
|
* is used by GTK after moving widgets around.
|
2020-02-21 21:38:36 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_surface_request_motion (GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
surface->request_motion = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-09 20:46:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_surface_translate_coordinates:
|
|
|
|
|
* @from: the origin surface
|
|
|
|
|
* @to: the target surface
|
2021-01-26 12:54:00 +00:00
|
|
|
|
* @x: (inout): coordinates to translate
|
|
|
|
|
* @y: (inout): coordinates to translate
|
2020-03-09 20:46:42 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Translates coordinates between two surfaces.
|
2020-03-09 20:46:42 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Note that this only works if @to and @from are popups or
|
|
|
|
|
* transient-for to the same toplevel (directly or indirectly).
|
2020-03-09 20:46:42 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Returns: %TRUE if the coordinates were successfully translated
|
2020-03-09 20:46:42 +00:00
|
|
|
|
*/
|
2019-05-29 03:41:56 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gdk_surface_translate_coordinates (GdkSurface *from,
|
|
|
|
|
GdkSurface *to,
|
|
|
|
|
double *x,
|
|
|
|
|
double *y)
|
|
|
|
|
{
|
2021-01-26 12:54:53 +00:00
|
|
|
|
double in_x, in_y, out_x, out_y;
|
2019-05-29 03:41:56 +00:00
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
GdkSurface *f, *t;
|
|
|
|
|
|
2021-01-26 12:56:32 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (from), FALSE);
|
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (to), FALSE);
|
|
|
|
|
g_return_val_if_fail (x != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (y != NULL, FALSE);
|
|
|
|
|
|
2021-01-26 12:54:53 +00:00
|
|
|
|
in_x = *x;
|
|
|
|
|
in_y = *y;
|
|
|
|
|
|
2019-05-29 03:41:56 +00:00
|
|
|
|
x1 = 0;
|
|
|
|
|
y1 = 0;
|
|
|
|
|
f = from;
|
|
|
|
|
while (f->parent)
|
|
|
|
|
{
|
|
|
|
|
x1 += f->x;
|
|
|
|
|
y1 += f->y;
|
|
|
|
|
f = f->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x2 = 0;
|
|
|
|
|
y2 = 0;
|
|
|
|
|
t = to;
|
|
|
|
|
while (t->parent)
|
|
|
|
|
{
|
|
|
|
|
x2 += t->x;
|
|
|
|
|
y2 += t->y;
|
|
|
|
|
t = t->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (f != t)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2021-01-26 12:54:53 +00:00
|
|
|
|
out_x = in_x + (x1 - x2);
|
|
|
|
|
out_y = in_y + (y1 - y2);
|
|
|
|
|
|
|
|
|
|
*x = out_x;
|
|
|
|
|
*y = out_y;
|
2019-05-29 03:41:56 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-03-30 14:55:05 +00:00
|
|
|
|
|
|
|
|
|
GdkSeat *
|
|
|
|
|
gdk_surface_get_seat_from_event (GdkSurface *surface,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (event)
|
|
|
|
|
{
|
|
|
|
|
GdkSeat *seat = NULL;
|
|
|
|
|
|
2020-06-23 09:00:46 +00:00
|
|
|
|
seat = gdk_event_get_seat (event);
|
2020-03-30 14:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (seat)
|
|
|
|
|
return seat;
|
|
|
|
|
}
|
|
|
|
|
return gdk_display_get_default_seat (surface->display);
|
|
|
|
|
}
|
2017-11-29 03:36:17 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_surface_enter_monitor (GdkSurface *surface,
|
|
|
|
|
GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (surface, signals[ENTER_MONITOR], 0, monitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_surface_leave_monitor (GdkSurface *surface,
|
|
|
|
|
GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (surface, signals[LEAVE_MONITOR], 0, monitor);
|
|
|
|
|
}
|