2010-12-18 20:38:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-18 20:38:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "gdk.h"
|
|
|
|
#include "gdkwayland.h"
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdkwaylandsurface.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
#include "gdkdisplay-wayland.h"
|
2020-03-07 21:08:43 +00:00
|
|
|
#include "gdkdragsurfaceprivate.h"
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdkframeclockidleprivate.h"
|
2020-03-07 21:08:43 +00:00
|
|
|
#include "gdkglcontext-wayland.h"
|
|
|
|
#include "gdkmonitor-wayland.h"
|
|
|
|
#include "gdkpopupprivate.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
#include "gdkprivate-wayland.h"
|
2016-07-01 09:03:36 +00:00
|
|
|
#include "gdkprivate-wayland.h"
|
2019-04-20 00:08:14 +00:00
|
|
|
#include "gdkseat-wayland.h"
|
2020-03-07 21:08:43 +00:00
|
|
|
#include "gdksurfaceprivate.h"
|
|
|
|
#include "gdktoplevelprivate.h"
|
2020-08-26 20:04:25 +00:00
|
|
|
#include "gdkdevice-wayland-private.h"
|
2020-03-07 21:08:43 +00:00
|
|
|
|
2016-09-10 18:39:07 +00:00
|
|
|
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-04-19 16:18:46 +00:00
|
|
|
#include <errno.h>
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2019-03-22 18:24:39 +00:00
|
|
|
#define SURFACE_IS_TOPLEVEL(surface) TRUE
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2016-06-08 05:31:45 +00:00
|
|
|
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
typedef enum _PopupState
|
|
|
|
{
|
|
|
|
POPUP_STATE_IDLE,
|
2020-02-16 19:09:42 +00:00
|
|
|
POPUP_STATE_WAITING_FOR_REPOSITIONED,
|
2020-02-16 11:59:24 +00:00
|
|
|
POPUP_STATE_WAITING_FOR_CONFIGURE,
|
|
|
|
POPUP_STATE_WAITING_FOR_FRAME,
|
|
|
|
} PopupState;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
struct _GdkWaylandSurface
|
2011-01-06 21:51:12 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurface parent_instance;
|
2011-01-06 21:51:12 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
struct {
|
2018-03-20 14:14:10 +00:00
|
|
|
/* The wl_outputs that this surface currently touches */
|
2016-02-02 16:42:52 +00:00
|
|
|
GSList *outputs;
|
|
|
|
|
|
|
|
struct wl_surface *wl_surface;
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
struct xdg_surface *xdg_surface;
|
|
|
|
struct xdg_toplevel *xdg_toplevel;
|
|
|
|
struct xdg_popup *xdg_popup;
|
|
|
|
|
|
|
|
/* Legacy xdg-shell unstable v6 fallback support */
|
|
|
|
struct zxdg_surface_v6 *zxdg_surface_v6;
|
|
|
|
struct zxdg_toplevel_v6 *zxdg_toplevel_v6;
|
|
|
|
struct zxdg_popup_v6 *zxdg_popup_v6;
|
|
|
|
|
2016-03-07 03:49:35 +00:00
|
|
|
struct gtk_surface1 *gtk_surface;
|
2016-02-02 16:42:52 +00:00
|
|
|
struct wl_egl_window *egl_window;
|
|
|
|
struct wl_egl_window *dummy_egl_window;
|
2016-07-12 03:49:39 +00:00
|
|
|
struct zxdg_exported_v1 *xdg_exported;
|
2017-04-29 00:35:51 +00:00
|
|
|
struct org_kde_kwin_server_decoration *server_decoration;
|
2016-02-02 16:42:52 +00:00
|
|
|
} display_server;
|
2014-08-21 15:31:50 +00:00
|
|
|
|
2020-01-07 16:13:22 +00:00
|
|
|
struct wl_event_queue *event_queue;
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
EGLSurface egl_surface;
|
2014-10-09 14:09:05 +00:00
|
|
|
EGLSurface dummy_egl_surface;
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
uint32_t reposition_token;
|
|
|
|
uint32_t received_reposition_token;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
PopupState popup_state;
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
unsigned int initial_configure_received : 1;
|
2020-09-17 16:20:08 +00:00
|
|
|
unsigned int has_uncommitted_ack_configure : 1;
|
2011-01-07 15:16:17 +00:00
|
|
|
unsigned int mapped : 1;
|
2015-02-25 13:46:54 +00:00
|
|
|
unsigned int awaiting_frame : 1;
|
2019-12-10 18:23:17 +00:00
|
|
|
unsigned int awaiting_frame_frozen : 1;
|
2020-02-29 17:25:51 +00:00
|
|
|
unsigned int is_drag_surface : 1;
|
2011-01-06 21:51:12 +00:00
|
|
|
|
2015-12-08 10:19:33 +00:00
|
|
|
int pending_buffer_offset_x;
|
|
|
|
int pending_buffer_offset_y;
|
2012-03-06 21:24:20 +00:00
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
char *title;
|
2013-03-16 23:57:17 +00:00
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
struct {
|
|
|
|
gboolean was_set;
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
char *application_id;
|
|
|
|
char *app_menu_path;
|
|
|
|
char *menubar_path;
|
|
|
|
char *window_object_path;
|
|
|
|
char *application_object_path;
|
|
|
|
char *unique_bus_name;
|
2015-03-23 05:08:09 +00:00
|
|
|
} application;
|
|
|
|
|
2012-01-09 17:11:22 +00:00
|
|
|
GdkGeometry geometry_hints;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceHints geometry_mask;
|
2012-02-27 14:06:22 +00:00
|
|
|
|
2015-12-09 11:56:26 +00:00
|
|
|
GdkSeat *grab_input_seat;
|
2013-01-29 18:40:02 +00:00
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
gint64 pending_frame_counter;
|
2013-09-22 03:35:02 +00:00
|
|
|
guint32 scale;
|
2014-02-27 21:54:20 +00:00
|
|
|
|
|
|
|
int margin_left;
|
|
|
|
int margin_right;
|
|
|
|
int margin_top;
|
|
|
|
int margin_bottom;
|
2016-07-01 08:48:16 +00:00
|
|
|
gboolean margin_dirty;
|
2016-02-26 12:35:35 +00:00
|
|
|
|
2017-11-01 15:52:56 +00:00
|
|
|
struct wl_output *initial_fullscreen_output;
|
2014-03-17 20:08:35 +00:00
|
|
|
|
|
|
|
cairo_region_t *opaque_region;
|
2016-07-01 08:48:16 +00:00
|
|
|
gboolean opaque_region_dirty;
|
|
|
|
|
2014-03-17 20:02:47 +00:00
|
|
|
cairo_region_t *input_region;
|
2016-07-01 08:48:16 +00:00
|
|
|
gboolean input_region_dirty;
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
GdkRectangle last_sent_window_geometry;
|
|
|
|
int last_sent_min_width;
|
|
|
|
int last_sent_min_height;
|
|
|
|
int last_sent_max_width;
|
|
|
|
int last_sent_max_height;
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
int saved_width;
|
|
|
|
int saved_height;
|
2016-05-06 08:31:41 +00:00
|
|
|
|
|
|
|
gulong parent_surface_committed_handler;
|
2016-08-08 07:00:42 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
struct {
|
|
|
|
GdkToplevelLayout *layout;
|
|
|
|
} toplevel;
|
|
|
|
|
2016-08-08 07:00:42 +00:00
|
|
|
struct {
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkPopupLayout *layout;
|
|
|
|
int unconstrained_width;
|
|
|
|
int unconstrained_height;
|
|
|
|
} popup;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
|
|
|
struct {
|
2019-07-12 13:54:32 +00:00
|
|
|
struct {
|
|
|
|
int width;
|
|
|
|
int height;
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState state;
|
2019-07-12 13:54:32 +00:00
|
|
|
} toplevel;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
2020-02-16 19:09:42 +00:00
|
|
|
uint32_t repositioned_token;
|
|
|
|
gboolean has_repositioned_token;
|
2019-07-12 13:54:32 +00:00
|
|
|
} popup;
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
gboolean is_initial_configure;
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
uint32_t serial;
|
2020-02-16 11:59:24 +00:00
|
|
|
gboolean is_dirty;
|
2016-06-28 07:01:22 +00:00
|
|
|
} pending;
|
2016-07-12 03:49:39 +00:00
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
uint32_t last_configure_serial;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
int state_freeze_count;
|
|
|
|
|
2016-07-12 03:49:39 +00:00
|
|
|
struct {
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkWaylandSurfaceExported callback;
|
2016-07-12 03:49:39 +00:00
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify destroy_func;
|
|
|
|
} exported;
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
struct zxdg_imported_v1 *imported_transient_for;
|
2017-03-22 09:21:02 +00:00
|
|
|
GHashTable *shortcuts_inhibitors;
|
2020-07-14 19:18:03 +00:00
|
|
|
|
|
|
|
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
|
|
|
size_t idle_inhibitor_refcount;
|
2011-01-06 21:51:12 +00:00
|
|
|
};
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
struct _GdkWaylandSurfaceClass
|
2011-01-06 21:51:12 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurfaceClass parent_class;
|
2011-01-06 21:51:12 +00:00
|
|
|
};
|
|
|
|
|
2020-03-17 14:23:57 +00:00
|
|
|
G_DEFINE_TYPE (GdkWaylandSurface, gdk_wayland_surface, GDK_TYPE_SURFACE)
|
|
|
|
|
|
|
|
typedef struct _GdkWaylandToplevel GdkWaylandToplevel;
|
|
|
|
struct _GdkWaylandToplevel
|
|
|
|
{
|
|
|
|
GdkWaylandSurface parent_instance;
|
2020-03-17 14:30:25 +00:00
|
|
|
|
|
|
|
GdkWaylandToplevel *transient_for;
|
2020-03-17 14:23:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWaylandSurfaceClass parent_class;
|
|
|
|
} GdkWaylandToplevelClass;
|
|
|
|
|
|
|
|
static void gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface);
|
|
|
|
|
|
|
|
GType gdk_wayland_toplevel_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define GDK_IS_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_TOPLEVEL))
|
|
|
|
#define GDK_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_TOPLEVEL, GdkWaylandToplevel))
|
|
|
|
|
|
|
|
#define GDK_TYPE_WAYLAND_TOPLEVEL (gdk_wayland_toplevel_get_type ())
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWaylandToplevel, gdk_wayland_toplevel, GDK_TYPE_WAYLAND_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
|
|
|
gdk_wayland_toplevel_iface_init))
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWaylandSurface parent_instance;
|
|
|
|
} GdkWaylandPopup;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWaylandSurfaceClass parent_class;
|
|
|
|
} GdkWaylandPopupClass;
|
|
|
|
|
|
|
|
static void gdk_wayland_popup_iface_init (GdkPopupInterface *iface);
|
|
|
|
|
|
|
|
GType gdk_wayland_popup_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define GDK_IS_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_POPUP))
|
|
|
|
#define GDK_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_POPUP, GdkWaylandPopup))
|
|
|
|
|
|
|
|
#define GDK_TYPE_WAYLAND_POPUP (gdk_wayland_popup_get_type ())
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWaylandPopup, gdk_wayland_popup, GDK_TYPE_WAYLAND_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
|
|
|
gdk_wayland_popup_iface_init))
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWaylandSurface parent_instance;
|
|
|
|
} GdkWaylandDragSurface;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWaylandSurfaceClass parent_class;
|
|
|
|
} GdkWaylandDragSurfaceClass;
|
|
|
|
|
|
|
|
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
|
|
|
|
|
|
|
|
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define GDK_IS_WAYLAND_DRAG_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_SURFACE))
|
|
|
|
|
|
|
|
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
|
|
|
gdk_wayland_drag_surface_iface_init))
|
|
|
|
|
2019-07-12 13:24:18 +00:00
|
|
|
static void gdk_wayland_surface_maybe_resize (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int scale);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
static void gdk_wayland_surface_configure (GdkSurface *surface);
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
static void maybe_set_gtk_surface_dbus_properties (GdkSurface *surface);
|
|
|
|
static void maybe_set_gtk_surface_modal (GdkSurface *surface);
|
2015-03-23 05:08:09 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
static void gdk_wayland_surface_sync_margin (GdkSurface *surface);
|
|
|
|
static void gdk_wayland_surface_sync_input_region (GdkSurface *surface);
|
|
|
|
static void gdk_wayland_surface_sync_opaque_region (GdkSurface *surface);
|
2016-07-01 08:48:16 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
static void unset_transient_for_exported (GdkSurface *surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
static void gdk_wayland_surface_move_resize (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height);
|
2019-07-15 13:47:12 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
static void update_popup_layout_state (GdkSurface *surface,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout);
|
2016-09-12 06:53:51 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
static gboolean gdk_wayland_surface_is_exported (GdkSurface *surface);
|
2017-05-08 04:09:00 +00:00
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_init (GdkWaylandSurface *impl)
|
2011-01-06 21:51:12 +00:00
|
|
|
{
|
2013-06-04 09:39:36 +00:00
|
|
|
impl->scale = 1;
|
2017-11-01 15:52:56 +00:00
|
|
|
impl->initial_fullscreen_output = NULL;
|
2016-02-26 12:35:35 +00:00
|
|
|
impl->saved_width = -1;
|
|
|
|
impl->saved_height = -1;
|
2019-04-22 01:14:46 +00:00
|
|
|
impl->shortcuts_inhibitors = g_hash_table_new (NULL, NULL);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_surface_freeze_state (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
impl->state_freeze_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_surface_thaw_state (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
g_assert (impl->state_freeze_count > 0);
|
|
|
|
|
|
|
|
impl->state_freeze_count--;
|
|
|
|
|
|
|
|
if (impl->state_freeze_count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (impl->pending.is_dirty)
|
|
|
|
gdk_wayland_surface_configure (surface);
|
|
|
|
|
|
|
|
g_assert (!impl->display_server.xdg_popup);
|
|
|
|
}
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_save_size (GdkSurface *surface)
|
2016-02-26 12:35:35 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-02-26 12:35:35 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN | GDK_TOPLEVEL_STATE_MAXIMIZED))
|
2016-02-26 12:35:35 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
impl->saved_width = surface->width - impl->margin_left - impl->margin_right;
|
|
|
|
impl->saved_height = surface->height - impl->margin_top - impl->margin_bottom;
|
2016-02-26 12:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_clear_saved_size (GdkSurface *surface)
|
2016-02-26 12:35:35 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-02-26 12:35:35 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN | GDK_TOPLEVEL_STATE_MAXIMIZED))
|
2016-02-26 12:35:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
impl->saved_width = -1;
|
|
|
|
impl->saved_height = -1;
|
|
|
|
}
|
|
|
|
|
2012-01-29 12:15:12 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_update_size (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
int32_t width,
|
|
|
|
int32_t height,
|
|
|
|
int scale)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if ((surface->width == width) &&
|
|
|
|
(surface->height == height) &&
|
2016-03-17 06:35:20 +00:00
|
|
|
(impl->scale == scale))
|
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
2015-02-24 08:11:48 +00:00
|
|
|
impl->scale = scale;
|
2011-02-11 03:37:51 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.egl_window)
|
2017-08-23 14:27:43 +00:00
|
|
|
wl_egl_window_resize (impl->display_server.egl_window, width * scale, height * scale, 0, 0);
|
|
|
|
if (impl->display_server.wl_surface)
|
|
|
|
wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2018-03-21 03:07:37 +00:00
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static const char *
|
2010-12-18 20:38:49 +00:00
|
|
|
get_default_title (void)
|
|
|
|
{
|
|
|
|
const char *title;
|
|
|
|
|
|
|
|
title = g_get_application_name ();
|
|
|
|
if (!title)
|
|
|
|
title = g_get_prgname ();
|
|
|
|
if (!title)
|
|
|
|
title = "";
|
|
|
|
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:46:31 +00:00
|
|
|
static void
|
|
|
|
fill_presentation_time_from_frame_time (GdkFrameTimings *timings,
|
|
|
|
guint32 frame_time)
|
|
|
|
{
|
|
|
|
/* The timestamp in a wayland frame is a msec time value that in some
|
|
|
|
* way reflects the time at which the server started drawing the frame.
|
|
|
|
* This is not useful from our perspective.
|
|
|
|
*
|
|
|
|
* However, for the DRM backend of Weston, on reasonably recent
|
|
|
|
* Linux, we know that the time is the
|
2013-09-16 21:23:29 +00:00
|
|
|
* clock_gettime (CLOCK_MONOTONIC) value at the vblank, and that
|
2013-04-25 15:46:31 +00:00
|
|
|
* backend starts drawing immediately after receiving the vblank
|
|
|
|
* notification. If we detect this, and make the assumption that the
|
|
|
|
* compositor will finish drawing before the next vblank, we can
|
|
|
|
* then determine the presentation time as the frame time we
|
2013-09-16 21:23:29 +00:00
|
|
|
* received plus one refresh interval.
|
2013-04-25 15:46:31 +00:00
|
|
|
*
|
|
|
|
* If a backend is using clock_gettime(CLOCK_MONOTONIC), but not
|
|
|
|
* picking values right at the vblank, then the presentation times
|
|
|
|
* we compute won't be accurate, but not really worse than then
|
|
|
|
* the alternative of not providing presentation times at all.
|
|
|
|
*
|
|
|
|
* The complexity here is dealing with the fact that we receive
|
|
|
|
* only the low 32 bits of the CLOCK_MONOTONIC value in milliseconds.
|
|
|
|
*/
|
|
|
|
gint64 now_monotonic = g_get_monotonic_time ();
|
|
|
|
gint64 now_monotonic_msec = now_monotonic / 1000;
|
|
|
|
uint32_t now_monotonic_low = (uint32_t)now_monotonic_msec;
|
|
|
|
|
|
|
|
if (frame_time - now_monotonic_low < 1000 ||
|
|
|
|
frame_time - now_monotonic_low > (uint32_t)-1000)
|
|
|
|
{
|
|
|
|
/* Timestamp we received is within one second of the current time.
|
|
|
|
*/
|
|
|
|
gint64 last_frame_time = now_monotonic + (gint64)1000 * (gint32)(frame_time - now_monotonic_low);
|
|
|
|
if ((gint32)now_monotonic_low < 0 && (gint32)frame_time > 0)
|
|
|
|
last_frame_time += (gint64)1000 * G_GINT64_CONSTANT(0x100000000);
|
|
|
|
else if ((gint32)now_monotonic_low > 0 && (gint32)frame_time < 0)
|
|
|
|
last_frame_time -= (gint64)1000 * G_GINT64_CONSTANT(0x100000000);
|
|
|
|
|
|
|
|
timings->presentation_time = last_frame_time + timings->refresh_interval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
static GdkSurface *
|
|
|
|
get_popup_toplevel (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
if (surface->parent)
|
|
|
|
return get_popup_toplevel (surface->parent);
|
|
|
|
else
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
freeze_popup_toplevel_state (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkSurface *toplevel;
|
|
|
|
|
|
|
|
toplevel = get_popup_toplevel (surface);
|
|
|
|
gdk_wayland_surface_freeze_state (toplevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
thaw_popup_toplevel_state (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkSurface *toplevel;
|
|
|
|
|
|
|
|
toplevel = get_popup_toplevel (surface);
|
|
|
|
gdk_wayland_surface_thaw_state (toplevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
finish_pending_relayout (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
g_assert (impl->popup_state == POPUP_STATE_WAITING_FOR_FRAME);
|
|
|
|
impl->popup_state = POPUP_STATE_IDLE;
|
|
|
|
|
|
|
|
thaw_popup_toplevel_state (surface);
|
|
|
|
}
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
static void
|
|
|
|
frame_callback (void *data,
|
|
|
|
struct wl_callback *callback,
|
|
|
|
uint32_t time)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = data;
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
2013-04-24 22:14:22 +00:00
|
|
|
GdkFrameTimings *timings;
|
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "frame event");
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_DISPLAY_NOTE (GDK_DISPLAY (display_wayland), EVENTS, g_message ("frame %p", surface));
|
2015-02-28 05:15:13 +00:00
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
wl_callback_destroy (callback);
|
2014-01-31 21:39:33 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2014-01-31 21:39:33 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-25 13:46:54 +00:00
|
|
|
if (!impl->awaiting_frame)
|
|
|
|
return;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
switch (impl->popup_state)
|
|
|
|
{
|
|
|
|
case POPUP_STATE_IDLE:
|
2020-02-16 19:09:42 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
2020-02-16 11:59:24 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
|
|
|
break;
|
|
|
|
case POPUP_STATE_WAITING_FOR_FRAME:
|
|
|
|
finish_pending_relayout (surface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2015-02-25 13:46:54 +00:00
|
|
|
impl->awaiting_frame = FALSE;
|
2019-12-10 18:23:17 +00:00
|
|
|
if (impl->awaiting_frame_frozen)
|
|
|
|
{
|
|
|
|
impl->awaiting_frame_frozen = FALSE;
|
|
|
|
gdk_surface_thaw_updates (surface);
|
|
|
|
}
|
2013-04-24 22:14:22 +00:00
|
|
|
|
|
|
|
timings = gdk_frame_clock_get_timings (clock, impl->pending_frame_counter);
|
|
|
|
impl->pending_frame_counter = 0;
|
|
|
|
|
|
|
|
if (timings == NULL)
|
|
|
|
return;
|
|
|
|
|
2013-04-25 15:19:31 +00:00
|
|
|
timings->refresh_interval = 16667; /* default to 1/60th of a second */
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.outputs)
|
2013-04-25 15:19:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
/* We pick a random output out of the outputs that the surface touches
|
2013-04-25 15:19:31 +00:00
|
|
|
* The rate here is in milli-hertz */
|
2016-04-26 03:16:56 +00:00
|
|
|
int refresh_rate =
|
2017-11-01 23:25:45 +00:00
|
|
|
gdk_wayland_display_get_output_refresh_rate (display_wayland,
|
2016-04-26 03:16:56 +00:00
|
|
|
impl->display_server.outputs->data);
|
2013-04-25 15:19:31 +00:00
|
|
|
if (refresh_rate != 0)
|
|
|
|
timings->refresh_interval = G_GINT64_CONSTANT(1000000000) / refresh_rate;
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:46:31 +00:00
|
|
|
fill_presentation_time_from_frame_time (timings, time);
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
timings->complete = TRUE;
|
|
|
|
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
|
|
|
|
_gdk_frame_clock_debug_print_timings (clock, timings);
|
2020-01-23 00:04:53 +00:00
|
|
|
#endif
|
2019-05-16 19:08:34 +00:00
|
|
|
|
2020-02-12 10:05:01 +00:00
|
|
|
if (GDK_PROFILER_IS_RUNNING)
|
2019-05-16 19:08:34 +00:00
|
|
|
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
|
2013-04-24 22:14:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-21 21:33:09 +00:00
|
|
|
static const struct wl_callback_listener frame_listener = {
|
2013-04-24 22:14:22 +00:00
|
|
|
frame_callback
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_frame_clock_before_paint (GdkFrameClock *clock,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface)
|
2013-04-24 22:14:22 +00:00
|
|
|
{
|
2013-04-25 15:46:31 +00:00
|
|
|
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
|
|
|
|
gint64 presentation_time;
|
|
|
|
gint64 refresh_interval;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface->update_freeze_count > 0)
|
2016-07-01 09:03:36 +00:00
|
|
|
return;
|
|
|
|
|
2013-04-25 15:46:31 +00:00
|
|
|
gdk_frame_clock_get_refresh_info (clock,
|
|
|
|
timings->frame_time,
|
|
|
|
&refresh_interval, &presentation_time);
|
|
|
|
|
|
|
|
if (presentation_time != 0)
|
|
|
|
{
|
|
|
|
/* Assume the algorithm used by the DRM backend of Weston - it
|
|
|
|
* starts drawing at the next vblank after receiving the commit
|
|
|
|
* for this frame, and presentation occurs at the vblank
|
|
|
|
* after that.
|
|
|
|
*/
|
|
|
|
timings->predicted_presentation_time = presentation_time + refresh_interval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* As above, but we don't actually know the phase of the vblank,
|
|
|
|
* so just assume that we're half way through a refresh cycle.
|
|
|
|
*/
|
|
|
|
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
|
|
|
|
}
|
2013-04-24 22:14:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 13:10:56 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_surface_request_frame (GdkSurface *surface)
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2018-04-10 13:10:56 +00:00
|
|
|
struct wl_callback *callback;
|
|
|
|
GdkFrameClock *clock;
|
|
|
|
|
|
|
|
if (impl->awaiting_frame)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
|
|
|
|
callback = wl_surface_frame (impl->display_server.wl_surface);
|
2020-01-07 16:13:22 +00:00
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) callback, NULL);
|
2018-04-10 13:10:56 +00:00
|
|
|
wl_callback_add_listener (callback, &frame_listener, surface);
|
|
|
|
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
|
|
|
impl->awaiting_frame = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-09-17 15:35:35 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_surface_commit (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
wl_surface_commit (impl->display_server.wl_surface);
|
|
|
|
}
|
|
|
|
|
2020-09-17 16:20:08 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_surface_notify_committed (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
impl->has_uncommitted_ack_configure = FALSE;
|
|
|
|
}
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
static void
|
|
|
|
on_frame_clock_after_paint (GdkFrameClock *clock,
|
2018-04-13 00:13:27 +00:00
|
|
|
GdkSurface *surface)
|
2013-04-24 22:14:22 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-04-24 22:14:22 +00:00
|
|
|
|
2020-09-17 16:20:08 +00:00
|
|
|
if (surface->update_freeze_count == 0 && impl->has_uncommitted_ack_configure)
|
|
|
|
{
|
|
|
|
gdk_wayland_surface_commit (surface);
|
|
|
|
gdk_wayland_surface_notify_committed (surface);
|
|
|
|
}
|
|
|
|
|
2019-06-28 16:45:44 +00:00
|
|
|
if (impl->awaiting_frame &&
|
|
|
|
impl->pending_frame_counter == gdk_frame_clock_get_frame_counter (clock))
|
2019-12-10 18:23:17 +00:00
|
|
|
{
|
|
|
|
impl->awaiting_frame_frozen = TRUE;
|
|
|
|
gdk_surface_freeze_updates (surface);
|
|
|
|
}
|
2013-04-24 22:14:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-01 01:48:58 +00:00
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_update_scale (GdkSurface *surface)
|
2013-06-04 09:39:36 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2013-06-04 09:39:36 +00:00
|
|
|
guint32 scale;
|
|
|
|
GSList *l;
|
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
if (display_wayland->compositor_version < WL_SURFACE_HAS_BUFFER_SCALE)
|
2013-07-12 14:49:52 +00:00
|
|
|
{
|
|
|
|
/* We can't set the scale on this surface */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-04 09:39:36 +00:00
|
|
|
scale = 1;
|
2016-02-02 16:42:52 +00:00
|
|
|
for (l = impl->display_server.outputs; l != NULL; l = l->next)
|
2013-06-04 09:39:36 +00:00
|
|
|
{
|
2017-11-01 23:25:45 +00:00
|
|
|
guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, l->data);
|
2013-06-04 09:39:36 +00:00
|
|
|
scale = MAX (scale, output_scale);
|
|
|
|
}
|
|
|
|
|
2015-02-24 08:11:48 +00:00
|
|
|
/* Notify app that scale changed */
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_maybe_resize (surface,
|
|
|
|
surface->width, surface->height,
|
|
|
|
scale);
|
2013-06-04 09:39:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
static void gdk_wayland_surface_create_surface (GdkSurface *surface);
|
2020-03-01 17:31:26 +00:00
|
|
|
static void gdk_wayland_surface_set_title (GdkSurface *surface,
|
|
|
|
const char *title);
|
2013-07-03 15:19:39 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurface *
|
|
|
|
_gdk_wayland_display_create_surface (GdkDisplay *display,
|
|
|
|
GdkSurfaceType surface_type,
|
|
|
|
GdkSurface *parent,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurface *surface;
|
|
|
|
GdkWaylandSurface *impl;
|
2013-04-24 22:14:22 +00:00
|
|
|
GdkFrameClock *frame_clock;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2019-05-05 22:59:51 +00:00
|
|
|
if (parent)
|
|
|
|
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
|
|
|
|
else
|
|
|
|
frame_clock = _gdk_frame_clock_idle_new ();
|
2019-04-22 01:14:46 +00:00
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
switch (surface_type)
|
|
|
|
{
|
|
|
|
case GDK_SURFACE_TOPLEVEL:
|
|
|
|
surface = g_object_new (GDK_TYPE_WAYLAND_TOPLEVEL,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
2020-03-17 14:28:14 +00:00
|
|
|
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels,
|
|
|
|
surface);
|
|
|
|
g_warn_if_fail (!parent);
|
2020-03-07 21:08:43 +00:00
|
|
|
break;
|
|
|
|
case GDK_SURFACE_POPUP:
|
|
|
|
surface = g_object_new (GDK_TYPE_WAYLAND_POPUP,
|
|
|
|
"parent", parent,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case GDK_SURFACE_TEMP:
|
|
|
|
surface = g_object_new (GDK_TYPE_WAYLAND_DRAG_SURFACE,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
if (width > 65535)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_warning ("Native Surfaces wider than 65535 pixels are not supported");
|
2019-04-22 01:14:46 +00:00
|
|
|
width = 65535;
|
2015-02-28 03:28:28 +00:00
|
|
|
}
|
2019-04-22 01:14:46 +00:00
|
|
|
if (height > 65535)
|
2015-02-28 03:28:28 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_warning ("Native Surfaces taller than 65535 pixels are not supported");
|
2019-04-22 01:14:46 +00:00
|
|
|
height = 65535;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
2011-01-06 20:23:52 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
surface->x = x;
|
|
|
|
surface->y = y;
|
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_object_ref (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2013-06-04 09:39:36 +00:00
|
|
|
/* More likely to be right than just assuming 1 */
|
2020-05-17 03:58:20 +00:00
|
|
|
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
|
|
|
|
{
|
|
|
|
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
|
|
|
|
if (monitor)
|
|
|
|
{
|
|
|
|
impl->scale = gdk_monitor_get_scale_factor (monitor);
|
|
|
|
g_object_unref (monitor);
|
|
|
|
}
|
|
|
|
}
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2020-03-01 17:31:26 +00:00
|
|
|
gdk_wayland_surface_set_title (surface, get_default_title ());
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2019-04-22 15:21:45 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_create_surface (surface);
|
2013-07-03 15:19:39 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_signal_connect (frame_clock, "before-paint", G_CALLBACK (on_frame_clock_before_paint), surface);
|
|
|
|
g_signal_connect (frame_clock, "after-paint", G_CALLBACK (on_frame_clock_after_paint), surface);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
|
|
|
g_object_unref (frame_clock);
|
|
|
|
|
|
|
|
return surface;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2018-04-17 21:05:41 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_surface_attach_image (GdkSurface *surface,
|
|
|
|
cairo_surface_t *cairo_surface,
|
|
|
|
const cairo_region_t *damage)
|
2011-01-08 01:49:40 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2018-04-17 21:05:41 +00:00
|
|
|
GdkWaylandDisplay *display;
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
int i, n;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2011-01-08 01:49:40 +00:00
|
|
|
return;
|
|
|
|
|
2018-04-17 21:05:41 +00:00
|
|
|
g_assert (_gdk_wayland_is_shm_surface (cairo_surface));
|
2015-02-24 10:10:07 +00:00
|
|
|
|
2012-03-06 21:24:20 +00:00
|
|
|
/* Attach this new buffer to the surface */
|
2016-02-02 16:42:52 +00:00
|
|
|
wl_surface_attach (impl->display_server.wl_surface,
|
2018-04-17 21:05:41 +00:00
|
|
|
_gdk_wayland_shm_surface_get_wl_buffer (cairo_surface),
|
2015-12-08 10:19:33 +00:00
|
|
|
impl->pending_buffer_offset_x,
|
|
|
|
impl->pending_buffer_offset_y);
|
|
|
|
impl->pending_buffer_offset_x = 0;
|
|
|
|
impl->pending_buffer_offset_y = 0;
|
2013-07-12 14:49:52 +00:00
|
|
|
|
|
|
|
/* Only set the buffer scale if supported by the compositor */
|
2018-03-20 14:14:10 +00:00
|
|
|
display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2013-07-12 14:49:52 +00:00
|
|
|
if (display->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
|
2016-02-02 16:42:52 +00:00
|
|
|
wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2018-04-17 21:05:41 +00:00
|
|
|
n = cairo_region_num_rectangles (damage);
|
|
|
|
for (i = 0; i < n; i++)
|
wayland: stage uncommitted changes to dedicated buffer
Right now we use one buffer for both staged changes (freshly painted
changes waiting for the frame clock to send to the compositor) and
committed changes (changes actively being read by the compositor
process). This creates a problem in the event we need to stage updates
at the same time the compositor is processing committed updates: we
can't change what the compositor is actively processing.
The current solution for handling this contention is to allocate a
temporary buffer on the spot at the time the updates are staged, and to
copy that buffer back to the shared buffer later. The problem, though,
is that the copy to the shared buffer currently happens as soon as
the updates are finished being staged, not when the shared buffer is
done being processed by the compositor.
In order to address that problem, this commit changes the code to always
stage changes to a dedicated staging buffer. The staging buffer is
used exclusively by the client until the client is done with it, and then
once that staging buffer is committed, the client never writes to that
buffer again. If the client needs to stage new updates, it allocates a
brand new staging buffer, draws to it, and back fills the undrawn parts
of the buffer from a copy of the contents of the committed buffer.
As an optimization, the compositor has the option of releasing the
committed buffer back to the client. If it does so before the client
needs to stage new updates, then the client will reuse the buffer
for staging future updates. This optimization prevents having to allocate
a new staging buffer and the associated cost of back filling
that new buffer with a readback of the committed buffer.
https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-01-29 16:19:03 +00:00
|
|
|
{
|
2018-04-17 21:05:41 +00:00
|
|
|
cairo_region_get_rectangle (damage, i, &rect);
|
|
|
|
wl_surface_damage (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
|
wayland: stage uncommitted changes to dedicated buffer
Right now we use one buffer for both staged changes (freshly painted
changes waiting for the frame clock to send to the compositor) and
committed changes (changes actively being read by the compositor
process). This creates a problem in the event we need to stage updates
at the same time the compositor is processing committed updates: we
can't change what the compositor is actively processing.
The current solution for handling this contention is to allocate a
temporary buffer on the spot at the time the updates are staged, and to
copy that buffer back to the shared buffer later. The problem, though,
is that the copy to the shared buffer currently happens as soon as
the updates are finished being staged, not when the shared buffer is
done being processed by the compositor.
In order to address that problem, this commit changes the code to always
stage changes to a dedicated staging buffer. The staging buffer is
used exclusively by the client until the client is done with it, and then
once that staging buffer is committed, the client never writes to that
buffer again. If the client needs to stage new updates, it allocates a
brand new staging buffer, draws to it, and back fills the undrawn parts
of the buffer from a copy of the contents of the committed buffer.
As an optimization, the compositor has the option of releasing the
committed buffer back to the client. If it does so before the client
needs to stage new updates, then the client will reuse the buffer
for staging future updates. This optimization prevents having to allocate
a new staging buffer and the associated cost of back filling
that new buffer with a readback of the committed buffer.
https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-01-29 16:19:03 +00:00
|
|
|
}
|
2016-12-06 17:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync (GdkSurface *surface)
|
2016-12-06 17:01:34 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_margin (surface);
|
|
|
|
gdk_wayland_surface_sync_opaque_region (surface);
|
|
|
|
gdk_wayland_surface_sync_input_region (surface);
|
2014-06-21 21:29:08 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 04:41:31 +00:00
|
|
|
static gboolean
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_beep (GdkSurface *surface)
|
2016-03-07 04:41:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_display_system_bell (gdk_surface_get_display (surface),
|
|
|
|
surface);
|
2016-03-07 04:41:31 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-07 16:13:22 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_surface_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->constructed (object);
|
|
|
|
|
|
|
|
impl->event_queue = wl_display_create_queue (display_wayland->wl_display);
|
|
|
|
display_wayland->event_queues = g_list_prepend (display_wayland->event_queues,
|
|
|
|
impl->event_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_surface_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
GdkWaylandSurface *impl;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_SURFACE (surface));
|
|
|
|
|
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (impl->event_queue)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
display_wayland->event_queues =
|
|
|
|
g_list_remove (display_wayland->event_queues, surface);
|
|
|
|
g_clear_pointer (&impl->event_queue, wl_event_queue_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2012-04-04 13:05:27 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_finalize (GObject *object)
|
2012-04-04 13:05:27 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2012-04-04 13:05:27 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_SURFACE (object));
|
2012-04-04 13:05:27 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (object);
|
2012-04-04 13:05:27 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (gdk_wayland_surface_is_exported (surface))
|
|
|
|
gdk_wayland_surface_unexport_handle (surface);
|
2017-05-08 04:09:00 +00:00
|
|
|
|
2013-08-21 11:09:29 +00:00
|
|
|
g_free (impl->title);
|
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
g_free (impl->application.application_id);
|
|
|
|
g_free (impl->application.app_menu_path);
|
|
|
|
g_free (impl->application.menubar_path);
|
|
|
|
g_free (impl->application.window_object_path);
|
|
|
|
g_free (impl->application.application_object_path);
|
|
|
|
g_free (impl->application.unique_bus_name);
|
|
|
|
|
2014-03-17 20:08:35 +00:00
|
|
|
g_clear_pointer (&impl->opaque_region, cairo_region_destroy);
|
2014-03-17 20:02:47 +00:00
|
|
|
g_clear_pointer (&impl->input_region, cairo_region_destroy);
|
2018-04-23 09:57:07 +00:00
|
|
|
g_clear_pointer (&impl->shortcuts_inhibitors, g_hash_table_unref);
|
2017-03-22 09:21:02 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->finalize (object);
|
2012-04-04 13:05:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-30 14:04:45 +00:00
|
|
|
static void
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_resize (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int scale)
|
2012-01-29 12:15:12 +00:00
|
|
|
{
|
2018-07-15 23:52:28 +00:00
|
|
|
GdkDisplay *display;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
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
|
|
|
event = gdk_configure_event_new (surface, width, height);
|
2018-07-15 23:52:28 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_update_size (surface, width, height, scale);
|
|
|
|
_gdk_surface_update_size (surface);
|
2018-07-15 23:52:28 +00:00
|
|
|
|
|
|
|
display = gdk_surface_get_display (surface);
|
|
|
|
_gdk_wayland_display_deliver_event (display, event);
|
2012-01-29 12:15:12 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static gboolean
|
|
|
|
is_realized_shell_surface (GdkSurface *surface)
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
return (impl->display_server.xdg_surface ||
|
|
|
|
impl->display_server.zxdg_surface_v6);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_realized_toplevel (GdkSurface *surface)
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
return (impl->display_server.xdg_toplevel ||
|
|
|
|
impl->display_server.zxdg_toplevel_v6);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_realized_popup (GdkSurface *surface)
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
return (impl->display_server.xdg_popup ||
|
|
|
|
impl->display_server.zxdg_popup_v6);
|
|
|
|
}
|
|
|
|
|
2019-06-12 19:07:29 +00:00
|
|
|
static void gdk_wayland_surface_show (GdkSurface *surface,
|
|
|
|
gboolean already_mapped);
|
|
|
|
static void gdk_wayland_surface_hide (GdkSurface *surface);
|
|
|
|
|
2016-04-04 12:55:38 +00:00
|
|
|
static void
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_maybe_resize (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int scale)
|
2016-04-04 12:55:38 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-11-25 13:24:52 +00:00
|
|
|
gboolean is_xdg_popup;
|
|
|
|
gboolean is_visible;
|
2016-04-04 12:55:38 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface->width == width &&
|
|
|
|
surface->height == height &&
|
2016-04-04 12:55:38 +00:00
|
|
|
impl->scale == scale)
|
|
|
|
return;
|
|
|
|
|
2016-11-25 13:24:52 +00:00
|
|
|
/* For xdg_popup using an xdg_positioner, there is a race condition if
|
|
|
|
* the application tries to change the size after it's mapped, but before
|
|
|
|
* the initial configure is received, so hide and show the surface again
|
|
|
|
* force the new size onto the compositor. See bug #772505.
|
|
|
|
*/
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
is_xdg_popup = is_realized_popup (surface);
|
2020-02-25 00:02:34 +00:00
|
|
|
is_visible = gdk_surface_get_mapped (surface);
|
2016-11-25 13:24:52 +00:00
|
|
|
|
|
|
|
if (is_xdg_popup && is_visible && !impl->initial_configure_received)
|
2019-06-12 19:07:29 +00:00
|
|
|
gdk_wayland_surface_hide (surface);
|
2016-11-25 13:24:52 +00:00
|
|
|
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_resize (surface, width, height, scale);
|
2016-11-25 13:24:52 +00:00
|
|
|
|
|
|
|
if (is_xdg_popup && is_visible && !impl->initial_configure_received)
|
2019-06-12 19:07:29 +00:00
|
|
|
gdk_wayland_surface_show (surface, FALSE);
|
2016-04-04 12:55:38 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 22:20:14 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_parent (GdkSurface *surface,
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkSurface *parent)
|
2011-02-11 22:20:14 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-03-17 14:30:25 +00:00
|
|
|
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (impl);
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl_parent = NULL;
|
2012-07-11 18:18:37 +00:00
|
|
|
|
2016-04-26 03:46:25 +00:00
|
|
|
g_assert (parent == NULL ||
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_get_display (surface) == gdk_surface_get_display (parent));
|
2016-04-26 03:46:25 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2013-11-11 23:02:19 +00:00
|
|
|
return;
|
2013-02-07 11:27:25 +00:00
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
if (toplevel->transient_for)
|
|
|
|
impl_parent = GDK_WAYLAND_SURFACE (toplevel->transient_for);
|
2015-12-08 15:33:45 +00:00
|
|
|
else if (parent)
|
2019-04-22 01:14:46 +00:00
|
|
|
impl_parent = GDK_WAYLAND_SURFACE (parent);
|
2013-11-19 17:36:12 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
/* XXX: Is this correct? */
|
|
|
|
if (impl_parent && !impl_parent->display_server.wl_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
2015-12-08 15:33:45 +00:00
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
{
|
|
|
|
struct xdg_toplevel *parent_toplevel;
|
2013-11-19 17:36:12 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (impl_parent)
|
|
|
|
parent_toplevel = impl_parent->display_server.xdg_toplevel;
|
|
|
|
else
|
|
|
|
parent_toplevel = NULL;
|
2013-02-07 11:27:25 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_toplevel_set_parent (impl->display_server.xdg_toplevel,
|
|
|
|
parent_toplevel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
{
|
|
|
|
struct zxdg_toplevel_v6 *parent_toplevel;
|
|
|
|
|
|
|
|
if (impl_parent)
|
|
|
|
parent_toplevel = impl_parent->display_server.zxdg_toplevel_v6;
|
|
|
|
else
|
|
|
|
parent_toplevel = NULL;
|
|
|
|
|
|
|
|
zxdg_toplevel_v6_set_parent (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
parent_toplevel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2011-02-11 22:20:14 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 04:18:30 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_parent_of_imported (GdkSurface *surface)
|
2017-12-01 04:18:30 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-01 04:18:30 +00:00
|
|
|
|
|
|
|
if (!impl->display_server.wl_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!impl->imported_transient_for)
|
|
|
|
return;
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2017-12-01 04:18:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
zxdg_imported_v1_set_parent_of (impl->imported_transient_for,
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
}
|
|
|
|
|
2013-11-21 17:03:18 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_title (GdkSurface *surface)
|
2013-11-21 17:03:18 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2013-11-21 17:03:18 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2013-11-21 17:03:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!impl->title)
|
|
|
|
return;
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_title (impl->display_server.xdg_toplevel,
|
|
|
|
impl->title);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_title (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
impl->title);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2013-11-21 17:03:18 +00:00
|
|
|
}
|
|
|
|
|
2016-07-01 09:02:11 +00:00
|
|
|
static void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_get_window_geometry (GdkSurface *surface,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkRectangle *geometry)
|
2016-07-01 09:02:11 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-01 09:02:11 +00:00
|
|
|
|
|
|
|
*geometry = (GdkRectangle) {
|
|
|
|
.x = impl->margin_left,
|
|
|
|
.y = impl->margin_top,
|
2018-03-20 14:14:10 +00:00
|
|
|
.width = surface->width - (impl->margin_left + impl->margin_right),
|
|
|
|
.height = surface->height - (impl->margin_top + impl->margin_bottom)
|
2016-07-01 09:02:11 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-29 18:06:22 +00:00
|
|
|
static void gdk_wayland_surface_set_geometry_hints (GdkSurface *surface,
|
|
|
|
const GdkGeometry *geometry,
|
|
|
|
GdkSurfaceHints geom_mask);
|
|
|
|
|
2014-02-27 21:54:20 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_margin (GdkSurface *surface)
|
2014-02-27 21:54:20 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2016-07-01 09:02:11 +00:00
|
|
|
GdkRectangle geometry;
|
2014-02-27 21:54:20 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_shell_surface (surface))
|
2014-02-27 21:54:20 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_window_geometry (surface, &geometry);
|
2020-02-29 18:06:22 +00:00
|
|
|
gdk_wayland_surface_set_geometry_hints (surface,
|
|
|
|
&impl->geometry_hints,
|
|
|
|
impl->geometry_mask);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
if (gdk_rectangle_equal (&geometry, &impl->last_sent_window_geometry))
|
|
|
|
return;
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_surface_set_window_geometry (impl->display_server.xdg_surface,
|
2016-07-01 09:03:36 +00:00
|
|
|
geometry.x,
|
|
|
|
geometry.y,
|
|
|
|
geometry.width,
|
|
|
|
geometry.height);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_surface_v6_set_window_geometry (impl->display_server.zxdg_surface_v6,
|
|
|
|
geometry.x,
|
|
|
|
geometry.y,
|
|
|
|
geometry.width,
|
|
|
|
geometry.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2020-07-30 21:06:59 +00:00
|
|
|
|
|
|
|
impl->last_sent_window_geometry = geometry;
|
2014-02-27 21:54:20 +00:00
|
|
|
}
|
|
|
|
|
2014-03-17 20:08:35 +00:00
|
|
|
static struct wl_region *
|
|
|
|
wl_region_from_cairo_region (GdkWaylandDisplay *display,
|
|
|
|
cairo_region_t *region)
|
|
|
|
{
|
|
|
|
struct wl_region *wl_region;
|
|
|
|
int i, n_rects;
|
|
|
|
|
|
|
|
wl_region = wl_compositor_create_region (display->compositor);
|
|
|
|
if (wl_region == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (region);
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
cairo_region_get_rectangle (region, i, &rect);
|
|
|
|
wl_region_add (wl_region, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return wl_region;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
|
2014-03-17 20:08:35 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2014-03-17 20:08:35 +00:00
|
|
|
struct wl_region *wl_region = NULL;
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (!impl->display_server.wl_surface)
|
2014-03-17 20:08:35 +00:00
|
|
|
return;
|
|
|
|
|
2016-07-01 08:48:16 +00:00
|
|
|
if (!impl->opaque_region_dirty)
|
|
|
|
return;
|
|
|
|
|
2014-03-17 20:08:35 +00:00
|
|
|
if (impl->opaque_region != NULL)
|
2018-03-20 14:14:10 +00:00
|
|
|
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
2014-03-17 20:08:35 +00:00
|
|
|
impl->opaque_region);
|
|
|
|
|
2017-08-23 14:40:12 +00:00
|
|
|
wl_surface_set_opaque_region (impl->display_server.wl_surface, wl_region);
|
2014-03-17 20:08:35 +00:00
|
|
|
|
|
|
|
if (wl_region != NULL)
|
|
|
|
wl_region_destroy (wl_region);
|
2016-07-01 08:48:16 +00:00
|
|
|
|
|
|
|
impl->opaque_region_dirty = FALSE;
|
2014-03-17 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
2014-03-17 20:02:47 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_input_region (GdkSurface *surface)
|
2014-03-17 20:02:47 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2014-03-17 20:02:47 +00:00
|
|
|
struct wl_region *wl_region = NULL;
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (!impl->display_server.wl_surface)
|
2014-03-17 20:02:47 +00:00
|
|
|
return;
|
|
|
|
|
2016-07-01 08:48:16 +00:00
|
|
|
if (!impl->input_region_dirty)
|
|
|
|
return;
|
|
|
|
|
2014-03-17 20:02:47 +00:00
|
|
|
if (impl->input_region != NULL)
|
2018-03-20 14:14:10 +00:00
|
|
|
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
2014-03-17 20:02:47 +00:00
|
|
|
impl->input_region);
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
wl_surface_set_input_region (impl->display_server.wl_surface, wl_region);
|
2014-03-17 20:02:47 +00:00
|
|
|
|
|
|
|
if (wl_region != NULL)
|
|
|
|
wl_region_destroy (wl_region);
|
2016-07-01 08:48:16 +00:00
|
|
|
|
|
|
|
impl->input_region_dirty = FALSE;
|
2014-03-17 20:02:47 +00:00
|
|
|
}
|
|
|
|
|
2013-04-25 15:19:31 +00:00
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
surface_enter (void *data,
|
2013-04-25 15:19:31 +00:00
|
|
|
struct wl_surface *wl_surface,
|
2013-09-16 21:23:29 +00:00
|
|
|
struct wl_output *output)
|
2013-04-25 15:19:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-11-29 03:37:42 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkMonitor *monitor;
|
2013-04-25 15:19:31 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
|
|
|
|
g_message ("surface enter, surface %p output %p", surface, output));
|
2015-02-28 05:15:13 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_update_scale (surface);
|
2017-11-29 03:37:42 +00:00
|
|
|
|
|
|
|
monitor = gdk_wayland_display_get_monitor_for_output (display, output);
|
|
|
|
gdk_surface_enter_monitor (surface, monitor);
|
2013-04-25 15:19:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
surface_leave (void *data,
|
2013-04-25 15:19:31 +00:00
|
|
|
struct wl_surface *wl_surface,
|
2013-09-16 21:23:29 +00:00
|
|
|
struct wl_output *output)
|
2013-04-25 15:19:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-11-29 03:37:42 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkMonitor *monitor;
|
2013-04-25 15:19:31 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
|
|
|
|
g_message ("surface leave, surface %p output %p", surface, output));
|
2015-02-28 05:15:13 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.outputs = g_slist_remove (impl->display_server.outputs, output);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2016-11-15 14:07:39 +00:00
|
|
|
if (impl->display_server.outputs)
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_update_scale (surface);
|
2017-11-29 03:37:42 +00:00
|
|
|
|
|
|
|
monitor = gdk_wayland_display_get_monitor_for_output (display, output);
|
|
|
|
gdk_surface_leave_monitor (surface, monitor);
|
2013-04-25 15:19:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
static const struct wl_surface_listener surface_listener = {
|
|
|
|
surface_enter,
|
|
|
|
surface_leave
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_create_surface (GdkSurface *surface)
|
2013-11-11 23:02:19 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2020-01-07 16:13:22 +00:00
|
|
|
struct wl_surface *wl_surface;
|
|
|
|
|
|
|
|
wl_surface = wl_compositor_create_surface (display_wayland->compositor);
|
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) wl_surface, impl->event_queue);
|
|
|
|
wl_surface_add_listener (wl_surface, &surface_listener, surface);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2020-01-07 16:13:22 +00:00
|
|
|
impl->display_server.wl_surface = wl_surface;
|
2013-11-11 23:02:19 +00:00
|
|
|
}
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
static void
|
|
|
|
configure_surface_geometry (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkRectangle monitor_geometry;
|
|
|
|
int bounds_width, bounds_height;
|
|
|
|
GdkToplevelSize size;
|
|
|
|
int width, height;
|
|
|
|
GdkToplevelLayout *layout;
|
|
|
|
GdkGeometry geometry;
|
|
|
|
GdkSurfaceHints mask;
|
|
|
|
|
|
|
|
monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
|
|
|
|
gdk_monitor_get_geometry (monitor, &monitor_geometry);
|
|
|
|
bounds_width = monitor_geometry.width;
|
|
|
|
bounds_height = monitor_geometry.height;
|
|
|
|
|
|
|
|
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
|
|
|
|
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
|
|
|
|
width = size.width;
|
|
|
|
height = size.height;
|
|
|
|
g_warn_if_fail (width > 0);
|
|
|
|
g_warn_if_fail (height > 0);
|
|
|
|
|
|
|
|
layout = impl->toplevel.layout;
|
|
|
|
if (gdk_toplevel_layout_get_resizable (layout))
|
|
|
|
{
|
|
|
|
geometry.min_width = size.min_width;
|
|
|
|
geometry.min_height = size.min_height;
|
|
|
|
mask = GDK_HINT_MIN_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geometry.max_width = geometry.min_width = width;
|
|
|
|
geometry.max_height = geometry.min_height = height;
|
|
|
|
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
|
|
|
|
}
|
|
|
|
gdk_wayland_surface_set_geometry_hints (surface, &geometry, mask);
|
|
|
|
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
|
|
|
|
gdk_wayland_surface_resize (surface, width, height, impl->scale);
|
|
|
|
}
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
static void
|
2019-07-12 13:54:32 +00:00
|
|
|
gdk_wayland_surface_configure_toplevel (GdkSurface *surface)
|
2011-12-05 15:55:37 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState new_state;
|
2019-07-12 13:54:32 +00:00
|
|
|
int width, height;
|
2016-06-06 08:48:36 +00:00
|
|
|
gboolean fixed_size;
|
2017-06-21 13:02:05 +00:00
|
|
|
gboolean saved_size;
|
2011-12-05 15:55:37 +00:00
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
new_state = impl->pending.toplevel.state;
|
|
|
|
impl->pending.toplevel.state = 0;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
2016-06-28 07:01:04 +00:00
|
|
|
fixed_size =
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state & (GDK_TOPLEVEL_STATE_MAXIMIZED |
|
|
|
|
GDK_TOPLEVEL_STATE_FULLSCREEN |
|
|
|
|
GDK_TOPLEVEL_STATE_TILED);
|
2016-06-28 07:01:04 +00:00
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
width = impl->pending.toplevel.width;
|
|
|
|
height = impl->pending.toplevel.height;
|
|
|
|
|
2017-06-21 13:02:05 +00:00
|
|
|
saved_size = (width == 0 && height == 0);
|
2016-06-28 07:01:04 +00:00
|
|
|
/* According to xdg_shell, an xdg_surface.configure with size 0x0
|
|
|
|
* should be interpreted as that it is up to the client to set a
|
|
|
|
* size.
|
|
|
|
*
|
|
|
|
* When transitioning from maximize or fullscreen state, this means
|
|
|
|
* the client should configure its size back to what it was before
|
|
|
|
* being maximize or fullscreen.
|
|
|
|
*/
|
2017-06-21 13:02:05 +00:00
|
|
|
if (saved_size && !fixed_size)
|
2016-02-26 12:35:35 +00:00
|
|
|
{
|
|
|
|
width = impl->saved_width;
|
|
|
|
height = impl->saved_height;
|
|
|
|
}
|
|
|
|
|
2016-06-28 07:01:04 +00:00
|
|
|
if (width > 0 && height > 0)
|
2015-06-23 09:54:48 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceHints geometry_mask = impl->geometry_mask;
|
2015-06-23 09:54:48 +00:00
|
|
|
|
2017-06-21 13:02:05 +00:00
|
|
|
if (!saved_size)
|
|
|
|
{
|
2020-05-28 08:00:03 +00:00
|
|
|
/* Do not reapply constrains if we are restoring original size */
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_constrain_size (&impl->geometry_hints,
|
2017-06-21 13:02:05 +00:00
|
|
|
geometry_mask,
|
|
|
|
width + impl->margin_left + impl->margin_right,
|
|
|
|
height + impl->margin_top + impl->margin_bottom,
|
|
|
|
&width,
|
|
|
|
&height);
|
|
|
|
|
|
|
|
/* Save size for next time we get 0x0 */
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_save_size (surface);
|
2017-06-21 13:02:05 +00:00
|
|
|
}
|
2016-02-26 12:35:35 +00:00
|
|
|
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_resize (surface, width, height, impl->scale);
|
2015-06-23 09:54:48 +00:00
|
|
|
}
|
2020-07-30 21:06:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
configure_surface_geometry (surface);
|
|
|
|
}
|
2015-06-23 09:54:48 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
|
|
|
|
g_message ("configure, surface %p %dx%d,%s%s%s%s",
|
|
|
|
surface, width, height,
|
2020-09-10 04:39:03 +00:00
|
|
|
(new_state & GDK_TOPLEVEL_STATE_FULLSCREEN) ? " fullscreen" : "",
|
|
|
|
(new_state & GDK_TOPLEVEL_STATE_MAXIMIZED) ? " maximized" : "",
|
|
|
|
(new_state & GDK_TOPLEVEL_STATE_FOCUSED) ? " focused" : "",
|
|
|
|
(new_state & GDK_TOPLEVEL_STATE_TILED) ? " tiled" : ""));
|
2015-02-28 05:15:13 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_set_state (surface, new_state);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
2019-07-12 13:54:32 +00:00
|
|
|
xdg_surface_ack_configure (impl->display_server.xdg_surface,
|
|
|
|
impl->pending.serial);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_surface_v6_ack_configure (impl->display_server.zxdg_surface_v6,
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.serial);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2014-02-06 19:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_surface_configure_popup (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
int x, y, width, height;
|
|
|
|
|
|
|
|
if (impl->display_server.xdg_popup)
|
|
|
|
{
|
|
|
|
xdg_surface_ack_configure (impl->display_server.xdg_surface,
|
|
|
|
impl->pending.serial);
|
|
|
|
}
|
|
|
|
else if (impl->display_server.zxdg_popup_v6)
|
|
|
|
{
|
|
|
|
zxdg_surface_v6_ack_configure (impl->display_server.zxdg_surface_v6,
|
|
|
|
impl->pending.serial);
|
|
|
|
}
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
if (impl->pending.popup.has_repositioned_token)
|
|
|
|
impl->received_reposition_token = impl->pending.popup.repositioned_token;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
switch (impl->popup_state)
|
|
|
|
{
|
2020-02-16 19:09:42 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
|
|
|
if (impl->received_reposition_token != impl->reposition_token)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
gdk_surface_thaw_updates (surface);
|
|
|
|
G_GNUC_FALLTHROUGH;
|
2020-02-16 11:59:24 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
|
|
|
impl->popup_state = POPUP_STATE_WAITING_FOR_FRAME;
|
|
|
|
break;
|
|
|
|
case POPUP_STATE_IDLE:
|
|
|
|
case POPUP_STATE_WAITING_FOR_FRAME:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
x = impl->pending.popup.x;
|
|
|
|
y = impl->pending.popup.y;
|
|
|
|
width = impl->pending.popup.width;
|
|
|
|
height = impl->pending.popup.height;
|
|
|
|
|
|
|
|
gdk_wayland_surface_resize (surface, width, height, impl->scale);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
update_popup_layout_state (surface,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
impl->popup.layout);
|
2019-07-12 13:54:32 +00:00
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
if (!impl->pending.popup.has_repositioned_token &&
|
|
|
|
!impl->pending.is_initial_configure)
|
|
|
|
g_signal_emit_by_name (surface, "popup-layout-changed");
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
2019-07-12 13:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_surface_configure (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (!impl->initial_configure_received)
|
|
|
|
{
|
|
|
|
gdk_surface_thaw_updates (surface);
|
|
|
|
impl->initial_configure_received = TRUE;
|
2020-02-16 19:09:42 +00:00
|
|
|
impl->pending.is_initial_configure = TRUE;
|
2019-07-12 13:54:32 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 16:20:08 +00:00
|
|
|
impl->has_uncommitted_ack_configure = TRUE;
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
if (is_realized_popup (surface))
|
|
|
|
gdk_wayland_surface_configure_popup (surface);
|
|
|
|
else if (is_realized_toplevel (surface))
|
|
|
|
gdk_wayland_surface_configure_toplevel (surface);
|
|
|
|
else
|
|
|
|
g_warn_if_reached ();
|
2020-02-16 11:59:24 +00:00
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
impl->last_configure_serial = impl->pending.serial;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
memset (&impl->pending, 0, sizeof (impl->pending));
|
2019-07-12 13:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_surface_handle_configure (GdkSurface *surface,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
impl->pending.is_dirty = TRUE;
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.serial = serial;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
if (impl->state_freeze_count > 0)
|
|
|
|
return;
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
gdk_wayland_surface_configure (surface);
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_surface_handle_configure_toplevel (GdkSurface *surface,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height,
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState state)
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.toplevel.state |= state;
|
|
|
|
impl->pending.toplevel.width = width;
|
|
|
|
impl->pending.toplevel.height = height;
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_surface_handle_close (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
display = gdk_surface_get_display (surface);
|
|
|
|
|
|
|
|
GDK_DISPLAY_NOTE (display, EVENTS, g_message ("close %p", surface));
|
|
|
|
|
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
|
|
|
event = gdk_delete_event_new (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (display, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_surface_configure (void *data,
|
|
|
|
struct xdg_surface *xdg_surface,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
|
|
|
gdk_wayland_surface_handle_configure (surface, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_surface_listener xdg_surface_listener = {
|
2016-07-01 09:03:36 +00:00
|
|
|
xdg_surface_configure,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_toplevel_configure (void *data,
|
|
|
|
struct xdg_toplevel *xdg_toplevel,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height,
|
|
|
|
struct wl_array *states)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
uint32_t *p;
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState pending_state = 0;
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
wl_array_for_each (p, states)
|
|
|
|
{
|
|
|
|
uint32_t state = *p;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_FULLSCREEN;
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_MAXIMIZED;
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case XDG_TOPLEVEL_STATE_ACTIVATED:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_FOCUSED;
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case XDG_TOPLEVEL_STATE_RESIZING:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Unknown state */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_wayland_surface_handle_configure_toplevel (surface, width, height,
|
|
|
|
pending_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_toplevel_close (void *data,
|
|
|
|
struct xdg_toplevel *xdg_toplevel)
|
2016-07-01 09:03:36 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
gdk_wayland_surface_handle_close (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
|
|
|
|
xdg_toplevel_configure,
|
|
|
|
xdg_toplevel_close,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_xdg_toplevel_resources (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
impl->display_server.xdg_surface =
|
|
|
|
xdg_wm_base_get_xdg_surface (display_wayland->xdg_wm_base,
|
|
|
|
impl->display_server.wl_surface);
|
2020-01-07 16:13:22 +00:00
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.xdg_surface,
|
|
|
|
impl->event_queue);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_surface_add_listener (impl->display_server.xdg_surface,
|
|
|
|
&xdg_surface_listener,
|
|
|
|
surface);
|
|
|
|
|
|
|
|
impl->display_server.xdg_toplevel =
|
|
|
|
xdg_surface_get_toplevel (impl->display_server.xdg_surface);
|
|
|
|
xdg_toplevel_add_listener (impl->display_server.xdg_toplevel,
|
|
|
|
&xdg_toplevel_listener,
|
|
|
|
surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zxdg_surface_v6_configure (void *data,
|
|
|
|
struct zxdg_surface_v6 *xdg_surface,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
|
|
|
gdk_wayland_surface_handle_configure (surface, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_surface_v6_listener zxdg_surface_v6_listener = {
|
|
|
|
zxdg_surface_v6_configure,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
zxdg_toplevel_v6_configure (void *data,
|
|
|
|
struct zxdg_toplevel_v6 *xdg_toplevel,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height,
|
|
|
|
struct wl_array *states)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2016-07-01 09:03:36 +00:00
|
|
|
uint32_t *p;
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState pending_state = 0;
|
2016-07-01 09:03:36 +00:00
|
|
|
|
|
|
|
wl_array_for_each (p, states)
|
|
|
|
{
|
|
|
|
uint32_t state = *p;
|
2017-12-18 12:00:36 +00:00
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_FULLSCREEN;
|
2016-07-01 09:03:36 +00:00
|
|
|
break;
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_MAXIMIZED;
|
2016-07-01 09:03:36 +00:00
|
|
|
break;
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
|
2020-09-10 04:39:03 +00:00
|
|
|
pending_state |= GDK_TOPLEVEL_STATE_FOCUSED;
|
2016-07-01 09:03:36 +00:00
|
|
|
break;
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_RESIZING:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Unknown state */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
gdk_wayland_surface_handle_configure_toplevel (surface, width, height,
|
|
|
|
pending_state);
|
2016-07-01 09:03:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 22:16:40 +00:00
|
|
|
static void
|
2017-12-18 12:00:36 +00:00
|
|
|
zxdg_toplevel_v6_close (void *data,
|
|
|
|
struct zxdg_toplevel_v6 *xdg_toplevel)
|
2014-02-07 22:16:40 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2014-02-07 22:16:40 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
gdk_wayland_surface_handle_close (surface);
|
|
|
|
}
|
2018-01-12 00:48:27 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static const struct zxdg_toplevel_v6_listener zxdg_toplevel_v6_listener = {
|
|
|
|
zxdg_toplevel_v6_configure,
|
|
|
|
zxdg_toplevel_v6_close,
|
|
|
|
};
|
2015-02-28 05:15:13 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static void
|
|
|
|
create_zxdg_toplevel_v6_resources (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2014-02-07 22:16:40 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
impl->display_server.zxdg_surface_v6 =
|
|
|
|
zxdg_shell_v6_get_xdg_surface (display_wayland->zxdg_shell_v6,
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
zxdg_surface_v6_add_listener (impl->display_server.zxdg_surface_v6,
|
|
|
|
&zxdg_surface_v6_listener,
|
|
|
|
surface);
|
2014-02-07 22:16:40 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
impl->display_server.zxdg_toplevel_v6 =
|
|
|
|
zxdg_surface_v6_get_toplevel (impl->display_server.zxdg_surface_v6);
|
|
|
|
zxdg_toplevel_v6_add_listener (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
&zxdg_toplevel_v6_listener,
|
|
|
|
surface);
|
|
|
|
}
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2020-07-07 14:45:30 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_surface_set_application_id (GdkSurface *surface, const char* application_id)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl;
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
|
|
|
g_return_if_fail (application_id != NULL);
|
|
|
|
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!is_realized_toplevel (surface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_app_id (impl->display_server.xdg_toplevel,
|
|
|
|
application_id);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_app_id (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
application_id);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 13:15:04 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
|
2012-07-11 13:15:04 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *app_id;
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_freeze_updates (surface);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
create_xdg_toplevel_resources (surface);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
create_zxdg_toplevel_v6_resources (surface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2013-11-21 17:03:18 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_parent (surface, NULL);
|
|
|
|
gdk_wayland_surface_sync_parent_of_imported (surface);
|
|
|
|
gdk_wayland_surface_sync_title (surface);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_toplevel_set_maximized (impl->display_server.xdg_toplevel);
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_toplevel_set_fullscreen (impl->display_server.xdg_toplevel,
|
2017-11-01 15:52:56 +00:00
|
|
|
impl->initial_fullscreen_output);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
2017-12-18 12:00:36 +00:00
|
|
|
zxdg_toplevel_v6_set_maximized (impl->display_server.zxdg_toplevel_v6);
|
2020-09-10 04:39:03 +00:00
|
|
|
if (surface->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2017-12-18 12:00:36 +00:00
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
impl->initial_fullscreen_output);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2017-11-01 15:52:56 +00:00
|
|
|
|
|
|
|
impl->initial_fullscreen_output = NULL;
|
2015-02-27 23:18:00 +00:00
|
|
|
|
2018-08-02 09:03:41 +00:00
|
|
|
app_id = impl->application.application_id;
|
|
|
|
if (app_id == NULL)
|
|
|
|
app_id = g_get_prgname ();
|
2015-03-23 05:08:09 +00:00
|
|
|
|
2017-11-17 19:07:18 +00:00
|
|
|
if (app_id == NULL)
|
2020-09-12 16:01:04 +00:00
|
|
|
app_id = "GTK Application";
|
2017-11-17 19:07:18 +00:00
|
|
|
|
2020-07-07 14:45:30 +00:00
|
|
|
gdk_wayland_surface_set_application_id (surface, app_id);
|
2015-03-23 05:08:09 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
maybe_set_gtk_surface_dbus_properties (surface);
|
|
|
|
maybe_set_gtk_surface_modal (surface);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
|
2016-07-01 09:03:36 +00:00
|
|
|
wl_surface_commit (impl->display_server.wl_surface);
|
2013-11-11 23:02:19 +00:00
|
|
|
}
|
2012-07-11 16:09:23 +00:00
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
static void
|
2017-12-18 12:00:36 +00:00
|
|
|
gdk_wayland_surface_handle_configure_popup (GdkSurface *surface,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height)
|
2016-09-12 06:53:51 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-09-12 06:53:51 +00:00
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.popup.x = x;
|
|
|
|
impl->pending.popup.y = y;
|
|
|
|
impl->pending.popup.width = width;
|
|
|
|
impl->pending.popup.height = height;
|
2016-09-12 06:53:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_popup_configure (void *data,
|
|
|
|
struct xdg_popup *xdg_popup,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
|
|
|
gdk_wayland_surface_handle_configure_popup (surface, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_popup_done (void *data,
|
|
|
|
struct xdg_popup *xdg_popup)
|
2016-09-12 06:53:51 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2016-09-12 06:53:51 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS, g_message ("done %p", surface));
|
2016-09-12 06:53:51 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_hide (surface);
|
2016-09-12 06:53:51 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
static void
|
|
|
|
xdg_popup_repositioned (void *data,
|
|
|
|
struct xdg_popup *xdg_popup,
|
|
|
|
uint32_t token)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
|
|
|
|
g_message ("repositioned %p", surface));
|
|
|
|
|
|
|
|
if (impl->popup_state != POPUP_STATE_WAITING_FOR_REPOSITIONED)
|
|
|
|
{
|
|
|
|
g_warning ("Unexpected xdg_popup.repositioned event, probably buggy compositor");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl->pending.popup.repositioned_token = token;
|
|
|
|
impl->pending.popup.has_repositioned_token = TRUE;
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static const struct xdg_popup_listener xdg_popup_listener = {
|
2016-09-12 06:53:51 +00:00
|
|
|
xdg_popup_configure,
|
|
|
|
xdg_popup_done,
|
2020-02-16 19:09:42 +00:00
|
|
|
xdg_popup_repositioned,
|
2016-09-12 06:53:51 +00:00
|
|
|
};
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static void
|
|
|
|
zxdg_popup_v6_configure (void *data,
|
|
|
|
struct zxdg_popup_v6 *xdg_popup,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
|
|
|
gdk_wayland_surface_handle_configure_popup (surface, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zxdg_popup_v6_done (void *data,
|
|
|
|
struct zxdg_popup_v6 *xdg_popup)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
g_message ("done %p", surface));
|
|
|
|
|
|
|
|
gdk_surface_hide (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_popup_v6_listener zxdg_popup_v6_listener = {
|
|
|
|
zxdg_popup_v6_configure,
|
|
|
|
zxdg_popup_v6_done,
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum xdg_positioner_anchor
|
2016-09-12 06:53:51 +00:00
|
|
|
rect_anchor_to_anchor (GdkGravity rect_anchor)
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
|
|
|
switch (rect_anchor)
|
|
|
|
{
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
return XDG_POSITIONER_ANCHOR_TOP_LEFT;
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
return XDG_POSITIONER_ANCHOR_TOP;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
return XDG_POSITIONER_ANCHOR_TOP_RIGHT;
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
return XDG_POSITIONER_ANCHOR_LEFT;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
return XDG_POSITIONER_ANCHOR_NONE;
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
return XDG_POSITIONER_ANCHOR_RIGHT;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
return XDG_POSITIONER_ANCHOR_BOTTOM_LEFT;
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
return XDG_POSITIONER_ANCHOR_BOTTOM;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
return XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum xdg_positioner_gravity
|
|
|
|
surface_anchor_to_gravity (GdkGravity rect_anchor)
|
|
|
|
{
|
|
|
|
switch (rect_anchor)
|
|
|
|
{
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
return XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT;
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
return XDG_POSITIONER_GRAVITY_BOTTOM;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
return XDG_POSITIONER_GRAVITY_BOTTOM_LEFT;
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
return XDG_POSITIONER_GRAVITY_RIGHT;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
return XDG_POSITIONER_GRAVITY_NONE;
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
return XDG_POSITIONER_GRAVITY_LEFT;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
return XDG_POSITIONER_GRAVITY_TOP_RIGHT;
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
return XDG_POSITIONER_GRAVITY_TOP;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
return XDG_POSITIONER_GRAVITY_TOP_LEFT;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum zxdg_positioner_v6_anchor
|
|
|
|
rect_anchor_to_anchor_legacy (GdkGravity rect_anchor)
|
2016-09-12 06:53:51 +00:00
|
|
|
{
|
|
|
|
switch (rect_anchor)
|
|
|
|
{
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
return (ZXDG_POSITIONER_V6_ANCHOR_TOP |
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_LEFT);
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
return ZXDG_POSITIONER_V6_ANCHOR_TOP;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
return (ZXDG_POSITIONER_V6_ANCHOR_TOP |
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_RIGHT);
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
return ZXDG_POSITIONER_V6_ANCHOR_LEFT;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
return ZXDG_POSITIONER_V6_ANCHOR_NONE;
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
return ZXDG_POSITIONER_V6_ANCHOR_RIGHT;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
return (ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_LEFT);
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
return ZXDG_POSITIONER_V6_ANCHOR_BOTTOM;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
return (ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_RIGHT);
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2017-10-24 15:58:06 +00:00
|
|
|
|
|
|
|
return (ZXDG_POSITIONER_V6_ANCHOR_TOP |
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_LEFT);
|
2016-09-12 06:53:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum zxdg_positioner_v6_gravity
|
2017-12-18 12:00:36 +00:00
|
|
|
surface_anchor_to_gravity_legacy (GdkGravity rect_anchor)
|
2016-09-12 06:53:51 +00:00
|
|
|
{
|
|
|
|
switch (rect_anchor)
|
|
|
|
{
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
case GDK_GRAVITY_STATIC:
|
2017-03-20 13:36:29 +00:00
|
|
|
return (ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_RIGHT);
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_NORTH:
|
2017-03-20 13:36:29 +00:00
|
|
|
return ZXDG_POSITIONER_V6_GRAVITY_BOTTOM;
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
2017-03-20 13:36:29 +00:00
|
|
|
return (ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_LEFT);
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_WEST:
|
2017-03-20 13:36:29 +00:00
|
|
|
return ZXDG_POSITIONER_V6_GRAVITY_RIGHT;
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_CENTER:
|
2017-03-20 13:36:29 +00:00
|
|
|
return ZXDG_POSITIONER_V6_GRAVITY_NONE;
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_EAST:
|
2017-03-20 13:36:29 +00:00
|
|
|
return ZXDG_POSITIONER_V6_GRAVITY_LEFT;
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
2017-03-20 13:36:29 +00:00
|
|
|
return (ZXDG_POSITIONER_V6_GRAVITY_TOP |
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_RIGHT);
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_SOUTH:
|
2017-03-20 13:36:29 +00:00
|
|
|
return ZXDG_POSITIONER_V6_GRAVITY_TOP;
|
2016-09-12 06:53:51 +00:00
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
2017-03-20 13:36:29 +00:00
|
|
|
return (ZXDG_POSITIONER_V6_GRAVITY_TOP |
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_LEFT);
|
2016-09-12 06:53:51 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2017-10-24 15:58:06 +00:00
|
|
|
|
|
|
|
return (ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_RIGHT);
|
2016-09-12 06:53:51 +00:00
|
|
|
}
|
|
|
|
|
2017-04-29 00:35:51 +00:00
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_announce_csd (GdkSurface *surface)
|
2017-04-29 00:35:51 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-04-29 00:35:51 +00:00
|
|
|
if (!display_wayland->server_decoration_manager)
|
|
|
|
return;
|
|
|
|
impl->display_server.server_decoration =
|
|
|
|
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
if (impl->display_server.server_decoration)
|
|
|
|
org_kde_kwin_server_decoration_request_mode (impl->display_server.server_decoration,
|
|
|
|
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT);
|
|
|
|
}
|
|
|
|
|
2020-07-14 19:18:03 +00:00
|
|
|
gboolean
|
|
|
|
gdk_wayland_surface_inhibit_idle (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (!display_wayland->idle_inhibit_manager)
|
|
|
|
return false;
|
|
|
|
if (!impl->idle_inhibitor)
|
|
|
|
{
|
|
|
|
g_assert (impl->idle_inhibitor_refcount == 0);
|
|
|
|
impl->idle_inhibitor =
|
|
|
|
zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager,
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
}
|
|
|
|
++impl->idle_inhibitor_refcount;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_wayland_surface_uninhibit_idle (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
g_assert (impl->idle_inhibitor && impl->idle_inhibitor_refcount > 0);
|
|
|
|
|
|
|
|
if (--impl->idle_inhibitor_refcount == 0)
|
|
|
|
{
|
|
|
|
zwp_idle_inhibitor_v1_destroy (impl->idle_inhibitor);
|
|
|
|
impl->idle_inhibitor = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
calculate_popup_rect (GdkSurface *surface,
|
|
|
|
GdkPopupLayout *layout,
|
|
|
|
GdkRectangle *out_rect)
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-02-16 11:59:24 +00:00
|
|
|
int width, height;
|
2016-09-12 07:00:21 +00:00
|
|
|
GdkRectangle anchor_rect;
|
2020-02-16 11:59:24 +00:00
|
|
|
int dx, dy;
|
2016-07-08 08:54:36 +00:00
|
|
|
int x = 0, y = 0;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
width = (impl->popup.unconstrained_width -
|
|
|
|
(impl->margin_left + impl->margin_right));
|
|
|
|
height = (impl->popup.unconstrained_height -
|
|
|
|
(impl->margin_top + impl->margin_bottom));
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
|
|
|
|
gdk_popup_layout_get_offset (layout, &dx, &dy);
|
|
|
|
anchor_rect.x += dx;
|
|
|
|
anchor_rect.y += dy;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
switch (gdk_popup_layout_get_rect_anchor (layout))
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
2016-07-08 08:54:36 +00:00
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
x = anchor_rect.x;
|
|
|
|
y = anchor_rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
x = anchor_rect.x + (anchor_rect.width / 2);
|
|
|
|
y = anchor_rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
x = anchor_rect.x + anchor_rect.width;
|
|
|
|
y = anchor_rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
x = anchor_rect.x;
|
|
|
|
y = anchor_rect.y + (anchor_rect.height / 2);
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
x = anchor_rect.x + (anchor_rect.width / 2);
|
|
|
|
y = anchor_rect.y + (anchor_rect.height / 2);
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
x = anchor_rect.x + anchor_rect.width;
|
|
|
|
y = anchor_rect.y + (anchor_rect.height / 2);
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
x = anchor_rect.x;
|
2016-09-12 07:01:24 +00:00
|
|
|
y = anchor_rect.y + anchor_rect.height;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
x = anchor_rect.x + (anchor_rect.width / 2);
|
|
|
|
y = anchor_rect.y + anchor_rect.height;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
x = anchor_rect.x + anchor_rect.width;
|
|
|
|
y = anchor_rect.y + anchor_rect.height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
switch (gdk_popup_layout_get_surface_anchor (layout))
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
2016-07-08 08:54:36 +00:00
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width / 2;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_WEST:
|
2020-02-16 11:59:24 +00:00
|
|
|
y -= height / 2;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width / 2;
|
|
|
|
y -= height / 2;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_EAST:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width;
|
|
|
|
y -= height / 2;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
2020-02-16 11:59:24 +00:00
|
|
|
y -= height;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width / 2;
|
|
|
|
y -= height;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
2020-02-16 11:59:24 +00:00
|
|
|
x -= width;
|
|
|
|
y -= height;
|
2016-07-08 08:54:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out_rect = (GdkRectangle) {
|
|
|
|
.x = x,
|
|
|
|
.y = y,
|
2020-02-16 11:59:24 +00:00
|
|
|
.width = width,
|
|
|
|
.height = height
|
2016-07-08 08:54:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
update_popup_layout_state (GdkSurface *surface,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2016-07-01 09:03:36 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int surface_x, surface_y;
|
|
|
|
int surface_width, surface_height;
|
2016-07-08 08:54:36 +00:00
|
|
|
GdkRectangle best_rect;
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkRectangle flipped_rect;
|
|
|
|
GdkGravity rect_anchor;
|
|
|
|
GdkGravity surface_anchor;
|
|
|
|
GdkAnchorHints anchor_hints;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
x += surface->parent->shadow_left;
|
|
|
|
y += surface->parent->shadow_top;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
surface_x = x;
|
|
|
|
surface_y = y;
|
2018-03-20 14:14:10 +00:00
|
|
|
surface_width = width + surface->shadow_left + surface->shadow_right;
|
|
|
|
surface_height = height + surface->shadow_top + surface->shadow_bottom;
|
2016-09-12 10:46:44 +00:00
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_wayland_surface_move_resize (surface,
|
|
|
|
surface_x, surface_y,
|
|
|
|
surface_width, surface_height);
|
2016-09-12 10:46:44 +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);
|
|
|
|
anchor_hints = gdk_popup_layout_get_anchor_hints (layout);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
calculate_popup_rect (surface, layout, &best_rect);
|
|
|
|
|
|
|
|
flipped_rect = best_rect;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
if (x != best_rect.x &&
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor_hints & GDK_ANCHOR_FLIP_X)
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
|
|
|
GdkRectangle flipped_x_rect;
|
|
|
|
GdkGravity flipped_rect_anchor;
|
2018-03-20 11:05:26 +00:00
|
|
|
GdkGravity flipped_surface_anchor;
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkPopupLayout *flipped_layout;
|
|
|
|
|
|
|
|
flipped_rect_anchor = gdk_gravity_flip_horizontally (rect_anchor);
|
|
|
|
flipped_surface_anchor = gdk_gravity_flip_horizontally (surface_anchor);
|
|
|
|
flipped_layout = gdk_popup_layout_copy (layout);
|
|
|
|
gdk_popup_layout_set_rect_anchor (flipped_layout,
|
|
|
|
flipped_rect_anchor);
|
|
|
|
gdk_popup_layout_set_surface_anchor (flipped_layout,
|
|
|
|
flipped_surface_anchor);
|
2018-03-20 14:14:10 +00:00
|
|
|
calculate_popup_rect (surface,
|
2020-02-16 11:59:24 +00:00
|
|
|
flipped_layout,
|
2016-07-08 08:54:36 +00:00
|
|
|
&flipped_x_rect);
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_popup_layout_unref (flipped_layout);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
if (flipped_x_rect.x == x)
|
2020-02-16 11:59:24 +00:00
|
|
|
flipped_rect.x = x;
|
2016-07-08 08:54:36 +00:00
|
|
|
}
|
|
|
|
if (y != best_rect.y &&
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor_hints & GDK_ANCHOR_FLIP_Y)
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
|
|
|
GdkRectangle flipped_y_rect;
|
|
|
|
GdkGravity flipped_rect_anchor;
|
2018-03-20 11:05:26 +00:00
|
|
|
GdkGravity flipped_surface_anchor;
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkPopupLayout *flipped_layout;
|
|
|
|
|
|
|
|
flipped_rect_anchor = gdk_gravity_flip_vertically (rect_anchor);
|
|
|
|
flipped_surface_anchor = gdk_gravity_flip_vertically (surface_anchor);
|
|
|
|
flipped_layout = gdk_popup_layout_copy (layout);
|
|
|
|
gdk_popup_layout_set_rect_anchor (flipped_layout,
|
|
|
|
flipped_rect_anchor);
|
|
|
|
gdk_popup_layout_set_surface_anchor (flipped_layout,
|
|
|
|
flipped_surface_anchor);
|
2018-03-20 14:14:10 +00:00
|
|
|
calculate_popup_rect (surface,
|
2020-02-16 11:59:24 +00:00
|
|
|
flipped_layout,
|
2016-07-08 08:54:36 +00:00
|
|
|
&flipped_y_rect);
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_popup_layout_unref (flipped_layout);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
if (flipped_y_rect.y == y)
|
2020-02-16 11:59:24 +00:00
|
|
|
flipped_rect.y = y;
|
2016-07-08 08:54:36 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
if (flipped_rect.x != best_rect.x)
|
|
|
|
{
|
|
|
|
rect_anchor = gdk_gravity_flip_horizontally (rect_anchor);
|
|
|
|
surface_anchor = gdk_gravity_flip_horizontally (surface_anchor);
|
|
|
|
}
|
|
|
|
if (flipped_rect.y != best_rect.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;
|
2016-07-08 08:54:36 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
static gpointer
|
2020-02-16 11:59:24 +00:00
|
|
|
create_dynamic_positioner (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
2020-02-16 19:09:42 +00:00
|
|
|
GdkPopupLayout *layout,
|
|
|
|
gboolean ack_parent_configure)
|
2013-04-25 15:11:02 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkSurface *parent = surface->parent;
|
2016-07-08 08:54:36 +00:00
|
|
|
GdkWaylandDisplay *display =
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2016-07-01 09:03:36 +00:00
|
|
|
GdkRectangle geometry;
|
2016-07-08 08:54:36 +00:00
|
|
|
uint32_t constraint_adjustment = ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE;
|
2020-02-16 11:59:24 +00:00
|
|
|
const GdkRectangle *anchor_rect;
|
2020-07-24 13:54:49 +00:00
|
|
|
int real_anchor_rect_x, real_anchor_rect_y;
|
|
|
|
int anchor_rect_width, anchor_rect_height;
|
2020-02-16 11:59:24 +00:00
|
|
|
int rect_anchor_dx;
|
|
|
|
int rect_anchor_dy;
|
|
|
|
GdkGravity rect_anchor;
|
|
|
|
GdkGravity surface_anchor;
|
|
|
|
GdkAnchorHints anchor_hints;
|
2013-04-25 15:11:02 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
geometry = (GdkRectangle) {
|
|
|
|
.x = impl->margin_left,
|
|
|
|
.y = impl->margin_top,
|
|
|
|
.width = width - (impl->margin_left + impl->margin_right),
|
|
|
|
.height = height - (impl->margin_top + impl->margin_bottom),
|
|
|
|
};
|
2019-07-24 16:44:32 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor_rect = gdk_popup_layout_get_anchor_rect (layout);
|
|
|
|
real_anchor_rect_x = anchor_rect->x - parent->shadow_left;
|
|
|
|
real_anchor_rect_y = anchor_rect->y - parent->shadow_top;
|
|
|
|
|
2020-08-09 20:00:19 +00:00
|
|
|
anchor_rect_width = MAX (anchor_rect->width, 1);
|
|
|
|
anchor_rect_height = MAX (anchor_rect->height, 1);
|
2013-08-30 11:55:37 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_popup_layout_get_offset (layout, &rect_anchor_dx, &rect_anchor_dy);
|
2016-07-08 08:54:36 +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);
|
|
|
|
|
|
|
|
anchor_hints = gdk_popup_layout_get_anchor_hints (layout);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
switch (display->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
{
|
|
|
|
struct xdg_positioner *positioner;
|
|
|
|
enum xdg_positioner_anchor anchor;
|
|
|
|
enum xdg_positioner_gravity gravity;
|
|
|
|
|
|
|
|
positioner = xdg_wm_base_create_positioner (display->xdg_wm_base);
|
|
|
|
|
|
|
|
xdg_positioner_set_size (positioner, geometry.width, geometry.height);
|
|
|
|
xdg_positioner_set_anchor_rect (positioner,
|
|
|
|
real_anchor_rect_x,
|
|
|
|
real_anchor_rect_y,
|
|
|
|
anchor_rect_width,
|
|
|
|
anchor_rect_height);
|
2020-02-16 11:59:24 +00:00
|
|
|
xdg_positioner_set_offset (positioner, rect_anchor_dx, rect_anchor_dy);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor = rect_anchor_to_anchor (rect_anchor);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_positioner_set_anchor (positioner, anchor);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gravity = surface_anchor_to_gravity (surface_anchor);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_positioner_set_gravity (positioner, gravity);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_FLIP_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_FLIP_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y;
|
|
|
|
xdg_positioner_set_constraint_adjustment (positioner,
|
|
|
|
constraint_adjustment);
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
if (xdg_positioner_get_version (positioner) >=
|
|
|
|
XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION)
|
|
|
|
xdg_positioner_set_reactive (positioner);
|
|
|
|
|
|
|
|
if (ack_parent_configure &&
|
|
|
|
xdg_positioner_get_version (positioner) >=
|
|
|
|
XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
|
|
|
|
int parent_width;
|
|
|
|
int parent_height;
|
|
|
|
|
|
|
|
parent_width = parent->width - (parent_impl->margin_left +
|
|
|
|
parent_impl->margin_right);
|
|
|
|
parent_height = parent->height - (parent_impl->margin_top +
|
|
|
|
parent_impl->margin_bottom);
|
|
|
|
|
|
|
|
xdg_positioner_set_parent_size (positioner,
|
|
|
|
parent_width,
|
|
|
|
parent_height);
|
|
|
|
xdg_positioner_set_parent_configure (positioner,
|
|
|
|
parent_impl->last_configure_serial);
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
return positioner;
|
|
|
|
}
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
{
|
|
|
|
struct zxdg_positioner_v6 *positioner;
|
|
|
|
enum zxdg_positioner_v6_anchor anchor;
|
|
|
|
enum zxdg_positioner_v6_gravity gravity;
|
|
|
|
|
|
|
|
positioner = zxdg_shell_v6_create_positioner (display->zxdg_shell_v6);
|
|
|
|
|
|
|
|
zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
|
|
|
|
zxdg_positioner_v6_set_anchor_rect (positioner,
|
|
|
|
real_anchor_rect_x,
|
|
|
|
real_anchor_rect_y,
|
|
|
|
anchor_rect_width,
|
|
|
|
anchor_rect_height);
|
|
|
|
zxdg_positioner_v6_set_offset (positioner,
|
2020-02-16 11:59:24 +00:00
|
|
|
rect_anchor_dx,
|
|
|
|
rect_anchor_dy);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
anchor = rect_anchor_to_anchor_legacy (rect_anchor);
|
2017-12-18 12:00:36 +00:00
|
|
|
zxdg_positioner_v6_set_anchor (positioner, anchor);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gravity = surface_anchor_to_gravity_legacy (surface_anchor);
|
2017-12-18 12:00:36 +00:00
|
|
|
zxdg_positioner_v6_set_gravity (positioner, gravity);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_FLIP_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_FLIP_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_SLIDE_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_X)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X;
|
2020-02-16 11:59:24 +00:00
|
|
|
if (anchor_hints & GDK_ANCHOR_RESIZE_Y)
|
2017-12-18 12:00:36 +00:00
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y;
|
|
|
|
zxdg_positioner_v6_set_constraint_adjustment (positioner,
|
|
|
|
constraint_adjustment);
|
|
|
|
|
|
|
|
return positioner;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2020-02-16 15:24:12 +00:00
|
|
|
static gboolean
|
|
|
|
can_map_grabbing_popup (GdkSurface *surface,
|
|
|
|
GdkSurface *parent)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
GdkSurface *top_most_popup;
|
|
|
|
|
|
|
|
if (!display_wayland->current_grabbing_popups)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
top_most_popup = g_list_first (display_wayland->current_grabbing_popups)->data;
|
|
|
|
return top_most_popup == parent;
|
|
|
|
}
|
|
|
|
|
2020-04-18 20:51:21 +00:00
|
|
|
static gboolean
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
|
|
|
|
GdkSurface *parent,
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkWaylandSeat *grab_input_seat,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
|
2017-12-18 12:00:36 +00:00
|
|
|
gpointer positioner;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
if (!impl->display_server.wl_surface)
|
2020-04-18 20:51:21 +00:00
|
|
|
return FALSE;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_shell_surface (parent))
|
2020-04-18 20:51:21 +00:00
|
|
|
return FALSE;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (is_realized_toplevel (surface))
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
|
|
|
g_warning ("Can't map popup, already mapped as toplevel");
|
2020-04-18 20:51:21 +00:00
|
|
|
return FALSE;
|
2016-07-08 08:54:36 +00:00
|
|
|
}
|
2017-12-18 12:00:36 +00:00
|
|
|
if (is_realized_popup (surface))
|
2016-07-08 08:54:36 +00:00
|
|
|
{
|
|
|
|
g_warning ("Can't map popup, already mapped");
|
2020-04-18 20:51:21 +00:00
|
|
|
return FALSE;
|
2016-07-08 08:54:36 +00:00
|
|
|
}
|
2020-02-16 15:24:12 +00:00
|
|
|
|
2019-04-24 11:33:12 +00:00
|
|
|
if (grab_input_seat &&
|
2020-02-16 15:24:12 +00:00
|
|
|
!can_map_grabbing_popup (surface, parent))
|
2016-09-02 10:51:34 +00:00
|
|
|
{
|
2020-02-16 15:24:12 +00:00
|
|
|
g_warning ("Tried to map a grabbing popup with a non-top most parent");
|
2020-04-18 20:51:21 +00:00
|
|
|
return FALSE;
|
2016-09-02 10:51:34 +00:00
|
|
|
}
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_freeze_updates (surface);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
positioner = create_dynamic_positioner (surface, width, height, layout, FALSE);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
impl->display_server.xdg_surface =
|
|
|
|
xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
|
|
|
|
impl->display_server.wl_surface);
|
2020-01-07 16:13:22 +00:00
|
|
|
|
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.xdg_surface,
|
|
|
|
impl->event_queue);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_surface_add_listener (impl->display_server.xdg_surface,
|
|
|
|
&xdg_surface_listener,
|
|
|
|
surface);
|
|
|
|
impl->display_server.xdg_popup =
|
|
|
|
xdg_surface_get_popup (impl->display_server.xdg_surface,
|
2016-07-01 09:03:36 +00:00
|
|
|
parent_impl->display_server.xdg_surface,
|
|
|
|
positioner);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_popup_add_listener (impl->display_server.xdg_popup,
|
2016-07-01 09:03:36 +00:00
|
|
|
&xdg_popup_listener,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_positioner_destroy (positioner);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
impl->display_server.zxdg_surface_v6 =
|
|
|
|
zxdg_shell_v6_get_xdg_surface (display->zxdg_shell_v6,
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
zxdg_surface_v6_add_listener (impl->display_server.zxdg_surface_v6,
|
|
|
|
&zxdg_surface_v6_listener,
|
|
|
|
surface);
|
|
|
|
impl->display_server.zxdg_popup_v6 =
|
|
|
|
zxdg_surface_v6_get_popup (impl->display_server.zxdg_surface_v6,
|
|
|
|
parent_impl->display_server.zxdg_surface_v6,
|
|
|
|
positioner);
|
|
|
|
zxdg_popup_v6_add_listener (impl->display_server.zxdg_popup_v6,
|
|
|
|
&zxdg_popup_v6_listener,
|
|
|
|
surface);
|
|
|
|
zxdg_positioner_v6_destroy (positioner);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2014-03-10 17:30:21 +00:00
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
if (grab_input_seat)
|
2016-10-18 17:18:14 +00:00
|
|
|
{
|
2019-04-20 00:08:14 +00:00
|
|
|
struct wl_seat *seat;
|
|
|
|
guint32 serial;
|
|
|
|
|
|
|
|
seat = gdk_wayland_seat_get_wl_seat (GDK_SEAT (grab_input_seat));
|
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (grab_input_seat, NULL);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
switch (display->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_popup_grab (impl->display_server.xdg_popup, seat, serial);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_popup_v6_grab (impl->display_server.zxdg_popup_v6, seat, serial);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2016-10-18 17:18:14 +00:00
|
|
|
}
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
|
2016-07-01 09:03:36 +00:00
|
|
|
wl_surface_commit (impl->display_server.wl_surface);
|
2016-09-02 10:51:34 +00:00
|
|
|
|
2020-03-09 15:04:19 +00:00
|
|
|
if (GDK_IS_POPUP (surface))
|
2020-02-16 11:59:24 +00:00
|
|
|
{
|
|
|
|
g_assert (impl->popup_state == POPUP_STATE_IDLE);
|
|
|
|
impl->popup_state = POPUP_STATE_WAITING_FOR_CONFIGURE;
|
|
|
|
freeze_popup_toplevel_state (surface);
|
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
display->current_popups = g_list_append (display->current_popups, surface);
|
2020-02-16 15:24:12 +00:00
|
|
|
if (grab_input_seat)
|
|
|
|
{
|
|
|
|
display->current_grabbing_popups =
|
|
|
|
g_list_prepend (display->current_grabbing_popups, surface);
|
|
|
|
}
|
2020-04-18 20:51:21 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2013-11-11 23:02:19 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
static GdkWaylandSeat *
|
2017-12-18 12:10:47 +00:00
|
|
|
find_grab_input_seat (GdkSurface *surface,
|
2020-02-10 09:55:59 +00:00
|
|
|
GdkSurface *parent)
|
2014-05-15 21:12:09 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkWaylandSurface *tmp_impl;
|
2014-05-15 21:12:09 +00:00
|
|
|
|
|
|
|
/* Use the device that was used for the grab as the device for
|
2020-09-12 16:01:04 +00:00
|
|
|
* the popup surface setup - so this relies on GTK taking the
|
2018-03-20 14:14:10 +00:00
|
|
|
* grab before showing the popup surface.
|
2014-05-15 21:12:09 +00:00
|
|
|
*/
|
2014-05-15 21:14:26 +00:00
|
|
|
if (impl->grab_input_seat)
|
2019-04-20 00:08:14 +00:00
|
|
|
return GDK_WAYLAND_SEAT (impl->grab_input_seat);
|
2014-05-15 21:12:09 +00:00
|
|
|
|
2020-02-10 09:55:59 +00:00
|
|
|
while (parent)
|
2014-05-15 21:12:09 +00:00
|
|
|
{
|
2020-02-10 09:55:59 +00:00
|
|
|
tmp_impl = GDK_WAYLAND_SURFACE (parent);
|
2014-05-15 21:12:09 +00:00
|
|
|
|
2014-05-15 21:14:26 +00:00
|
|
|
if (tmp_impl->grab_input_seat)
|
2019-04-20 00:08:14 +00:00
|
|
|
return GDK_WAYLAND_SEAT (tmp_impl->grab_input_seat);
|
2014-05-15 21:14:26 +00:00
|
|
|
|
2020-02-10 09:55:59 +00:00
|
|
|
parent = parent->parent;
|
2014-05-15 21:12:09 +00:00
|
|
|
}
|
|
|
|
|
2014-05-15 21:14:26 +00:00
|
|
|
return NULL;
|
2014-05-15 21:12:09 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 23:01:52 +00:00
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
should_be_mapped (GdkSurface *surface)
|
2014-08-13 23:01:52 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2015-10-13 12:39:02 +00:00
|
|
|
|
2020-09-12 16:01:04 +00:00
|
|
|
/* Don't map crazy temp that GTK uses for internal X11 shenanigans. */
|
2020-03-09 15:04:19 +00:00
|
|
|
if (GDK_IS_DRAG_SURFACE (surface) && surface->x < 0 && surface->y < 0)
|
2014-08-13 23:01:52 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-02-29 17:25:51 +00:00
|
|
|
if (impl->is_drag_surface)
|
2015-10-13 12:39:02 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2014-08-13 23:01:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_wayland_surface_map_toplevel (GdkSurface *surface)
|
2013-11-11 23:02:19 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (!should_be_mapped (surface))
|
2014-08-13 23:01:52 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-03 23:22:36 +00:00
|
|
|
if (impl->mapped)
|
2015-10-13 12:39:02 +00:00
|
|
|
return;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_wayland_surface_create_xdg_toplevel (surface);
|
2015-10-13 12:39:02 +00:00
|
|
|
|
|
|
|
impl->mapped = TRUE;
|
2013-04-25 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_show (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
gboolean already_mapped)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (!impl->display_server.wl_surface)
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_create_surface (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_wayland_surface_map_toplevel (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-05 15:53:38 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
unmap_popups_for_surface (GdkSurface *surface)
|
2016-09-05 15:53:38 +00:00
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
GList *l;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2016-09-05 15:53:38 +00:00
|
|
|
for (l = display_wayland->current_popups; l; l = l->next)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *popup = l->data;
|
2016-09-05 15:53:38 +00:00
|
|
|
|
2020-03-17 14:26:58 +00:00
|
|
|
if (popup->parent == surface)
|
2016-09-05 15:53:38 +00:00
|
|
|
{
|
|
|
|
g_warning ("Tried to unmap the parent of a popup");
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_hide (popup);
|
2016-09-05 15:53:38 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2019-05-25 18:08:43 +00:00
|
|
|
gdk_wayland_surface_hide_surface (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
unmap_popups_for_surface (surface);
|
2016-09-05 15:53:38 +00:00
|
|
|
|
2019-05-25 18:08:43 +00:00
|
|
|
if (impl->display_server.wl_surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-05-25 18:08:43 +00:00
|
|
|
if (impl->dummy_egl_surface)
|
|
|
|
{
|
|
|
|
eglDestroySurface (display_wayland->egl_display, impl->dummy_egl_surface);
|
|
|
|
impl->dummy_egl_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (impl->display_server.dummy_egl_window)
|
|
|
|
{
|
|
|
|
wl_egl_window_destroy (impl->display_server.dummy_egl_window);
|
|
|
|
impl->display_server.dummy_egl_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (impl->egl_surface)
|
|
|
|
{
|
|
|
|
eglDestroySurface (display_wayland->egl_display, impl->egl_surface);
|
|
|
|
impl->egl_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (impl->display_server.egl_window)
|
|
|
|
{
|
|
|
|
wl_egl_window_destroy (impl->display_server.egl_window);
|
|
|
|
impl->display_server.egl_window = NULL;
|
|
|
|
}
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
if (impl->display_server.xdg_toplevel)
|
2014-06-19 19:10:01 +00:00
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_toplevel_destroy (impl->display_server.xdg_toplevel);
|
2016-07-01 09:03:36 +00:00
|
|
|
impl->display_server.xdg_toplevel = NULL;
|
2014-06-19 19:10:01 +00:00
|
|
|
}
|
2016-02-02 16:42:52 +00:00
|
|
|
else if (impl->display_server.xdg_popup)
|
2014-06-19 19:10:01 +00:00
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_popup_destroy (impl->display_server.xdg_popup);
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.xdg_popup = NULL;
|
2016-09-02 10:51:34 +00:00
|
|
|
display_wayland->current_popups =
|
2018-03-20 14:14:10 +00:00
|
|
|
g_list_remove (display_wayland->current_popups, surface);
|
2020-02-16 15:24:12 +00:00
|
|
|
display_wayland->current_grabbing_popups =
|
|
|
|
g_list_remove (display_wayland->current_grabbing_popups, surface);
|
2014-06-19 19:10:01 +00:00
|
|
|
}
|
2016-07-01 09:03:36 +00:00
|
|
|
if (impl->display_server.xdg_surface)
|
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
xdg_surface_destroy (impl->display_server.xdg_surface);
|
2016-07-01 09:03:36 +00:00
|
|
|
impl->display_server.xdg_surface = NULL;
|
2016-07-08 08:54:36 +00:00
|
|
|
if (!impl->initial_configure_received)
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_thaw_updates (surface);
|
2016-07-08 08:54:36 +00:00
|
|
|
else
|
|
|
|
impl->initial_configure_received = FALSE;
|
2016-07-01 09:03:36 +00:00
|
|
|
}
|
2014-06-19 19:10:01 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (impl->display_server.zxdg_toplevel_v6)
|
|
|
|
{
|
|
|
|
zxdg_toplevel_v6_destroy (impl->display_server.zxdg_toplevel_v6);
|
|
|
|
impl->display_server.zxdg_toplevel_v6 = NULL;
|
|
|
|
}
|
|
|
|
else if (impl->display_server.zxdg_popup_v6)
|
|
|
|
{
|
|
|
|
zxdg_popup_v6_destroy (impl->display_server.zxdg_popup_v6);
|
|
|
|
impl->display_server.zxdg_popup_v6 = NULL;
|
|
|
|
display_wayland->current_popups =
|
|
|
|
g_list_remove (display_wayland->current_popups, surface);
|
2020-02-16 15:24:12 +00:00
|
|
|
display_wayland->current_grabbing_popups =
|
|
|
|
g_list_remove (display_wayland->current_grabbing_popups, surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
|
|
|
if (impl->display_server.zxdg_surface_v6)
|
|
|
|
{
|
|
|
|
zxdg_surface_v6_destroy (impl->display_server.zxdg_surface_v6);
|
|
|
|
impl->display_server.zxdg_surface_v6 = NULL;
|
|
|
|
if (!impl->initial_configure_received)
|
|
|
|
gdk_surface_thaw_updates (surface);
|
|
|
|
else
|
|
|
|
impl->initial_configure_received = FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-10 18:23:17 +00:00
|
|
|
impl->awaiting_frame = FALSE;
|
|
|
|
if (impl->awaiting_frame_frozen)
|
2015-02-25 13:46:54 +00:00
|
|
|
{
|
2019-12-10 18:23:17 +00:00
|
|
|
impl->awaiting_frame_frozen = FALSE;
|
2019-06-28 16:45:44 +00:00
|
|
|
gdk_surface_thaw_updates (surface);
|
2015-02-25 13:46:54 +00:00
|
|
|
}
|
|
|
|
|
2020-03-09 15:04:19 +00:00
|
|
|
if (GDK_IS_POPUP (surface))
|
2020-02-16 11:59:24 +00:00
|
|
|
{
|
|
|
|
switch (impl->popup_state)
|
|
|
|
{
|
2020-02-16 19:09:42 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
|
|
|
gdk_surface_thaw_updates (surface);
|
|
|
|
G_GNUC_FALLTHROUGH;
|
2020-02-16 11:59:24 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
|
|
|
case POPUP_STATE_WAITING_FOR_FRAME:
|
|
|
|
thaw_popup_toplevel_state (surface);
|
|
|
|
break;
|
|
|
|
case POPUP_STATE_IDLE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
impl->popup_state = POPUP_STATE_IDLE;
|
|
|
|
}
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.gtk_surface)
|
2015-08-01 15:08:30 +00:00
|
|
|
{
|
2016-03-07 03:49:35 +00:00
|
|
|
gtk_surface1_destroy (impl->display_server.gtk_surface);
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.gtk_surface = NULL;
|
2017-01-25 14:53:55 +00:00
|
|
|
impl->application.was_set = FALSE;
|
2015-08-01 15:08:30 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 18:08:43 +00:00
|
|
|
wl_surface_destroy (impl->display_server.wl_surface);
|
|
|
|
impl->display_server.wl_surface = NULL;
|
|
|
|
|
|
|
|
g_slist_free (impl->display_server.outputs);
|
|
|
|
impl->display_server.outputs = NULL;
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
g_clear_pointer (&impl->toplevel.layout, gdk_toplevel_layout_unref);
|
2020-02-16 11:59:24 +00:00
|
|
|
g_clear_pointer (&impl->popup.layout, gdk_popup_layout_unref);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
2013-09-16 22:36:18 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
unset_transient_for_exported (surface);
|
2017-12-01 08:03:34 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_clear_saved_size (surface);
|
2013-09-16 22:36:18 +00:00
|
|
|
impl->mapped = FALSE;
|
2013-04-25 15:11:02 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2013-04-25 15:11:02 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_hide (GdkSurface *surface)
|
2013-04-25 15:11:02 +00:00
|
|
|
{
|
2020-04-24 21:11:00 +00:00
|
|
|
GdkSeat *seat;
|
|
|
|
|
|
|
|
seat = gdk_display_get_default_seat (surface->display);
|
2020-05-15 01:27:45 +00:00
|
|
|
if (seat)
|
|
|
|
{
|
|
|
|
if (surface->autohide)
|
|
|
|
gdk_seat_ungrab (seat);
|
2020-04-24 21:11:00 +00:00
|
|
|
|
2020-05-15 01:27:45 +00:00
|
|
|
gdk_wayland_seat_clear_touchpoints (GDK_WAYLAND_SEAT (seat), surface);
|
|
|
|
}
|
2019-05-25 18:08:43 +00:00
|
|
|
gdk_wayland_surface_hide_surface (surface);
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_surface_clear_update_area (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_move_resize (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2012-04-20 16:57:33 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2015-02-24 08:11:48 +00:00
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
surface->x = x;
|
|
|
|
surface->y = y;
|
|
|
|
gdk_wayland_surface_maybe_resize (surface, width, height, impl->scale);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
static gboolean
|
|
|
|
is_fallback_relayout_possible (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = surface->children; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkSurface *child = l->data;
|
|
|
|
|
|
|
|
if (GDK_WAYLAND_SURFACE (child)->mapped)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-29 14:51:26 +00:00
|
|
|
static gboolean gdk_wayland_surface_present_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
static void
|
|
|
|
queue_relayout_fallback (GdkSurface *surface,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (!is_fallback_relayout_possible (surface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_wayland_surface_hide_surface (surface);
|
2020-02-29 14:51:26 +00:00
|
|
|
gdk_wayland_surface_present_popup (surface,
|
|
|
|
impl->popup.unconstrained_width,
|
|
|
|
impl->popup.unconstrained_height,
|
|
|
|
layout);
|
2020-02-16 11:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_queue_relayout (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-02-16 19:09:42 +00:00
|
|
|
struct xdg_positioner *positioner;
|
2020-02-16 11:59:24 +00:00
|
|
|
|
|
|
|
g_assert (is_realized_popup (surface));
|
|
|
|
g_assert (impl->popup_state == POPUP_STATE_IDLE ||
|
|
|
|
impl->popup_state == POPUP_STATE_WAITING_FOR_FRAME);
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->popup.layout, gdk_popup_layout_unref);
|
|
|
|
impl->popup.layout = gdk_popup_layout_copy (layout);
|
|
|
|
impl->popup.unconstrained_width = width;
|
|
|
|
impl->popup.unconstrained_height = height;
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
if (!impl->display_server.xdg_popup ||
|
|
|
|
xdg_popup_get_version (impl->display_server.xdg_popup) <
|
|
|
|
XDG_POPUP_REPOSITION_SINCE_VERSION)
|
|
|
|
{
|
|
|
|
g_warning_once ("Compositor doesn't support moving popups, "
|
|
|
|
"relying on remapping");
|
|
|
|
queue_relayout_fallback (surface, layout);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
positioner = create_dynamic_positioner (surface,
|
|
|
|
width, height, layout,
|
|
|
|
TRUE);
|
|
|
|
xdg_popup_reposition (impl->display_server.xdg_popup,
|
|
|
|
positioner,
|
|
|
|
++impl->reposition_token);
|
|
|
|
xdg_positioner_destroy (positioner);
|
|
|
|
|
|
|
|
gdk_surface_freeze_updates (surface);
|
|
|
|
|
|
|
|
switch (impl->popup_state)
|
|
|
|
{
|
|
|
|
case POPUP_STATE_IDLE:
|
|
|
|
freeze_popup_toplevel_state (surface);
|
|
|
|
break;
|
|
|
|
case POPUP_STATE_WAITING_FOR_FRAME:
|
|
|
|
break;
|
|
|
|
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
|
|
|
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
impl->popup_state = POPUP_STATE_WAITING_FOR_REPOSITIONED;
|
2020-02-16 11:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_relayout_finished (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (!impl->initial_configure_received)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-02-16 19:09:42 +00:00
|
|
|
if (impl->reposition_token != impl->received_reposition_token)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-01-12 17:08:32 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_wayland_surface_map_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2017-01-12 17:08:32 +00:00
|
|
|
{
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkSurface *parent;
|
|
|
|
GdkWaylandSeat *grab_input_seat;
|
|
|
|
|
|
|
|
parent = surface->parent;
|
|
|
|
if (!parent)
|
|
|
|
{
|
|
|
|
g_warning ("Couldn't map as surface %p as popup because it doesn't have a parent",
|
|
|
|
surface);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->autohide)
|
|
|
|
grab_input_seat = find_grab_input_seat (surface, parent);
|
|
|
|
else
|
|
|
|
grab_input_seat = NULL;
|
2020-04-18 20:51:21 +00:00
|
|
|
|
|
|
|
if (!gdk_wayland_surface_create_xdg_popup (surface,
|
|
|
|
parent,
|
|
|
|
grab_input_seat,
|
|
|
|
width, height,
|
|
|
|
layout))
|
|
|
|
return;
|
2020-02-16 11:59:24 +00:00
|
|
|
|
|
|
|
impl->popup.layout = gdk_popup_layout_copy (layout);
|
|
|
|
impl->popup.unconstrained_width = width;
|
|
|
|
impl->popup.unconstrained_height = height;
|
|
|
|
impl->mapped = TRUE;
|
2020-02-22 19:09:38 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_WITHDRAWN, 0);
|
2017-01-12 17:08:32 +00:00
|
|
|
}
|
|
|
|
|
2016-08-08 07:00:42 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
show_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2016-08-08 07:00:42 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-08-08 07:00:42 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
if (!impl->display_server.wl_surface)
|
|
|
|
gdk_wayland_surface_create_surface (surface);
|
|
|
|
|
|
|
|
gdk_wayland_surface_map_popup (surface, width, height, layout);
|
|
|
|
}
|
2017-01-12 17:08:32 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
GdkPopupLayout *layout;
|
|
|
|
} GrabPrepareData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_grabbing_popup (GdkSeat *seat,
|
|
|
|
GdkSurface *surface,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GrabPrepareData *data = user_data;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
show_popup (surface, data->width, data->height, data->layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
reposition_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
switch (impl->popup_state)
|
|
|
|
{
|
|
|
|
case POPUP_STATE_IDLE:
|
|
|
|
case POPUP_STATE_WAITING_FOR_FRAME:
|
|
|
|
do_queue_relayout (surface, width, height, layout);
|
|
|
|
break;
|
2020-02-16 19:09:42 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
|
2020-02-16 11:59:24 +00:00
|
|
|
case POPUP_STATE_WAITING_FOR_CONFIGURE:
|
|
|
|
g_warn_if_reached ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_surface_present_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
GdkWaylandSurface *impl;
|
|
|
|
|
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
if (!impl->mapped)
|
|
|
|
{
|
|
|
|
if (surface->autohide)
|
|
|
|
{
|
2020-05-15 01:27:45 +00:00
|
|
|
GdkSeat *seat;
|
|
|
|
|
|
|
|
seat = gdk_display_get_default_seat (surface->display);
|
|
|
|
if (seat)
|
2020-02-22 03:03:28 +00:00
|
|
|
{
|
2020-05-15 01:27:45 +00:00
|
|
|
GrabPrepareData data;
|
|
|
|
GdkGrabStatus result;
|
|
|
|
|
|
|
|
data = (GrabPrepareData) {
|
|
|
|
.width = width,
|
|
|
|
.height = height,
|
|
|
|
.layout = layout,
|
2020-02-22 03:03:28 +00:00
|
|
|
};
|
2020-05-15 01:27:45 +00:00
|
|
|
|
|
|
|
result = gdk_seat_grab (seat,
|
|
|
|
surface,
|
|
|
|
GDK_SEAT_CAPABILITY_ALL,
|
|
|
|
TRUE,
|
|
|
|
NULL, NULL,
|
|
|
|
show_grabbing_popup, &data);
|
|
|
|
if (result != GDK_GRAB_SUCCESS)
|
|
|
|
{
|
|
|
|
const char *grab_status[] = {
|
|
|
|
"success", "already grabbed", "invalid time",
|
|
|
|
"not viewable", "frozen", "failed"
|
|
|
|
};
|
|
|
|
g_warning ("Grab failed: %s", grab_status[result]);
|
|
|
|
}
|
2020-02-22 03:03:28 +00:00
|
|
|
}
|
2020-02-16 11:59:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
show_popup (surface, width, height, layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-21 20:30:42 +00:00
|
|
|
if (impl->popup.unconstrained_width == width &&
|
|
|
|
impl->popup.unconstrained_height == height &&
|
|
|
|
gdk_popup_layout_equal (impl->popup.layout, layout))
|
|
|
|
return TRUE;
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
reposition_popup (surface, width, height, layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (impl->display_server.xdg_popup && !is_relayout_finished (surface))
|
|
|
|
wl_display_dispatch_queue (display_wayland->wl_display, impl->event_queue);
|
|
|
|
|
|
|
|
if (impl->display_server.xdg_popup)
|
|
|
|
{
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-08-08 07:00:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_get_geometry (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
|
|
|
if (x)
|
2018-03-20 14:14:10 +00:00
|
|
|
*x = surface->x;
|
2010-12-18 20:38:49 +00:00
|
|
|
if (y)
|
2018-03-20 14:14:10 +00:00
|
|
|
*y = surface->y;
|
2010-12-18 20:38:49 +00:00
|
|
|
if (width)
|
2018-03-20 14:14:10 +00:00
|
|
|
*width = surface->width;
|
2010-12-18 20:38:49 +00:00
|
|
|
if (height)
|
2018-03-20 14:14:10 +00:00
|
|
|
*height = surface->height;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_get_root_coords (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *root_x,
|
|
|
|
int *root_y)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2016-08-04 06:07:47 +00:00
|
|
|
/*
|
|
|
|
* Wayland does not have a global coordinate space shared between surfaces. In
|
|
|
|
* fact, for regular toplevels, we have no idea where our surfaces are
|
|
|
|
* positioned, relatively.
|
|
|
|
*
|
|
|
|
* However, there are some cases like popups and subsurfaces where we do have
|
2018-03-20 14:14:10 +00:00
|
|
|
* some amount of control over the placement of our surface, and we can
|
|
|
|
* semi-accurately control the x/y position of these surfaces, if they are
|
2016-08-04 06:07:47 +00:00
|
|
|
* relative to another surface.
|
|
|
|
*
|
|
|
|
* To pretend we have something called a root coordinate space, assume all
|
2018-03-20 14:14:10 +00:00
|
|
|
* parent-less surfaces are positioned in (0, 0), and all relative positioned
|
2016-08-04 06:07:47 +00:00
|
|
|
* popups and subsurfaces are placed within this fake root coordinate space.
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* For example a 200x200 large toplevel surface will have the position (0, 0).
|
2016-08-04 06:07:47 +00:00
|
|
|
* If a popup positioned in the middle of the toplevel will have the fake
|
|
|
|
* position (100,100). Furthermore, if a positioned is placed in the middle
|
|
|
|
* that popup, will have the fake position (150,150), even though it has the
|
2018-03-20 14:14:10 +00:00
|
|
|
* relative position (50,50). These three surfaces would make up one single
|
2016-08-04 06:07:47 +00:00
|
|
|
* fake root coordinate space.
|
|
|
|
*/
|
2012-04-23 16:26:49 +00:00
|
|
|
|
2013-08-30 07:23:56 +00:00
|
|
|
if (root_x)
|
2018-03-20 14:14:10 +00:00
|
|
|
*root_x = surface->x + x;
|
2013-08-30 07:23:56 +00:00
|
|
|
|
|
|
|
if (root_y)
|
2018-03-20 14:14:10 +00:00
|
|
|
*root_y = surface->y + y;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_get_device_state (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkDevice *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *x,
|
|
|
|
double *y,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkModifierType *mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2020-08-26 20:32:31 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
return FALSE;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2020-08-26 20:33:49 +00:00
|
|
|
gdk_wayland_device_query_state (device, surface, x, y, mask);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2020-08-26 20:32:31 +00:00
|
|
|
return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 21:23:29 +00:00
|
|
|
static void
|
2020-03-01 19:29:06 +00:00
|
|
|
gdk_wayland_surface_set_input_region (GdkSurface *surface,
|
|
|
|
cairo_region_t *input_region)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2014-03-17 20:02:47 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2014-03-17 20:02:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->input_region, cairo_region_destroy);
|
2014-11-07 16:16:59 +00:00
|
|
|
|
2020-03-01 19:29:06 +00:00
|
|
|
if (input_region)
|
|
|
|
impl->input_region = cairo_region_copy (input_region);
|
2014-11-07 16:16:59 +00:00
|
|
|
|
2016-07-01 08:48:16 +00:00
|
|
|
impl->input_region_dirty = TRUE;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_destroy (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
gboolean foreign_destroy)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-03-23 13:11:46 +00:00
|
|
|
GdkWaylandDisplay *display;
|
2019-05-24 10:59:38 +00:00
|
|
|
GdkFrameClock *frame_clock;
|
2019-03-23 13:11:46 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
/* Wayland surfaces can't be externally destroyed; we may possibly
|
2013-09-16 21:23:29 +00:00
|
|
|
* eventually want to use this path at display close-down
|
|
|
|
*/
|
2013-04-25 15:11:02 +00:00
|
|
|
g_return_if_fail (!foreign_destroy);
|
|
|
|
|
2019-05-25 18:08:43 +00:00
|
|
|
gdk_wayland_surface_hide_surface (surface);
|
2017-11-06 23:30:27 +00:00
|
|
|
|
2019-05-24 10:59:38 +00:00
|
|
|
frame_clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
g_signal_handlers_disconnect_by_func (frame_clock, on_frame_clock_before_paint, surface);
|
|
|
|
g_signal_handlers_disconnect_by_func (frame_clock, on_frame_clock_after_paint, surface);
|
|
|
|
|
2019-03-23 13:11:46 +00:00
|
|
|
display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
display->toplevels = g_list_remove (display->toplevels, surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_focus (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-03-08 09:03:06 +00:00
|
|
|
|
|
|
|
if (!impl->display_server.gtk_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* We didn't have an event to fetch a time from, meaning we have nothing valid
|
|
|
|
* to send. This should rather be translated to a 'needs-attention' request or
|
|
|
|
* something.
|
|
|
|
*/
|
|
|
|
if (timestamp == GDK_CURRENT_TIME)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 07:01:22 +00:00
|
|
|
static void
|
|
|
|
gtk_surface_configure (void *data,
|
|
|
|
struct gtk_surface1 *gtk_surface,
|
|
|
|
struct wl_array *states)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState new_state = 0;
|
2016-06-28 07:01:22 +00:00
|
|
|
uint32_t *p;
|
|
|
|
|
|
|
|
wl_array_for_each (p, states)
|
|
|
|
{
|
|
|
|
uint32_t state = *p;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case GTK_SURFACE1_STATE_TILED:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= GDK_TOPLEVEL_STATE_TILED;
|
2016-06-28 07:01:22 +00:00
|
|
|
break;
|
2017-08-17 03:35:52 +00:00
|
|
|
|
|
|
|
/* Since v2 */
|
|
|
|
case GTK_SURFACE1_STATE_TILED_TOP:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= (GDK_TOPLEVEL_STATE_TILED | GDK_TOPLEVEL_STATE_TOP_TILED);
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_STATE_TILED_RIGHT:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= (GDK_TOPLEVEL_STATE_TILED | GDK_TOPLEVEL_STATE_RIGHT_TILED);
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_STATE_TILED_BOTTOM:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= (GDK_TOPLEVEL_STATE_TILED | GDK_TOPLEVEL_STATE_BOTTOM_TILED);
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_STATE_TILED_LEFT:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= (GDK_TOPLEVEL_STATE_TILED | GDK_TOPLEVEL_STATE_LEFT_TILED);
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Unknown state */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.toplevel.state |= new_state;
|
2017-08-17 03:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_surface_configure_edges (void *data,
|
|
|
|
struct gtk_surface1 *gtk_surface,
|
|
|
|
struct wl_array *edge_constraints)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (data);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState new_state = 0;
|
2017-08-17 03:35:52 +00:00
|
|
|
uint32_t *p;
|
|
|
|
|
|
|
|
wl_array_for_each (p, edge_constraints)
|
|
|
|
{
|
|
|
|
uint32_t constraint = *p;
|
|
|
|
|
|
|
|
switch (constraint)
|
|
|
|
{
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_TOP:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= GDK_TOPLEVEL_STATE_TOP_RESIZABLE;
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_RIGHT:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE;
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_BOTTOM:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE;
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_LEFT:
|
2020-09-10 04:39:03 +00:00
|
|
|
new_state |= GDK_TOPLEVEL_STATE_LEFT_RESIZABLE;
|
2017-08-17 03:35:52 +00:00
|
|
|
break;
|
2016-06-28 07:01:22 +00:00
|
|
|
default:
|
|
|
|
/* Unknown state */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:54:32 +00:00
|
|
|
impl->pending.toplevel.state |= new_state;
|
2016-06-28 07:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct gtk_surface1_listener gtk_surface_listener = {
|
2017-08-17 03:35:52 +00:00
|
|
|
gtk_surface_configure,
|
|
|
|
gtk_surface_configure_edges
|
2016-06-28 07:01:22 +00:00
|
|
|
};
|
|
|
|
|
2015-03-06 03:40:12 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_init_gtk_surface (GdkSurface *surface)
|
2015-03-06 03:40:12 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2015-03-06 03:40:12 +00:00
|
|
|
GdkWaylandDisplay *display =
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2015-03-06 03:40:12 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.gtk_surface != NULL)
|
2015-03-06 03:40:12 +00:00
|
|
|
return;
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2015-03-06 03:40:12 +00:00
|
|
|
return;
|
|
|
|
if (display->gtk_shell == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-07 03:49:35 +00:00
|
|
|
impl->display_server.gtk_surface =
|
|
|
|
gtk_shell1_get_gtk_surface (display->gtk_shell,
|
|
|
|
impl->display_server.wl_surface);
|
2020-01-07 16:13:22 +00:00
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.gtk_surface,
|
|
|
|
impl->event_queue);
|
2020-02-29 18:06:22 +00:00
|
|
|
gdk_wayland_surface_set_geometry_hints (surface,
|
|
|
|
&impl->geometry_hints,
|
|
|
|
impl->geometry_mask);
|
2016-06-28 07:01:22 +00:00
|
|
|
gtk_surface1_add_listener (impl->display_server.gtk_surface,
|
|
|
|
>k_surface_listener,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface);
|
2015-03-06 03:40:12 +00:00
|
|
|
}
|
|
|
|
|
2014-09-06 00:41:06 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
maybe_set_gtk_surface_modal (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2015-03-06 03:40:12 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_init_gtk_surface (surface);
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.gtk_surface == NULL)
|
2015-03-06 03:40:12 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface->modal_hint)
|
2016-03-07 03:49:35 +00:00
|
|
|
gtk_surface1_set_modal (impl->display_server.gtk_surface);
|
2015-03-06 03:40:12 +00:00
|
|
|
else
|
2016-03-07 03:49:35 +00:00
|
|
|
gtk_surface1_unset_modal (impl->display_server.gtk_surface);
|
2015-08-01 15:03:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_set_modal_hint (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
gboolean modal)
|
2015-08-01 15:03:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
surface->modal_hint = modal;
|
|
|
|
maybe_set_gtk_surface_modal (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_set_geometry_hints (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
const GdkGeometry *geometry,
|
|
|
|
GdkSurfaceHints geom_mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2017-12-18 12:00:36 +00:00
|
|
|
int min_width, min_height;
|
|
|
|
int max_width, max_height;
|
2012-01-09 17:11:22 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2012-01-09 17:11:22 +00:00
|
|
|
|
|
|
|
impl->geometry_hints = *geometry;
|
|
|
|
impl->geometry_mask = geom_mask;
|
2016-04-05 16:17:40 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2016-04-05 16:17:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MIN_SIZE)
|
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
min_width = MAX (0, (geometry->min_width -
|
|
|
|
(impl->margin_left + impl->margin_right)));
|
|
|
|
min_height = MAX (0, (geometry->min_height -
|
|
|
|
(impl->margin_top + impl->margin_bottom)));
|
2016-04-05 16:17:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
min_width = 0;
|
|
|
|
min_height = 0;
|
2016-04-05 16:17:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MAX_SIZE)
|
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
max_width = MAX (0, (geometry->max_width -
|
|
|
|
(impl->margin_left + impl->margin_right)));
|
|
|
|
max_height = MAX (0, (geometry->max_height -
|
|
|
|
(impl->margin_top + impl->margin_bottom)));
|
2016-04-05 16:17:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
max_width = 0;
|
|
|
|
max_height = 0;
|
2016-04-05 16:17:40 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
if (impl->last_sent_min_width == min_width &&
|
|
|
|
impl->last_sent_min_height == min_height &&
|
|
|
|
impl->last_sent_max_width == max_width &&
|
|
|
|
impl->last_sent_max_height == max_height)
|
|
|
|
return;
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_min_size (impl->display_server.xdg_toplevel,
|
|
|
|
min_width, min_height);
|
|
|
|
xdg_toplevel_set_max_size (impl->display_server.xdg_toplevel,
|
|
|
|
max_width, max_height);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_min_size (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
min_width, min_height);
|
|
|
|
zxdg_toplevel_v6_set_max_size (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
max_width, max_height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2020-07-30 21:06:59 +00:00
|
|
|
|
|
|
|
impl->last_sent_min_width = min_width;
|
|
|
|
impl->last_sent_min_height = min_height;
|
|
|
|
impl->last_sent_max_width = max_width;
|
|
|
|
impl->last_sent_max_height = max_height;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_set_title (GdkSurface *surface,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *title)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2016-06-08 05:31:45 +00:00
|
|
|
const char *end;
|
2017-03-20 18:56:22 +00:00
|
|
|
gsize title_length;
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
g_return_if_fail (title != NULL);
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
2013-03-16 23:57:17 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2013-03-16 23:57:17 +00:00
|
|
|
|
2016-07-01 08:51:32 +00:00
|
|
|
if (g_strcmp0 (impl->title, title) == 0)
|
|
|
|
return;
|
|
|
|
|
2013-08-21 11:09:29 +00:00
|
|
|
g_free (impl->title);
|
2016-06-08 05:31:45 +00:00
|
|
|
|
2017-03-20 18:56:22 +00:00
|
|
|
title_length = MIN (strlen (title), MAX_WL_BUFFER_SIZE);
|
|
|
|
if (g_utf8_validate (title, title_length, &end))
|
|
|
|
{
|
|
|
|
impl->title = g_malloc (end - title + 1);
|
|
|
|
memcpy (impl->title, title, end - title);
|
|
|
|
impl->title[end - title] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
impl->title = g_utf8_make_valid (title, title_length);
|
2018-03-20 10:40:08 +00:00
|
|
|
g_warning ("Invalid utf8 passed to gdk_surface_set_title: '%s'", title);
|
2017-03-20 18:56:22 +00:00
|
|
|
}
|
2013-11-21 17:03:18 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_title (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_set_startup_id (GdkSurface *surface,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *startup_id)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-14 15:34:00 +00:00
|
|
|
static gboolean
|
2020-03-17 14:30:25 +00:00
|
|
|
check_transient_for_loop (GdkWaylandToplevel *toplevel,
|
|
|
|
GdkWaylandToplevel *parent)
|
2015-12-14 15:34:00 +00:00
|
|
|
{
|
|
|
|
while (parent)
|
|
|
|
{
|
2020-03-17 14:30:25 +00:00
|
|
|
if (parent->transient_for == toplevel)
|
2015-12-14 15:34:00 +00:00
|
|
|
return TRUE;
|
2020-03-17 14:30:25 +00:00
|
|
|
parent = parent->transient_for;
|
2015-12-14 15:34:00 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2020-03-17 14:30:25 +00:00
|
|
|
gdk_wayland_toplevel_set_transient_for (GdkWaylandToplevel *toplevel,
|
|
|
|
GdkSurface *parent)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2020-03-17 14:30:25 +00:00
|
|
|
g_return_if_fail (!parent || GDK_IS_WAYLAND_TOPLEVEL (parent));
|
2020-04-12 16:10:18 +00:00
|
|
|
g_return_if_fail (!parent ||
|
|
|
|
gdk_surface_get_display (GDK_SURFACE (toplevel)) == gdk_surface_get_display (parent));
|
2015-09-10 09:42:21 +00:00
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
if (parent)
|
2015-12-14 15:34:00 +00:00
|
|
|
{
|
2020-03-17 14:30:25 +00:00
|
|
|
GdkWaylandToplevel *parent_toplevel = GDK_WAYLAND_TOPLEVEL (parent);
|
|
|
|
|
|
|
|
if (check_transient_for_loop (toplevel, parent_toplevel))
|
|
|
|
{
|
|
|
|
g_warning ("Setting %p transient for %p would create a loop",
|
|
|
|
toplevel, parent);
|
|
|
|
return;
|
|
|
|
}
|
2015-12-14 15:34:00 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
unset_transient_for_exported (GDK_SURFACE (toplevel));
|
2016-07-13 07:24:19 +00:00
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
if (parent)
|
|
|
|
toplevel->transient_for = GDK_WAYLAND_TOPLEVEL (parent);
|
|
|
|
else
|
|
|
|
toplevel->transient_for = NULL;
|
2013-11-11 23:02:19 +00:00
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
gdk_wayland_surface_sync_parent (GDK_SURFACE (toplevel), NULL);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_wayland_surface_minimize (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2015-02-10 23:06:38 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2015-02-10 23:06:38 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-16 20:04:00 +00:00
|
|
|
#if 0
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
|
|
|
/* We cannot use set_minimized() because it does not come with a
|
|
|
|
* minimized state that we can query or get notified of. This means
|
|
|
|
* we cannot implement the full GdkSurface API
|
|
|
|
*/
|
2017-12-18 12:00:36 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_minimized (impl->display_server.xdg_toplevel);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_minimized (impl->display_server.zxdg_toplevel_v6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2019-11-16 20:04:00 +00:00
|
|
|
#endif
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_maximize (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-03-16 23:34:57 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
2013-03-16 23:34:57 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_save_size (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
if (is_realized_toplevel (surface))
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_maximized (impl->display_server.xdg_toplevel);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_maximized (impl->display_server.zxdg_toplevel_v6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
2015-02-27 23:18:00 +00:00
|
|
|
else
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_MAXIMIZED);
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_unmaximize (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-03-16 23:34:57 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
2013-03-16 23:34:57 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (is_realized_toplevel (surface))
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_unset_maximized (impl->display_server.xdg_toplevel);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_unset_maximized (impl->display_server.zxdg_toplevel_v6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
2015-02-27 23:18:00 +00:00
|
|
|
else
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_MAXIMIZED, 0);
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
static void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_fullscreen_on_monitor (GdkSurface *surface,
|
|
|
|
GdkMonitor *monitor)
|
2015-07-13 16:30:42 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-11-01 15:52:56 +00:00
|
|
|
struct wl_output *output = ((GdkWaylandMonitor *)monitor)->output;
|
2016-09-10 18:39:07 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2015-07-13 16:30:42 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_save_size (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
if (is_realized_toplevel (surface))
|
2016-07-01 09:03:36 +00:00
|
|
|
{
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_fullscreen (impl->display_server.xdg_toplevel,
|
|
|
|
output);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
output);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2016-07-01 09:03:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_FULLSCREEN);
|
2017-11-01 15:52:56 +00:00
|
|
|
impl->initial_fullscreen_output = output;
|
2016-07-01 09:03:36 +00:00
|
|
|
}
|
2015-07-13 16:30:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_fullscreen (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-01-29 18:40:02 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
2013-01-29 18:40:02 +00:00
|
|
|
|
2017-11-01 15:52:56 +00:00
|
|
|
impl->initial_fullscreen_output = NULL;
|
2015-07-13 16:30:42 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_save_size (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
if (is_realized_toplevel (surface))
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_set_fullscreen (impl->display_server.xdg_toplevel,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
2015-02-27 23:18:00 +00:00
|
|
|
else
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_FULLSCREEN);
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_unfullscreen (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-09-10 18:39:07 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
2013-01-29 18:40:02 +00:00
|
|
|
|
2017-11-01 15:52:56 +00:00
|
|
|
impl->initial_fullscreen_output = NULL;
|
2015-07-13 16:30:42 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (is_realized_toplevel (surface))
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_unset_fullscreen (impl->display_server.xdg_toplevel);
|
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_unset_fullscreen (impl->display_server.zxdg_toplevel_v6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
2015-02-27 23:18:00 +00:00
|
|
|
else
|
2017-12-18 12:00:36 +00:00
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_FULLSCREEN, 0);
|
2017-12-18 12:00:36 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_wayland_toplevel_begin_resize (GdkToplevel *toplevel,
|
|
|
|
GdkSurfaceEdge edge,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2014-08-20 18:23:58 +00:00
|
|
|
GdkEventSequence *sequence;
|
|
|
|
uint32_t resize_edges, serial;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_LEFT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_RIGHT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_LEFT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-07-01 09:03:36 +00:00
|
|
|
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_RIGHT;
|
2010-12-18 20:38:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-05-17 16:35:45 +00:00
|
|
|
g_warning ("gdk_toplevel_begin_resize: bad resize edge %d!", edge);
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2013-03-20 15:38:36 +00:00
|
|
|
return;
|
2013-09-16 21:23:29 +00:00
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (GDK_WAYLAND_SEAT (gdk_device_get_seat (device)),
|
2016-02-23 19:32:31 +00:00
|
|
|
&sequence);
|
2014-08-20 18:23:58 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_resize (impl->display_server.xdg_toplevel,
|
2016-07-01 09:03:36 +00:00
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
serial, resize_edges);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_resize (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
serial, resize_edges);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2014-08-20 18:23:58 +00:00
|
|
|
|
|
|
|
if (sequence)
|
|
|
|
gdk_wayland_device_unset_touch_grab (device, sequence);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_wayland_toplevel_begin_move (GdkToplevel *toplevel,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2014-08-20 18:23:58 +00:00
|
|
|
GdkEventSequence *sequence;
|
|
|
|
uint32_t serial;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2013-03-20 15:38:36 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (GDK_WAYLAND_SEAT (gdk_device_get_seat (device)),
|
2016-02-23 19:32:31 +00:00
|
|
|
&sequence);
|
2017-12-18 12:00:36 +00:00
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_move (impl->display_server.xdg_toplevel,
|
2016-07-01 09:03:36 +00:00
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
serial);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_move (impl->display_server.zxdg_toplevel_v6,
|
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
serial);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2014-08-20 18:23:58 +00:00
|
|
|
if (sequence)
|
|
|
|
gdk_wayland_device_unset_touch_grab (device, sequence);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_destroy_notify (GdkSurface *surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_warning ("GdkSurface %p unexpectedly destroyed", surface);
|
|
|
|
_gdk_surface_destroy (surface, TRUE);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_object_unref (surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_scale_factor (GdkSurface *surface)
|
2013-06-04 09:39:36 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2013-06-04 09:39:36 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return impl->scale;
|
|
|
|
}
|
|
|
|
|
2013-05-14 20:23:33 +00:00
|
|
|
static void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_set_opaque_region (GdkSurface *surface,
|
|
|
|
cairo_region_t *region)
|
2013-05-14 20:23:33 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2013-05-14 20:23:33 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2013-05-14 20:23:33 +00:00
|
|
|
return;
|
|
|
|
|
2014-03-17 20:08:35 +00:00
|
|
|
g_clear_pointer (&impl->opaque_region, cairo_region_destroy);
|
|
|
|
impl->opaque_region = cairo_region_reference (region);
|
2016-07-01 08:48:16 +00:00
|
|
|
impl->opaque_region_dirty = TRUE;
|
2013-05-14 20:23:33 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 22:20:14 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_set_shadow_width (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom)
|
2014-02-07 22:20:14 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-07-24 13:54:49 +00:00
|
|
|
int new_width, new_height;
|
2014-02-07 22:20:14 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2014-02-07 22:20:14 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
/* Reconfigure surface to keep the same surface geometry */
|
|
|
|
new_width = surface->width -
|
2014-11-11 11:07:24 +00:00
|
|
|
(impl->margin_left + impl->margin_right) + (left + right);
|
2018-03-20 14:14:10 +00:00
|
|
|
new_height = surface->height -
|
2014-11-11 11:07:24 +00:00
|
|
|
(impl->margin_top + impl->margin_bottom) + (top + bottom);
|
2019-07-12 13:24:18 +00:00
|
|
|
gdk_wayland_surface_maybe_resize (surface,
|
|
|
|
new_width, new_height,
|
|
|
|
impl->scale);
|
2014-11-11 11:07:24 +00:00
|
|
|
|
2014-02-27 21:54:20 +00:00
|
|
|
impl->margin_left = left;
|
|
|
|
impl->margin_right = right;
|
|
|
|
impl->margin_top = top;
|
|
|
|
impl->margin_bottom = bottom;
|
2014-02-07 22:20:14 +00:00
|
|
|
}
|
2013-06-04 09:39:36 +00:00
|
|
|
|
2014-05-24 03:01:27 +00:00
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_show_window_menu (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkEvent *event)
|
2014-05-24 03:01:27 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-12-18 12:00:36 +00:00
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2020-06-23 09:00:46 +00:00
|
|
|
GdkSeat *seat;
|
|
|
|
struct wl_seat *wl_seat;
|
2014-05-24 03:01:27 +00:00
|
|
|
double x, y;
|
2016-07-01 09:03:36 +00:00
|
|
|
uint32_t serial;
|
2014-05-24 03:01:27 +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
|
|
|
GdkEventType event_type = gdk_event_get_event_type (event);
|
|
|
|
switch ((guint) event_type)
|
2014-05-24 03:01:27 +00:00
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2014-08-13 19:05:58 +00:00
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
case GDK_TOUCH_END:
|
2014-05-24 03:01:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-12-18 12:00:36 +00:00
|
|
|
if (!is_realized_toplevel (surface))
|
2014-05-24 03:01:27 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-06-23 09:00:46 +00:00
|
|
|
seat = gdk_event_get_seat (event);
|
|
|
|
wl_seat = gdk_wayland_seat_get_wl_seat (seat);
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_position (event, &x, &y);
|
2014-05-24 03:01:27 +00:00
|
|
|
|
2020-06-23 09:00:46 +00:00
|
|
|
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, event);
|
2017-12-18 12:00:36 +00:00
|
|
|
|
|
|
|
switch (display_wayland->shell_variant)
|
|
|
|
{
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
|
|
|
|
xdg_toplevel_show_window_menu (impl->display_server.xdg_toplevel,
|
2020-06-23 09:00:46 +00:00
|
|
|
wl_seat, serial, x, y);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
|
|
|
|
zxdg_toplevel_v6_show_window_menu (impl->display_server.zxdg_toplevel_v6,
|
2020-06-23 09:00:46 +00:00
|
|
|
wl_seat, serial, x, y);
|
2017-12-18 12:00:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2014-05-24 03:01:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-09-18 02:09:10 +00:00
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_supports_edge_constraints (GdkSurface *surface)
|
2017-09-18 02:09:10 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-10-04 21:25:31 +00:00
|
|
|
struct gtk_surface1 *gtk_surface = impl->display_server.gtk_surface;
|
2017-09-18 02:09:10 +00:00
|
|
|
|
2017-10-04 21:25:31 +00:00
|
|
|
if (!gtk_surface)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gtk_surface1_get_version (gtk_surface) >= GTK_SURFACE1_CONFIGURE_EDGES_SINCE_VERSION;
|
2017-09-18 02:09:10 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
|
2018-03-20 10:40:08 +00:00
|
|
|
|
2020-01-07 16:13:22 +00:00
|
|
|
object_class->constructed = gdk_wayland_surface_constructed;
|
|
|
|
object_class->dispose = gdk_wayland_surface_dispose;
|
2019-04-22 01:14:46 +00:00
|
|
|
object_class->finalize = gdk_wayland_surface_finalize;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
|
|
|
impl_class->hide = gdk_wayland_surface_hide;
|
2019-04-22 01:14:46 +00:00
|
|
|
impl_class->get_geometry = gdk_wayland_surface_get_geometry;
|
|
|
|
impl_class->get_root_coords = gdk_wayland_surface_get_root_coords;
|
|
|
|
impl_class->get_device_state = gdk_wayland_surface_get_device_state;
|
2020-03-01 19:29:06 +00:00
|
|
|
impl_class->set_input_region = gdk_wayland_surface_set_input_region;
|
2018-03-20 10:40:08 +00:00
|
|
|
impl_class->destroy = gdk_wayland_surface_destroy;
|
2019-04-22 01:14:46 +00:00
|
|
|
impl_class->beep = gdk_wayland_surface_beep;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
|
|
|
impl_class->destroy_notify = gdk_wayland_surface_destroy_notify;
|
|
|
|
impl_class->drag_begin = _gdk_wayland_surface_drag_begin;
|
|
|
|
impl_class->get_scale_factor = gdk_wayland_surface_get_scale_factor;
|
|
|
|
impl_class->set_opaque_region = gdk_wayland_surface_set_opaque_region;
|
|
|
|
impl_class->set_shadow_width = gdk_wayland_surface_set_shadow_width;
|
|
|
|
impl_class->create_gl_context = gdk_wayland_surface_create_gl_context;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
2012-02-27 14:06:22 +00:00
|
|
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_set_grab_seat (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkSeat *seat)
|
2012-02-27 14:06:22 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2012-03-05 19:41:11 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_if_fail (surface != NULL);
|
2012-03-05 19:41:11 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2012-07-11 13:29:43 +00:00
|
|
|
impl->grab_input_seat = seat;
|
2012-02-27 14:06:22 +00:00
|
|
|
}
|
2013-01-23 21:20:05 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_get_wl_surface:
|
2018-03-20 14:14:10 +00:00
|
|
|
* @surface: (type GdkWaylandSurface): a #GdkSurface
|
2013-01-23 21:20:05 +00:00
|
|
|
*
|
2018-03-20 10:40:08 +00:00
|
|
|
* Returns the Wayland surface of a #GdkSurface.
|
2013-01-23 21:20:05 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): a Wayland wl_surface
|
|
|
|
*/
|
|
|
|
struct wl_surface *
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_wl_surface (GdkSurface *surface)
|
2013-01-23 21:20:05 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL);
|
2013-01-23 21:20:05 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
return GDK_WAYLAND_SURFACE (surface)->display_server.wl_surface;
|
2013-01-23 21:20:05 +00:00
|
|
|
}
|
|
|
|
|
2016-05-17 13:02:01 +00:00
|
|
|
struct wl_output *
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_wl_output (GdkSurface *surface)
|
2016-05-17 13:02:01 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2016-05-17 13:02:01 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL);
|
2016-05-17 13:02:01 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2016-05-17 13:02:01 +00:00
|
|
|
/* We pick the head of the list as this is the last entered output */
|
|
|
|
if (impl->display_server.outputs)
|
|
|
|
return (struct wl_output *) impl->display_server.outputs->data;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
static struct wl_egl_window *
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_wl_egl_window (GdkSurface *surface)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.egl_window == NULL)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.egl_window =
|
|
|
|
wl_egl_window_create (impl->display_server.wl_surface,
|
2019-04-22 01:14:46 +00:00
|
|
|
surface->width * impl->scale,
|
|
|
|
surface->height * impl->scale);
|
2016-02-02 16:42:52 +00:00
|
|
|
wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
return impl->display_server.egl_window;
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLSurface
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_egl_surface (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
EGLConfig config)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2014-10-09 09:06:48 +00:00
|
|
|
struct wl_egl_window *egl_window;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
if (impl->egl_surface == NULL)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
egl_window = gdk_wayland_surface_get_wl_egl_window (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
impl->egl_surface =
|
2015-02-28 03:28:28 +00:00
|
|
|
eglCreateWindowSurface (display->egl_display, config, egl_window, NULL);
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return impl->egl_surface;
|
|
|
|
}
|
|
|
|
|
2014-10-09 14:09:05 +00:00
|
|
|
EGLSurface
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_dummy_egl_surface (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
EGLConfig config)
|
2014-10-09 14:09:05 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2014-10-09 14:09:05 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL);
|
2014-10-09 14:09:05 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2014-10-09 14:09:05 +00:00
|
|
|
|
|
|
|
if (impl->dummy_egl_surface == NULL)
|
|
|
|
{
|
2016-02-02 16:42:52 +00:00
|
|
|
impl->display_server.dummy_egl_window =
|
|
|
|
wl_egl_window_create (impl->display_server.wl_surface, 1, 1);
|
2014-10-09 14:09:05 +00:00
|
|
|
|
|
|
|
impl->dummy_egl_surface =
|
2016-02-02 16:42:52 +00:00
|
|
|
eglCreateWindowSurface (display->egl_display, config, impl->display_server.dummy_egl_window, NULL);
|
2014-10-09 14:09:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return impl->dummy_egl_surface;
|
|
|
|
}
|
|
|
|
|
2017-03-13 06:33:06 +00:00
|
|
|
struct gtk_surface1 *
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_gtk_surface (GdkSurface *surface)
|
2017-03-13 06:33:06 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL);
|
2017-03-13 06:33:06 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
return GDK_WAYLAND_SURFACE (surface)->display_server.gtk_surface;
|
2017-03-13 06:33:06 +00:00
|
|
|
}
|
2014-10-09 14:09:05 +00:00
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
maybe_set_gtk_surface_dbus_properties (GdkSurface *surface)
|
2015-03-23 05:08:09 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2015-03-06 03:40:12 +00:00
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
if (impl->application.was_set)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (impl->application.application_id == NULL &&
|
|
|
|
impl->application.app_menu_path == NULL &&
|
|
|
|
impl->application.menubar_path == NULL &&
|
|
|
|
impl->application.window_object_path == NULL &&
|
|
|
|
impl->application.application_object_path == NULL &&
|
|
|
|
impl->application.unique_bus_name == NULL)
|
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_init_gtk_surface (surface);
|
2016-02-02 16:42:52 +00:00
|
|
|
if (impl->display_server.gtk_surface == NULL)
|
2015-03-06 03:40:12 +00:00
|
|
|
return;
|
2015-03-23 05:08:09 +00:00
|
|
|
|
2016-03-07 03:49:35 +00:00
|
|
|
gtk_surface1_set_dbus_properties (impl->display_server.gtk_surface,
|
|
|
|
impl->application.application_id,
|
|
|
|
impl->application.app_menu_path,
|
|
|
|
impl->application.menubar_path,
|
|
|
|
impl->application.window_object_path,
|
|
|
|
impl->application.application_object_path,
|
|
|
|
impl->application.unique_bus_name);
|
2015-03-23 05:08:09 +00:00
|
|
|
impl->application.was_set = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-08-30 11:56:45 +00:00
|
|
|
void
|
2017-12-18 12:10:47 +00:00
|
|
|
gdk_wayland_surface_set_dbus_properties_libgtk_only (GdkSurface *surface,
|
|
|
|
const char *application_id,
|
|
|
|
const char *app_menu_path,
|
|
|
|
const char *menubar_path,
|
|
|
|
const char *window_object_path,
|
|
|
|
const char *application_object_path,
|
|
|
|
const char *unique_bus_name)
|
2013-08-30 11:56:45 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2013-08-30 11:56:45 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_SURFACE (surface));
|
2013-08-30 11:56:45 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2013-08-30 11:56:45 +00:00
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
impl->application.application_id = g_strdup (application_id);
|
|
|
|
impl->application.app_menu_path = g_strdup (app_menu_path);
|
|
|
|
impl->application.menubar_path = g_strdup (menubar_path);
|
|
|
|
impl->application.window_object_path = g_strdup (window_object_path);
|
|
|
|
impl->application.application_object_path =
|
|
|
|
g_strdup (application_object_path);
|
|
|
|
impl->application.unique_bus_name = g_strdup (unique_bus_name);
|
2013-08-30 11:56:45 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
maybe_set_gtk_surface_dbus_properties (surface);
|
2013-08-30 11:56:45 +00:00
|
|
|
}
|
2015-12-08 10:19:33 +00:00
|
|
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
int x,
|
|
|
|
int y)
|
2015-12-08 10:19:33 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2015-12-08 10:19:33 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_SURFACE (surface));
|
2015-12-08 10:19:33 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2015-12-08 10:19:33 +00:00
|
|
|
|
|
|
|
impl->pending_buffer_offset_x = x;
|
|
|
|
impl->pending_buffer_offset_y = y;
|
|
|
|
}
|
2016-07-12 03:49:39 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_exported_handle (void *data,
|
|
|
|
struct zxdg_exported_v1 *zxdg_exported_v1,
|
|
|
|
const char *handle)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = data;
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-12 03:49:39 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
impl->exported.callback (surface, handle, impl->exported.user_data);
|
2019-10-01 14:54:28 +00:00
|
|
|
if (impl->exported.destroy_func)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&impl->exported.user_data,
|
|
|
|
impl->exported.destroy_func);
|
|
|
|
}
|
2016-07-12 03:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_exported_v1_listener xdg_exported_listener = {
|
|
|
|
xdg_exported_handle
|
|
|
|
};
|
|
|
|
|
2016-08-29 17:12:56 +00:00
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* GdkWaylandSurfaceExported:
|
2018-03-20 14:14:10 +00:00
|
|
|
* @surface: the #GdkSurface that is exported
|
2016-08-29 17:12:56 +00:00
|
|
|
* @handle: the handle
|
2018-03-20 10:40:08 +00:00
|
|
|
* @user_data: user data that was passed to gdk_wayland_surface_export_handle()
|
2016-08-29 17:12:56 +00:00
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* Callback that gets called when the handle for a surface has been
|
2016-08-29 17:12:56 +00:00
|
|
|
* obtained from the Wayland compositor. The handle can be passed
|
2018-03-20 14:14:10 +00:00
|
|
|
* to other processes, for the purpose of marking surfaces as transient
|
2016-08-29 17:12:56 +00:00
|
|
|
* for out-of-process surfaces.
|
|
|
|
*/
|
|
|
|
|
2017-05-08 04:09:00 +00:00
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_is_exported (GdkSurface *surface)
|
2017-05-08 04:09:00 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-05-08 04:09:00 +00:00
|
|
|
|
|
|
|
return !!impl->display_server.xdg_exported;
|
|
|
|
}
|
|
|
|
|
2016-07-12 03:49:39 +00:00
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_export_handle:
|
2018-03-20 14:14:10 +00:00
|
|
|
* @surface: the #GdkSurface to obtain a handle for
|
2016-08-29 17:12:56 +00:00
|
|
|
* @callback: callback to call with the handle
|
2020-01-13 01:26:50 +00:00
|
|
|
* @user_data: (closure): user data for @callback
|
2016-08-29 17:12:56 +00:00
|
|
|
* @destroy_func: destroy notify for @user_data
|
|
|
|
*
|
|
|
|
* Asynchronously obtains a handle for a surface that can be passed
|
|
|
|
* to other processes. When the handle has been obtained, @callback
|
|
|
|
* will be called.
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* It is an error to call this function on a surface that is already
|
2016-08-29 17:12:56 +00:00
|
|
|
* exported.
|
|
|
|
*
|
2018-03-20 10:40:08 +00:00
|
|
|
* When the handle is no longer needed, gdk_wayland_surface_unexport_handle()
|
2016-08-29 17:12:56 +00:00
|
|
|
* should be called to clean up resources.
|
|
|
|
*
|
|
|
|
* The main purpose for obtaining a handle is to mark a surface
|
2018-03-20 14:14:10 +00:00
|
|
|
* from another surface as transient for this one, see
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_set_transient_for_exported().
|
2016-07-12 03:49:39 +00:00
|
|
|
*
|
2016-08-29 17:12:56 +00:00
|
|
|
* Note that this API depends on an unstable Wayland protocol,
|
|
|
|
* and thus may require changes in the future.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the handle has been requested, %FALSE if
|
|
|
|
* an error occurred.
|
2016-07-12 03:49:39 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_export_handle (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkWaylandSurfaceExported callback,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify destroy_func)
|
2016-07-12 03:49:39 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2016-07-12 03:49:39 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2016-07-12 03:49:39 +00:00
|
|
|
struct zxdg_exported_v1 *xdg_exported;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), FALSE);
|
2016-07-12 03:49:39 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), FALSE);
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-12 03:49:39 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
|
|
|
|
g_return_val_if_fail (!impl->display_server.xdg_exported, FALSE);
|
|
|
|
|
|
|
|
if (!display_wayland->xdg_exporter)
|
|
|
|
{
|
|
|
|
g_warning ("Server is missing xdg_foreign support");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdg_exported = zxdg_exporter_v1_export (display_wayland->xdg_exporter,
|
|
|
|
impl->display_server.wl_surface);
|
2018-03-20 14:14:10 +00:00
|
|
|
zxdg_exported_v1_add_listener (xdg_exported, &xdg_exported_listener, surface);
|
2016-07-12 03:49:39 +00:00
|
|
|
|
|
|
|
impl->display_server.xdg_exported = xdg_exported;
|
|
|
|
impl->exported.callback = callback;
|
|
|
|
impl->exported.user_data = user_data;
|
|
|
|
impl->exported.destroy_func = destroy_func;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_unexport_handle:
|
2018-03-20 14:14:10 +00:00
|
|
|
* @surface: the #GdkSurface to unexport
|
2016-08-29 17:12:56 +00:00
|
|
|
*
|
|
|
|
* Destroys the handle that was obtained with
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_export_handle().
|
2016-08-29 17:12:56 +00:00
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* It is an error to call this function on a surface that
|
2016-08-29 17:12:56 +00:00
|
|
|
* does not have a handle.
|
2016-07-12 03:49:39 +00:00
|
|
|
*
|
2016-08-29 17:12:56 +00:00
|
|
|
* Note that this API depends on an unstable Wayland protocol,
|
|
|
|
* and thus may require changes in the future.
|
2016-07-12 03:49:39 +00:00
|
|
|
*/
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_unexport_handle (GdkSurface *surface)
|
2016-07-12 03:49:39 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2016-07-12 03:49:39 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_SURFACE (surface));
|
2016-07-12 03:49:39 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-12 03:49:39 +00:00
|
|
|
|
|
|
|
g_return_if_fail (impl->display_server.xdg_exported);
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->display_server.xdg_exported,
|
|
|
|
zxdg_exported_v1_destroy);
|
2019-10-01 19:13:43 +00:00
|
|
|
if (impl->exported.destroy_func)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&impl->exported.user_data,
|
|
|
|
impl->exported.destroy_func);
|
|
|
|
}
|
2016-07-12 03:49:39 +00:00
|
|
|
}
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
unset_transient_for_exported (GdkSurface *surface)
|
2016-07-13 07:24:19 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
g_clear_pointer (&impl->imported_transient_for, zxdg_imported_v1_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_imported_destroyed (void *data,
|
|
|
|
struct zxdg_imported_v1 *zxdg_imported_v1)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = data;
|
2016-07-13 07:24:19 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
unset_transient_for_exported (surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_imported_v1_listener xdg_imported_listener = {
|
|
|
|
xdg_imported_destroyed,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_wayland_surface_set_transient_for_exported:
|
2018-03-20 14:14:10 +00:00
|
|
|
* @surface: the #GdkSurface to make as transient
|
2016-08-29 17:12:56 +00:00
|
|
|
* @parent_handle_str: an exported handle for a surface
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* Marks @surface as transient for the surface to which the given
|
2016-08-29 17:12:56 +00:00
|
|
|
* @parent_handle_str refers. Typically, the handle will originate
|
2018-03-20 10:40:08 +00:00
|
|
|
* from a gdk_wayland_surface_export_handle() call in another process.
|
2016-08-29 17:12:56 +00:00
|
|
|
*
|
|
|
|
* Note that this API depends on an unstable Wayland protocol,
|
|
|
|
* and thus may require changes in the future.
|
|
|
|
*
|
2018-03-20 14:14:10 +00:00
|
|
|
* Return value: %TRUE if the surface has been marked as transient,
|
2016-08-29 17:12:56 +00:00
|
|
|
* %FALSE if an error occurred.
|
2016-07-13 07:24:19 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
char *parent_handle_str)
|
2016-07-13 07:24:19 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl;
|
2016-07-13 07:24:19 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), FALSE);
|
2016-07-13 07:24:19 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), FALSE);
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_WAYLAND_SURFACE (surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
|
|
|
|
if (!display_wayland->xdg_importer)
|
|
|
|
{
|
|
|
|
g_warning ("Server is missing xdg_foreign support");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-03-17 14:30:25 +00:00
|
|
|
gdk_wayland_toplevel_set_transient_for (GDK_WAYLAND_TOPLEVEL (impl), NULL);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
impl->imported_transient_for =
|
|
|
|
zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
|
|
|
|
zxdg_imported_v1_add_listener (impl->imported_transient_for,
|
|
|
|
&xdg_imported_listener,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync_parent_of_imported (surface);
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-03-22 09:21:02 +00:00
|
|
|
|
|
|
|
static struct zwp_keyboard_shortcuts_inhibitor_v1 *
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_wayland_surface_get_inhibitor (GdkWaylandSurface *impl,
|
2020-03-27 13:40:52 +00:00
|
|
|
GdkSeat *gdk_seat)
|
2017-03-22 09:21:02 +00:00
|
|
|
{
|
2020-03-27 13:40:52 +00:00
|
|
|
return g_hash_table_lookup (impl->shortcuts_inhibitors, gdk_seat);
|
2017-03-22 09:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkSeat *gdk_seat)
|
2017-03-22 09:21:02 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl= GDK_WAYLAND_SURFACE (surface);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
struct wl_surface *wl_surface = impl->display_server.wl_surface;
|
2017-03-22 09:21:02 +00:00
|
|
|
struct wl_seat *seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
|
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
|
|
|
|
|
|
|
|
if (display->keyboard_shortcuts_inhibit == NULL)
|
|
|
|
return;
|
|
|
|
|
2020-03-20 14:22:30 +00:00
|
|
|
if (gdk_wayland_surface_get_inhibitor (impl, gdk_seat))
|
2020-03-27 13:40:52 +00:00
|
|
|
return; /* Already inhibited */
|
2017-03-22 09:21:02 +00:00
|
|
|
|
|
|
|
inhibitor =
|
|
|
|
zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts (
|
2018-03-20 14:14:10 +00:00
|
|
|
display->keyboard_shortcuts_inhibit, wl_surface, seat);
|
2017-03-22 09:21:02 +00:00
|
|
|
|
2020-03-27 13:40:52 +00:00
|
|
|
g_hash_table_insert (impl->shortcuts_inhibitors, gdk_seat, inhibitor);
|
2017-03-22 09:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_restore_shortcuts (GdkSurface *surface,
|
2017-12-18 12:10:47 +00:00
|
|
|
GdkSeat *gdk_seat)
|
2017-03-22 09:21:02 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2017-03-22 09:21:02 +00:00
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
|
|
|
|
|
2020-03-27 13:40:52 +00:00
|
|
|
inhibitor = gdk_wayland_surface_get_inhibitor (impl, gdk_seat);
|
2017-03-22 09:21:02 +00:00
|
|
|
if (inhibitor == NULL)
|
|
|
|
return; /* Not inhibitted */
|
|
|
|
|
|
|
|
zwp_keyboard_shortcuts_inhibitor_v1_destroy (inhibitor);
|
2020-03-27 13:40:52 +00:00
|
|
|
g_hash_table_remove (impl->shortcuts_inhibitors, gdk_seat);
|
2017-03-22 09:21:02 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 17:25:51 +00:00
|
|
|
GdkSurface *
|
|
|
|
create_dnd_surface (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
GdkSurface *surface;
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
surface = gdk_surface_new_temp (display, &(GdkRectangle){ 0, 0, 100, 100 });
|
2020-02-29 17:25:51 +00:00
|
|
|
|
|
|
|
GDK_WAYLAND_SURFACE (surface)->is_drag_surface = TRUE;
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
}
|
2020-03-07 21:08:43 +00:00
|
|
|
|
|
|
|
#define LAST_PROP 1
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_popup_init (GdkWaylandPopup *popup)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_popup_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
g_value_set_object (value, surface->parent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
g_value_set_boolean (value, surface->autohide);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_popup_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
surface->parent = g_value_dup_object (value);
|
|
|
|
if (surface->parent != NULL)
|
|
|
|
surface->parent->children = g_list_prepend (surface->parent->children, surface);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
surface->autohide = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_popup_class_init (GdkWaylandPopupClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_wayland_popup_get_property;
|
|
|
|
object_class->set_property = gdk_wayland_popup_set_property;
|
|
|
|
|
|
|
|
gdk_popup_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_popup_present (GdkPopup *popup,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
return gdk_wayland_surface_present_popup (GDK_SURFACE (popup), width, height, layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_wayland_popup_get_surface_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.surface_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_wayland_popup_get_rect_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.rect_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_wayland_popup_get_position_x (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_wayland_popup_get_position_y (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_popup_iface_init (GdkPopupInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_wayland_popup_present;
|
|
|
|
iface->get_surface_anchor = gdk_wayland_popup_get_surface_anchor;
|
|
|
|
iface->get_rect_anchor = gdk_wayland_popup_get_rect_anchor;
|
|
|
|
iface->get_position_x = gdk_wayland_popup_get_position_x;
|
|
|
|
iface->get_position_y = gdk_wayland_popup_get_position_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_init (GdkWaylandToplevel *toplevel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
2020-03-17 14:30:25 +00:00
|
|
|
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
|
2020-03-07 21:08:43 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
gdk_wayland_surface_set_title (surface, g_value_get_string (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
gdk_wayland_surface_set_startup_id (surface, g_value_get_string (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
2020-03-17 14:30:25 +00:00
|
|
|
gdk_wayland_toplevel_set_transient_for (toplevel,
|
|
|
|
g_value_get_object (value));
|
2020-03-07 21:08:43 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
|
|
|
gdk_wayland_surface_set_modal_hint (surface, g_value_get_boolean (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
2020-03-09 18:49:59 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE:
|
|
|
|
surface->fullscreen_mode = g_value_get_enum (value);
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
2020-03-20 14:22:30 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
break;
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-03-17 14:30:25 +00:00
|
|
|
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
|
2020-03-07 21:08:43 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STATE:
|
|
|
|
g_value_set_flags (value, surface->state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
g_value_set_string (value, impl->title);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
2020-03-17 14:30:25 +00:00
|
|
|
g_value_set_object (value, toplevel->transient_for);
|
2020-03-07 21:08:43 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
|
|
|
g_value_set_boolean (value, surface->modal_hint);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
g_value_set_pointer (value, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
2020-03-09 18:49:59 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE:
|
|
|
|
g_value_set_enum (value, surface->fullscreen_mode);
|
|
|
|
break;
|
|
|
|
|
2020-03-20 14:22:30 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
g_value_set_boolean (value, surface->shortcuts_inhibited);
|
|
|
|
break;
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_wayland_toplevel_get_property;
|
|
|
|
object_class->set_property = gdk_wayland_toplevel_set_property;
|
|
|
|
|
|
|
|
gdk_toplevel_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_surface (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
gboolean was_mapped;
|
|
|
|
|
|
|
|
if (surface->destroyed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
|
|
|
|
|
|
|
if (!was_mapped)
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_WITHDRAWN, 0);
|
2020-03-07 21:08:43 +00:00
|
|
|
|
|
|
|
gdk_wayland_surface_show (surface, FALSE);
|
|
|
|
|
|
|
|
if (!was_mapped)
|
2020-05-16 22:41:44 +00:00
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
2020-03-07 21:08:43 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
static void
|
|
|
|
reconfigure_callback (void *data,
|
|
|
|
struct wl_callback *callback,
|
|
|
|
uint32_t time)
|
|
|
|
{
|
|
|
|
gboolean *done = (gboolean *) data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_callback_listener reconfigure_listener = {
|
|
|
|
reconfigure_callback
|
|
|
|
};
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_wayland_toplevel_present (GdkToplevel *toplevel,
|
|
|
|
GdkToplevelLayout *layout)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
2020-07-30 21:06:59 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
struct wl_callback *callback;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
int last_configure_serial = impl->last_configure_serial;
|
|
|
|
gboolean needs_reconfigure = TRUE;
|
2020-03-07 21:08:43 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
if (gdk_toplevel_layout_get_maximized (layout))
|
2020-03-07 21:08:43 +00:00
|
|
|
{
|
2020-07-30 21:06:59 +00:00
|
|
|
gdk_wayland_surface_maximize (surface);
|
|
|
|
needs_reconfigure = FALSE;
|
2020-03-07 21:08:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-30 21:06:59 +00:00
|
|
|
gdk_wayland_surface_unmaximize (surface);
|
2020-03-07 21:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gdk_toplevel_layout_get_fullscreen (layout))
|
|
|
|
{
|
|
|
|
GdkMonitor *monitor = gdk_toplevel_layout_get_fullscreen_monitor (layout);
|
|
|
|
if (monitor)
|
|
|
|
gdk_wayland_surface_fullscreen_on_monitor (surface, monitor);
|
|
|
|
else
|
|
|
|
gdk_wayland_surface_fullscreen (surface);
|
2020-07-30 21:06:59 +00:00
|
|
|
needs_reconfigure = FALSE;
|
2020-03-07 21:08:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gdk_wayland_surface_unfullscreen (surface);
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
g_clear_pointer (&impl->toplevel.layout, gdk_toplevel_layout_unref);
|
|
|
|
impl->toplevel.layout = gdk_toplevel_layout_copy (layout);
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
show_surface (surface);
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
callback = wl_display_sync (display_wayland->wl_display);
|
|
|
|
wl_proxy_set_queue ((struct wl_proxy *) callback, impl->event_queue);
|
|
|
|
wl_callback_add_listener (callback,
|
|
|
|
&reconfigure_listener,
|
|
|
|
&done);
|
|
|
|
while (is_realized_toplevel (surface) &&
|
2020-08-07 07:02:03 +00:00
|
|
|
(!impl->initial_configure_received || !done))
|
2020-07-30 21:06:59 +00:00
|
|
|
wl_display_dispatch_queue (display_wayland->wl_display, impl->event_queue);
|
|
|
|
|
2020-08-07 12:01:16 +00:00
|
|
|
wl_callback_destroy (callback);
|
2020-08-07 07:03:03 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
if (needs_reconfigure &&
|
|
|
|
last_configure_serial == impl->last_configure_serial &&
|
2020-09-10 04:39:03 +00:00
|
|
|
!(surface->state & (GDK_TOPLEVEL_STATE_MAXIMIZED |
|
|
|
|
GDK_TOPLEVEL_STATE_FULLSCREEN |
|
|
|
|
GDK_TOPLEVEL_STATE_TILED)))
|
2020-07-30 21:06:59 +00:00
|
|
|
configure_surface_geometry (surface);
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_toplevel_minimize (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
gdk_wayland_surface_minimize (GDK_SURFACE (toplevel));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_toplevel_lower (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
gdk_wayland_surface_focus (GDK_SURFACE (toplevel), timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_toplevel_show_window_menu (GdkToplevel *toplevel,
|
|
|
|
GdkEvent *event)
|
|
|
|
{
|
|
|
|
return gdk_wayland_surface_show_window_menu (GDK_SURFACE (toplevel), event);
|
|
|
|
}
|
|
|
|
|
2020-03-09 18:38:08 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_wayland_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
return gdk_wayland_surface_supports_edge_constraints (GDK_SURFACE (toplevel));
|
|
|
|
}
|
|
|
|
|
2020-03-20 14:22:30 +00:00
|
|
|
static void
|
|
|
|
inhibitor_active (void *data,
|
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor)
|
|
|
|
{
|
|
|
|
GdkToplevel *toplevel = GDK_TOPLEVEL (data);
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
|
|
|
|
surface->shortcuts_inhibited = TRUE;
|
|
|
|
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
inhibitor_inactive (void *data,
|
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor)
|
|
|
|
{
|
|
|
|
GdkToplevel *toplevel = GDK_TOPLEVEL (data);
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
|
|
|
|
surface->shortcuts_inhibited = FALSE;
|
|
|
|
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_keyboard_shortcuts_inhibitor_v1_listener
|
|
|
|
zwp_keyboard_shortcuts_inhibitor_listener = {
|
|
|
|
inhibitor_active,
|
|
|
|
inhibitor_inactive,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
|
|
|
|
GdkEvent *event)
|
|
|
|
{
|
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
GdkWaylandSurface *impl= GDK_WAYLAND_SURFACE (surface);
|
|
|
|
GdkSeat *gdk_seat;
|
|
|
|
|
|
|
|
if (surface->shortcuts_inhibited)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_seat = gdk_surface_get_seat_from_event (surface, event);
|
|
|
|
gdk_wayland_surface_inhibit_shortcuts (surface, gdk_seat);
|
|
|
|
|
|
|
|
inhibitor = gdk_wayland_surface_get_inhibitor (impl, gdk_seat);
|
|
|
|
if (!inhibitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
surface->current_shortcuts_inhibited_seat = gdk_seat;
|
|
|
|
zwp_keyboard_shortcuts_inhibitor_v1_add_listener
|
|
|
|
(inhibitor, &zwp_keyboard_shortcuts_inhibitor_listener, toplevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
|
|
|
|
gdk_wayland_surface_restore_shortcuts (surface,
|
|
|
|
surface->current_shortcuts_inhibited_seat);
|
|
|
|
surface->current_shortcuts_inhibited_seat = NULL;
|
|
|
|
surface->shortcuts_inhibited = FALSE;
|
|
|
|
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
|
|
|
|
}
|
|
|
|
|
2020-03-07 21:08:43 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_wayland_toplevel_present;
|
|
|
|
iface->minimize = gdk_wayland_toplevel_minimize;
|
|
|
|
iface->lower = gdk_wayland_toplevel_lower;
|
|
|
|
iface->focus = gdk_wayland_toplevel_focus;
|
|
|
|
iface->show_window_menu = gdk_wayland_toplevel_show_window_menu;
|
2020-03-09 18:38:08 +00:00
|
|
|
iface->supports_edge_constraints = gdk_wayland_toplevel_supports_edge_constraints;
|
2020-03-20 14:22:30 +00:00
|
|
|
iface->inhibit_system_shortcuts = gdk_wayland_toplevel_inhibit_system_shortcuts;
|
|
|
|
iface->restore_system_shortcuts = gdk_wayland_toplevel_restore_system_shortcuts;
|
2020-05-17 16:35:45 +00:00
|
|
|
iface->begin_resize = gdk_wayland_toplevel_begin_resize;
|
|
|
|
iface->begin_move = gdk_wayland_toplevel_begin_move;
|
2020-03-07 21:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_drag_surface_init (GdkWaylandDragSurface *surface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_drag_surface_class_init (GdkWaylandDragSurfaceClass *class)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_wayland_drag_surface_present (GdkDragSurface *drag_surface,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (drag_surface);
|
|
|
|
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
|
|
|
|
|
|
|
gdk_wayland_surface_resize (surface, width, height, impl->scale);
|
|
|
|
show_surface (surface);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_wayland_drag_surface_present;
|
|
|
|
}
|
|
|
|
|