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"
|
|
|
|
|
|
|
|
|
|
#include "gdkwindow.h"
|
|
|
|
|
#include "gdkwindowimpl.h"
|
|
|
|
|
#include "gdkdisplay-wayland.h"
|
2014-10-09 09:06:48 +00:00
|
|
|
|
#include "gdkglcontext-wayland.h"
|
2013-04-24 22:14:22 +00:00
|
|
|
|
#include "gdkframeclockprivate.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
|
#include "gdkprivate-wayland.h"
|
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
#include "gdkdeviceprivate.h"
|
2016-07-01 09:03:36 +00:00
|
|
|
|
#include "gdkprivate-wayland.h"
|
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
|
|
|
|
|
2015-09-10 09:42:21 +00:00
|
|
|
|
enum {
|
|
|
|
|
COMMITTED,
|
|
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
#define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
|
2016-10-25 07:54:37 +00:00
|
|
|
|
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2013-09-16 21:23:29 +00:00
|
|
|
|
#define WINDOW_IS_TOPLEVEL(window) \
|
2010-12-18 20:38:49 +00:00
|
|
|
|
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
|
2016-10-25 07:54:37 +00:00
|
|
|
|
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
|
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 */
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
typedef struct _GdkWaylandWindow GdkWaylandWindow;
|
|
|
|
|
typedef struct _GdkWaylandWindowClass GdkWaylandWindowClass;
|
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
|
struct _GdkWaylandWindow
|
|
|
|
|
{
|
2010-12-18 20:38:49 +00:00
|
|
|
|
GdkWindow parent;
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
|
struct _GdkWaylandWindowClass
|
|
|
|
|
{
|
2010-12-18 20:38:49 +00:00
|
|
|
|
GdkWindowClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-23 21:20:05 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkWaylandWindow, gdk_wayland_window, GDK_TYPE_WINDOW)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2013-01-23 21:20:05 +00:00
|
|
|
|
gdk_wayland_window_class_init (GdkWaylandWindowClass *wayland_window_class)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-01-23 21:20:05 +00:00
|
|
|
|
gdk_wayland_window_init (GdkWaylandWindow *wayland_window)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-06 21:51:12 +00:00
|
|
|
|
#define GDK_TYPE_WINDOW_IMPL_WAYLAND (_gdk_window_impl_wayland_get_type ())
|
|
|
|
|
#define GDK_WINDOW_IMPL_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWayland))
|
|
|
|
|
#define GDK_WINDOW_IMPL_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWaylandClass))
|
|
|
|
|
#define GDK_IS_WINDOW_IMPL_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_WAYLAND))
|
|
|
|
|
#define GDK_IS_WINDOW_IMPL_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_WAYLAND))
|
|
|
|
|
#define GDK_WINDOW_IMPL_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWaylandClass))
|
|
|
|
|
|
|
|
|
|
typedef struct _GdkWindowImplWayland GdkWindowImplWayland;
|
|
|
|
|
typedef struct _GdkWindowImplWaylandClass GdkWindowImplWaylandClass;
|
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
typedef enum _PositionMethod
|
|
|
|
|
{
|
|
|
|
|
POSITION_METHOD_NONE,
|
|
|
|
|
POSITION_METHOD_MOVE_RESIZE,
|
|
|
|
|
POSITION_METHOD_MOVE_TO_RECT
|
|
|
|
|
} PositionMethod;
|
|
|
|
|
|
2011-01-06 21:51:12 +00:00
|
|
|
|
struct _GdkWindowImplWayland
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImpl parent_instance;
|
|
|
|
|
|
|
|
|
|
GdkWindow *wrapper;
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
struct {
|
|
|
|
|
/* The wl_outputs that this window currently touches */
|
|
|
|
|
GSList *outputs;
|
|
|
|
|
|
|
|
|
|
struct wl_surface *wl_surface;
|
2016-07-01 09:03:36 +00:00
|
|
|
|
struct zxdg_surface_v6 *xdg_surface;
|
|
|
|
|
struct zxdg_toplevel_v6 *xdg_toplevel;
|
|
|
|
|
struct zxdg_popup_v6 *xdg_popup;
|
2016-03-07 03:49:35 +00:00
|
|
|
|
struct gtk_surface1 *gtk_surface;
|
2016-02-02 16:42:52 +00:00
|
|
|
|
struct wl_subsurface *wl_subsurface;
|
|
|
|
|
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;
|
2016-02-02 16:42:52 +00:00
|
|
|
|
} display_server;
|
2014-08-21 15:31:50 +00:00
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
|
EGLSurface egl_surface;
|
2014-10-09 14:09:05 +00:00
|
|
|
|
EGLSurface dummy_egl_surface;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
unsigned int initial_configure_received : 1;
|
2011-01-07 15:16:17 +00:00
|
|
|
|
unsigned int mapped : 1;
|
2013-09-22 03:35:02 +00:00
|
|
|
|
unsigned int use_custom_surface : 1;
|
2016-02-16 04:41:57 +00:00
|
|
|
|
unsigned int pending_buffer_attached : 1;
|
2013-09-22 03:35:02 +00:00
|
|
|
|
unsigned int pending_commit : 1;
|
2015-02-25 13:46:54 +00:00
|
|
|
|
unsigned int awaiting_frame : 1;
|
2012-01-13 14:48:46 +00:00
|
|
|
|
GdkWindowTypeHint hint;
|
2013-09-22 03:35:02 +00:00
|
|
|
|
GdkWindow *transient_for;
|
2016-09-05 15:53:38 +00:00
|
|
|
|
GdkWindow *popup_parent;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
PositionMethod position_method;
|
2011-01-06 21:51:12 +00:00
|
|
|
|
|
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
|
|
|
|
cairo_surface_t *staging_cairo_surface;
|
|
|
|
|
cairo_surface_t *committed_cairo_surface;
|
|
|
|
|
cairo_surface_t *backfill_cairo_surface;
|
|
|
|
|
|
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
|
|
|
|
|
2013-03-16 23:57:17 +00:00
|
|
|
|
gchar *title;
|
|
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
|
struct {
|
|
|
|
|
gboolean was_set;
|
|
|
|
|
|
|
|
|
|
gchar *application_id;
|
|
|
|
|
gchar *app_menu_path;
|
|
|
|
|
gchar *menubar_path;
|
|
|
|
|
gchar *window_object_path;
|
|
|
|
|
gchar *application_object_path;
|
|
|
|
|
gchar *unique_bus_name;
|
|
|
|
|
} application;
|
|
|
|
|
|
2012-01-09 17:11:22 +00:00
|
|
|
|
GdkGeometry geometry_hints;
|
|
|
|
|
GdkWindowHints 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
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
|
int initial_fullscreen_monitor;
|
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;
|
|
|
|
|
|
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
|
|
|
|
cairo_region_t *staged_updates_region;
|
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
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
GdkRectangle rect;
|
|
|
|
|
GdkGravity rect_anchor;
|
|
|
|
|
GdkGravity window_anchor;
|
|
|
|
|
GdkAnchorHints anchor_hints;
|
|
|
|
|
gint rect_anchor_dx;
|
|
|
|
|
gint rect_anchor_dy;
|
|
|
|
|
} pending_move_to_rect;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
|
|
|
|
|
struct {
|
2016-07-01 09:03:36 +00:00
|
|
|
|
int width;
|
|
|
|
|
int height;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
GdkWindowState state;
|
|
|
|
|
} pending;
|
2016-07-12 03:49:39 +00:00
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
GdkWaylandWindowExported callback;
|
|
|
|
|
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;
|
2011-01-06 21:51:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GdkWindowImplWaylandClass
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-04 12:55:38 +00:00
|
|
|
|
static void gdk_wayland_window_maybe_configure (GdkWindow *window,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int scale);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
|
2015-03-06 03:40:12 +00:00
|
|
|
|
static void maybe_set_gtk_surface_dbus_properties (GdkWindow *window);
|
2015-08-01 15:03:49 +00:00
|
|
|
|
static void maybe_set_gtk_surface_modal (GdkWindow *window);
|
2015-03-23 05:08:09 +00:00
|
|
|
|
|
2015-06-17 09:31:19 +00:00
|
|
|
|
static void gdk_window_request_transient_parent_commit (GdkWindow *window);
|
|
|
|
|
|
2016-07-01 08:48:16 +00:00
|
|
|
|
static void gdk_wayland_window_sync_margin (GdkWindow *window);
|
|
|
|
|
static void gdk_wayland_window_sync_input_region (GdkWindow *window);
|
|
|
|
|
static void gdk_wayland_window_sync_opaque_region (GdkWindow *window);
|
|
|
|
|
|
2016-07-13 07:24:19 +00:00
|
|
|
|
static void unset_transient_for_exported (GdkWindow *window);
|
|
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
|
static void calculate_moved_to_rect_result (GdkWindow *window,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
GdkRectangle *flipped_rect,
|
|
|
|
|
GdkRectangle *final_rect,
|
|
|
|
|
gboolean *flipped_x,
|
|
|
|
|
gboolean *flipped_y);
|
|
|
|
|
|
2017-05-08 04:09:00 +00:00
|
|
|
|
static gboolean gdk_wayland_window_is_exported (GdkWindow *window);
|
|
|
|
|
|
2014-09-06 00:41:06 +00:00
|
|
|
|
GType _gdk_window_impl_wayland_get_type (void);
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkWindowImplWayland, _gdk_window_impl_wayland, GDK_TYPE_WINDOW_IMPL)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_gdk_window_impl_wayland_init (GdkWindowImplWayland *impl)
|
2011-01-06 21:51:12 +00:00
|
|
|
|
{
|
2013-06-04 09:39:36 +00:00
|
|
|
|
impl->scale = 1;
|
2015-07-13 16:30:42 +00:00
|
|
|
|
impl->initial_fullscreen_monitor = -1;
|
2016-02-26 12:35:35 +00:00
|
|
|
|
impl->saved_width = -1;
|
|
|
|
|
impl->saved_height = -1;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
static void
|
|
|
|
|
_gdk_wayland_screen_add_orphan_dialog (GdkWindow *window)
|
|
|
|
|
{
|
2016-04-26 03:46:25 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
|
|
|
|
|
if (!g_list_find (display_wayland->orphan_dialogs, window))
|
|
|
|
|
display_wayland->orphan_dialogs =
|
|
|
|
|
g_list_prepend (display_wayland->orphan_dialogs, window);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
static void
|
|
|
|
|
drop_cairo_surfaces (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
|
|
|
|
|
g_clear_pointer (&impl->backfill_cairo_surface, cairo_surface_destroy);
|
|
|
|
|
|
|
|
|
|
/* We nullify this so if a buffer release comes in later, we won't
|
|
|
|
|
* try to reuse that buffer since it's no longer suitable
|
|
|
|
|
*/
|
|
|
|
|
impl->committed_cairo_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
static void
|
|
|
|
|
_gdk_wayland_window_save_size (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (window->state & (GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_MAXIMIZED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->saved_width = window->width - impl->margin_left - impl->margin_right;
|
|
|
|
|
impl->saved_height = window->height - impl->margin_top - impl->margin_bottom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_gdk_wayland_window_clear_saved_size (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (window->state & (GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_MAXIMIZED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->saved_width = -1;
|
|
|
|
|
impl->saved_height = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-18 12:17:49 +00:00
|
|
|
|
/*
|
2012-01-29 12:15:12 +00:00
|
|
|
|
* gdk_wayland_window_update_size:
|
2010-12-18 20:38:49 +00:00
|
|
|
|
* @drawable: a #GdkDrawableImplWayland.
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*
|
2010-12-18 20:38:49 +00:00
|
|
|
|
* Updates the state of the drawable (in particular the drawable's
|
|
|
|
|
* cairo surface) when its size has changed.
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*/
|
2012-01-29 12:15:12 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_update_size (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
int32_t width,
|
2015-02-24 08:11:48 +00:00
|
|
|
|
int32_t height,
|
|
|
|
|
int scale)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2011-01-06 21:51:12 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2011-01-07 15:16:17 +00:00
|
|
|
|
GdkRectangle area;
|
|
|
|
|
cairo_region_t *region;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2016-03-17 06:35:20 +00:00
|
|
|
|
if ((window->width == width) &&
|
|
|
|
|
(window->height == height) &&
|
|
|
|
|
(impl->scale == scale))
|
|
|
|
|
return;
|
|
|
|
|
|
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
|
|
|
|
drop_cairo_surfaces (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2011-02-11 03:37:51 +00:00
|
|
|
|
window->width = width;
|
|
|
|
|
window->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
|
|
|
|
|
2011-01-07 15:16:17 +00:00
|
|
|
|
area.x = 0;
|
|
|
|
|
area.y = 0;
|
|
|
|
|
area.width = window->width;
|
|
|
|
|
area.height = window->height;
|
|
|
|
|
|
|
|
|
|
region = cairo_region_create_rectangle (&area);
|
|
|
|
|
_gdk_window_invalidate_for_expose (window, region);
|
|
|
|
|
cairo_region_destroy (region);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkWindow *
|
|
|
|
|
_gdk_wayland_screen_create_root_window (GdkScreen *screen,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2016-09-04 19:52:55 +00:00
|
|
|
|
GdkDisplay *display = gdk_screen_get_display (screen);
|
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
GdkWindow *window;
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
|
window = _gdk_display_create_window (GDK_DISPLAY (display_wayland));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WAYLAND, NULL);
|
|
|
|
|
window->impl_window = window;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
impl->wrapper = GDK_WINDOW (window);
|
2016-04-26 03:16:56 +00:00
|
|
|
|
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE &&
|
2016-09-04 19:52:55 +00:00
|
|
|
|
gdk_display_get_n_monitors (display) > 0)
|
|
|
|
|
impl->scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, 0));
|
2013-07-24 17:30:19 +00:00
|
|
|
|
|
|
|
|
|
/* logical 1x1 fake buffer */
|
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
|
|
|
|
impl->staging_cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
|
impl->scale,
|
|
|
|
|
impl->scale);
|
2013-07-24 17:30:19 +00:00
|
|
|
|
|
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
|
|
|
|
cairo_surface_set_device_scale (impl->staging_cairo_surface, impl->scale, impl->scale);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
window->window_type = GDK_WINDOW_ROOT;
|
|
|
|
|
|
|
|
|
|
window->x = 0;
|
|
|
|
|
window->y = 0;
|
|
|
|
|
window->abs_x = 0;
|
|
|
|
|
window->abs_y = 0;
|
|
|
|
|
window->width = width;
|
|
|
|
|
window->height = height;
|
|
|
|
|
window->viewable = TRUE;
|
|
|
|
|
|
|
|
|
|
/* see init_randr_support() in gdkscreen-wayland.c */
|
|
|
|
|
window->event_mask = GDK_STRUCTURE_MASK;
|
|
|
|
|
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
static void
|
|
|
|
|
read_back_cairo_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
cairo_t *cr;
|
|
|
|
|
cairo_region_t *paint_region = NULL;
|
|
|
|
|
|
|
|
|
|
if (!impl->backfill_cairo_surface)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
paint_region = cairo_region_copy (window->clip_region);
|
|
|
|
|
cairo_region_subtract (paint_region, impl->staged_updates_region);
|
|
|
|
|
|
|
|
|
|
if (cairo_region_is_empty (paint_region))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
cr = cairo_create (impl->staging_cairo_surface);
|
|
|
|
|
cairo_set_source_surface (cr, impl->backfill_cairo_surface, 0, 0);
|
|
|
|
|
gdk_cairo_region (cr, paint_region);
|
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
cairo_surface_flush (impl->staging_cairo_surface);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_clear_pointer (&paint_region, cairo_region_destroy);
|
|
|
|
|
g_clear_pointer (&impl->staged_updates_region, cairo_region_destroy);
|
|
|
|
|
g_clear_pointer (&impl->backfill_cairo_surface, cairo_surface_destroy);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
|
static void
|
|
|
|
|
frame_callback (void *data,
|
|
|
|
|
struct wl_callback *callback,
|
|
|
|
|
uint32_t time)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = data;
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-04-26 03:16:56 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2013-04-24 22:14:22 +00:00
|
|
|
|
GdkFrameClock *clock = gdk_window_get_frame_clock (window);
|
|
|
|
|
GdkFrameTimings *timings;
|
|
|
|
|
|
2015-02-28 05:15:13 +00:00
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
|
g_message ("frame %p", window));
|
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
|
wl_callback_destroy (callback);
|
2014-01-31 21:39:33 +00:00
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-25 13:46:54 +00:00
|
|
|
|
if (!impl->awaiting_frame)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->awaiting_frame = FALSE;
|
2013-04-24 22:14:22 +00:00
|
|
|
|
_gdk_frame_clock_thaw (clock);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
/* We pick a random output out of the outputs that the window touches
|
|
|
|
|
* The rate here is in milli-hertz */
|
2016-04-26 03:16:56 +00:00
|
|
|
|
int refresh_rate =
|
|
|
|
|
_gdk_wayland_screen_get_output_refresh_rate (display_wayland->screen,
|
|
|
|
|
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);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
|
|
GdkWindow *window)
|
|
|
|
|
{
|
2013-04-25 15:46:31 +00:00
|
|
|
|
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
|
|
|
|
|
gint64 presentation_time;
|
|
|
|
|
gint64 refresh_interval;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (window->update_freeze_count > 0)
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_frame_clock_after_paint (GdkFrameClock *clock,
|
|
|
|
|
GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
struct wl_callback *callback;
|
|
|
|
|
|
|
|
|
|
if (!impl->pending_commit)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (window->update_freeze_count > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
callback = wl_surface_frame (impl->display_server.wl_surface);
|
2014-06-21 21:33:09 +00:00
|
|
|
|
wl_callback_add_listener (callback, &frame_listener, window);
|
2013-04-24 22:14:22 +00:00
|
|
|
|
_gdk_frame_clock_freeze (clock);
|
|
|
|
|
|
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
|
|
|
|
/* Before we commit a new buffer, make sure we've backfilled
|
|
|
|
|
* undrawn parts from any old committed buffer
|
|
|
|
|
*/
|
2016-02-16 04:41:57 +00:00
|
|
|
|
if (impl->pending_buffer_attached)
|
|
|
|
|
read_back_cairo_surface (window);
|
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
|
|
|
|
|
|
|
|
|
/* From this commit forward, we can't write to the buffer,
|
|
|
|
|
* it's "live". In the future, if we need to stage more changes
|
|
|
|
|
* we have to allocate a new staging buffer and draw to it instead.
|
|
|
|
|
*
|
|
|
|
|
* Our one saving grace is if the compositor releases the buffer
|
|
|
|
|
* before we need to stage any changes, then we can take it back and
|
|
|
|
|
* use it again.
|
|
|
|
|
*/
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_surface_commit (impl->display_server.wl_surface);
|
2016-02-16 04:41:57 +00:00
|
|
|
|
|
|
|
|
|
if (impl->pending_buffer_attached)
|
|
|
|
|
impl->committed_cairo_surface = g_steal_pointer (&impl->staging_cairo_surface);
|
|
|
|
|
|
|
|
|
|
impl->pending_buffer_attached = FALSE;
|
|
|
|
|
impl->pending_commit = FALSE;
|
|
|
|
|
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
|
|
|
|
impl->awaiting_frame = TRUE;
|
2015-09-10 09:42:21 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit (impl, signals[COMMITTED], 0);
|
2013-04-24 22:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-04 09:39:36 +00:00
|
|
|
|
static void
|
|
|
|
|
window_update_scale (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-04-26 03:16:56 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
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
|
|
|
|
{
|
|
|
|
|
guint32 output_scale =
|
2016-04-26 03:16:56 +00:00
|
|
|
|
_gdk_wayland_screen_get_output_scale (display_wayland->screen, 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 */
|
2016-04-04 12:55:38 +00:00
|
|
|
|
gdk_wayland_window_maybe_configure (window, window->width, window->height, scale);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_monitors_changed (GdkScreen *screen,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindow *window)
|
2013-06-04 09:39:36 +00:00
|
|
|
|
{
|
|
|
|
|
window_update_scale (window);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 15:19:39 +00:00
|
|
|
|
|
2013-09-16 21:23:29 +00:00
|
|
|
|
static void gdk_wayland_window_create_surface (GdkWindow *window);
|
2013-07-03 15:19:39 +00:00
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_wayland_display_create_window_impl (GdkDisplay *display,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindow *window,
|
|
|
|
|
GdkWindow *real_parent,
|
|
|
|
|
GdkScreen *screen,
|
|
|
|
|
GdkEventMask event_mask,
|
2016-11-07 00:33:43 +00:00
|
|
|
|
GdkWindowAttr *attributes)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2016-04-26 03:16:56 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
2013-04-24 22:14:22 +00:00
|
|
|
|
GdkFrameClock *frame_clock;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WAYLAND, NULL);
|
|
|
|
|
window->impl = GDK_WINDOW_IMPL (impl);
|
|
|
|
|
impl->wrapper = GDK_WINDOW (window);
|
2017-03-22 09:21:02 +00:00
|
|
|
|
impl->shortcuts_inhibitors = g_hash_table_new (NULL, NULL);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
|
if (window->width > 65535)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2015-02-28 03:28:28 +00:00
|
|
|
|
g_warning ("Native Windows wider than 65535 pixels are not supported");
|
|
|
|
|
window->width = 65535;
|
|
|
|
|
}
|
|
|
|
|
if (window->height > 65535)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Native Windows taller than 65535 pixels are not supported");
|
|
|
|
|
window->height = 65535;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
2011-01-06 20:23:52 +00:00
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
g_object_ref (window);
|
|
|
|
|
|
2013-06-04 09:39:36 +00:00
|
|
|
|
/* More likely to be right than just assuming 1 */
|
2016-04-26 03:16:56 +00:00
|
|
|
|
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE &&
|
2016-09-04 19:52:55 +00:00
|
|
|
|
gdk_display_get_n_monitors (display) > 0)
|
|
|
|
|
impl->scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, 0));
|
2013-06-04 09:39:36 +00:00
|
|
|
|
|
2013-03-16 23:57:17 +00:00
|
|
|
|
impl->title = NULL;
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
switch (GDK_WINDOW_TYPE (window))
|
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_TOPLEVEL:
|
|
|
|
|
case GDK_WINDOW_TEMP:
|
2016-11-04 03:08:50 +00:00
|
|
|
|
gdk_window_set_title (window, get_default_title ());
|
2010-12-18 20:38:49 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_CHILD:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 15:19:39 +00:00
|
|
|
|
gdk_wayland_window_create_surface (window);
|
|
|
|
|
|
2013-04-24 22:14:22 +00:00
|
|
|
|
frame_clock = gdk_window_get_frame_clock (window);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (frame_clock, "before-paint",
|
|
|
|
|
G_CALLBACK (on_frame_clock_before_paint), window);
|
|
|
|
|
g_signal_connect (frame_clock, "after-paint",
|
|
|
|
|
G_CALLBACK (on_frame_clock_after_paint), window);
|
2013-06-04 09:39:36 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (screen, "monitors-changed",
|
|
|
|
|
G_CALLBACK (on_monitors_changed), window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-08 01:49:40 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_attach_image (GdkWindow *window)
|
|
|
|
|
{
|
2013-07-12 14:49:52 +00:00
|
|
|
|
GdkWaylandDisplay *display;
|
2011-01-08 01:49:40 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2011-01-08 01:49:40 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
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
|
|
|
|
g_assert (_gdk_wayland_is_shm_surface (impl->staging_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,
|
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
|
|
|
|
_gdk_wayland_shm_surface_get_wl_buffer (impl->staging_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 */
|
|
|
|
|
display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
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
|
|
|
|
|
2016-02-16 04:41:57 +00:00
|
|
|
|
impl->pending_buffer_attached = TRUE;
|
2013-04-24 22:14:22 +00:00
|
|
|
|
impl->pending_commit = TRUE;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
static const cairo_user_data_key_t gdk_wayland_window_cairo_key;
|
|
|
|
|
|
2016-02-02 19:36:25 +00:00
|
|
|
|
static void
|
|
|
|
|
buffer_release_callback (void *_data,
|
|
|
|
|
struct wl_buffer *wl_buffer)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_t *cairo_surface = _data;
|
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
|
|
|
|
GdkWindowImplWayland *impl = cairo_surface_get_user_data (cairo_surface, &gdk_wayland_window_cairo_key);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (impl));
|
|
|
|
|
|
|
|
|
|
/* The released buffer isn't the latest committed one, we have no further
|
|
|
|
|
* use for it, so clean it up.
|
|
|
|
|
*/
|
|
|
|
|
if (impl->committed_cairo_surface != cairo_surface)
|
|
|
|
|
{
|
|
|
|
|
/* If this fails, then the surface buffer got reused before it was
|
|
|
|
|
* released from the compositor
|
|
|
|
|
*/
|
|
|
|
|
g_warn_if_fail (impl->staging_cairo_surface != cairo_surface);
|
|
|
|
|
|
|
|
|
|
cairo_surface_destroy (cairo_surface);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-27 21:17:38 +00:00
|
|
|
|
if (impl->staged_updates_region != NULL)
|
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-02-27 21:17:38 +00:00
|
|
|
|
/* If this fails, then we're tracking staged updates on a staging surface
|
|
|
|
|
* that doesn't exist.
|
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-02-27 21:17:38 +00:00
|
|
|
|
g_warn_if_fail (impl->staging_cairo_surface != NULL);
|
|
|
|
|
|
|
|
|
|
/* If we've staged updates into a new buffer before the release for this
|
|
|
|
|
* buffer came in, then we can't reuse this buffer, so unref it. It may still
|
|
|
|
|
* be alive as a readback buffer though (via impl->backfill_cairo_surface).
|
|
|
|
|
*
|
|
|
|
|
* It's possible a staging surface was allocated but no updates were staged.
|
|
|
|
|
* If that happened, clean up that staging surface now, since the old commit
|
|
|
|
|
* buffer is available again, and reusing the old commit buffer for future
|
|
|
|
|
* updates will save having to do a read back later.
|
|
|
|
|
*/
|
|
|
|
|
if (!cairo_region_is_empty (impl->staged_updates_region))
|
|
|
|
|
{
|
|
|
|
|
g_clear_pointer (&impl->committed_cairo_surface, cairo_surface_destroy);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_clear_pointer (&impl->staged_updates_region, cairo_region_destroy);
|
|
|
|
|
g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
|
|
|
|
|
}
|
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-02-02 19:36:25 +00:00
|
|
|
|
|
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
|
|
|
|
/* Release came in, we haven't done any interim updates, so we can just use
|
|
|
|
|
* the old committed buffer again.
|
|
|
|
|
*/
|
|
|
|
|
impl->staging_cairo_surface = g_steal_pointer (&impl->committed_cairo_surface);
|
2016-02-02 19:36:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_buffer_listener buffer_listener = {
|
|
|
|
|
buffer_release_callback
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-24 22:00:41 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_ensure_cairo_surface (GdkWindow *window)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2015-02-24 10:10:07 +00:00
|
|
|
|
|
|
|
|
|
/* If we are drawing using OpenGL then we only need a logical 1x1 surface. */
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.egl_window)
|
2015-02-24 10:10:07 +00:00
|
|
|
|
{
|
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
|
|
|
|
if (impl->staging_cairo_surface &&
|
|
|
|
|
_gdk_wayland_is_shm_surface (impl->staging_cairo_surface))
|
2017-09-26 19:13:40 +00:00
|
|
|
|
g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
|
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
|
|
|
|
|
2017-09-26 19:13:40 +00:00
|
|
|
|
if (!impl->staging_cairo_surface)
|
|
|
|
|
{
|
|
|
|
|
impl->staging_cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
|
impl->scale,
|
|
|
|
|
impl->scale);
|
|
|
|
|
cairo_surface_set_device_scale (impl->staging_cairo_surface,
|
|
|
|
|
impl->scale, impl->scale);
|
|
|
|
|
}
|
2015-02-24 10:10:07 +00:00
|
|
|
|
}
|
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
|
|
|
|
else if (!impl->staging_cairo_surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2014-02-23 18:57:24 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (impl->wrapper));
|
2016-02-02 19:36:25 +00:00
|
|
|
|
struct wl_buffer *buffer;
|
2014-02-23 18:57:24 +00:00
|
|
|
|
|
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
|
|
|
|
impl->staging_cairo_surface = _gdk_wayland_display_create_shm_surface (display_wayland,
|
|
|
|
|
impl->wrapper->width,
|
|
|
|
|
impl->wrapper->height,
|
|
|
|
|
impl->scale);
|
|
|
|
|
cairo_surface_set_user_data (impl->staging_cairo_surface,
|
|
|
|
|
&gdk_wayland_window_cairo_key,
|
|
|
|
|
g_object_ref (impl),
|
|
|
|
|
(cairo_destroy_func_t)
|
|
|
|
|
g_object_unref);
|
|
|
|
|
buffer = _gdk_wayland_shm_surface_get_wl_buffer (impl->staging_cairo_surface);
|
|
|
|
|
wl_buffer_add_listener (buffer, &buffer_listener, impl->staging_cairo_surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
2013-04-24 22:00:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
/* The cairo surface returned here uses a memory segment that's shared
|
|
|
|
|
* with the display server. This is not a temporary buffer that gets
|
|
|
|
|
* copied to the display server, but the actual buffer the display server
|
|
|
|
|
* will ultimately end up sending to the GPU. At the time this happens
|
|
|
|
|
* impl->committed_cairo_surface gets set to impl->staging_cairo_surface, and
|
|
|
|
|
* impl->staging_cairo_surface gets nullified.
|
2013-04-24 22:00:41 +00:00
|
|
|
|
*/
|
|
|
|
|
static cairo_surface_t *
|
|
|
|
|
gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (impl->wrapper))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
gdk_wayland_window_ensure_cairo_surface (window);
|
2011-01-08 01:49:40 +00:00
|
|
|
|
|
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
|
|
|
|
cairo_surface_reference (impl->staging_cairo_surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
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
|
|
|
|
return impl->staging_cairo_surface;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 14:03:25 +00:00
|
|
|
|
static cairo_surface_t *
|
|
|
|
|
gdk_wayland_window_create_similar_image_surface (GdkWindow * window,
|
|
|
|
|
cairo_format_t format,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
|
|
|
|
return cairo_image_surface_create (format, width, height);
|
|
|
|
|
}
|
2012-04-04 13:05:27 +00:00
|
|
|
|
|
2013-04-29 19:49:12 +00:00
|
|
|
|
static gboolean
|
2014-11-22 16:08:34 +00:00
|
|
|
|
gdk_window_impl_wayland_begin_paint (GdkWindow *window)
|
2013-04-29 19:49:12 +00:00
|
|
|
|
{
|
|
|
|
|
gdk_wayland_window_ensure_cairo_surface (window);
|
2015-02-28 03:28:28 +00:00
|
|
|
|
|
2016-02-02 17:20:22 +00:00
|
|
|
|
return FALSE;
|
2013-04-29 19:49:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 21:29:08 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_impl_wayland_end_paint (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
int i, n;
|
|
|
|
|
|
2016-11-02 10:51:54 +00:00
|
|
|
|
if (impl->staging_cairo_surface &&
|
|
|
|
|
_gdk_wayland_is_shm_surface (impl->staging_cairo_surface) &&
|
2016-02-16 05:05:25 +00:00
|
|
|
|
!cairo_region_is_empty (window->current_paint.region))
|
2014-06-21 21:29:08 +00:00
|
|
|
|
{
|
2014-10-09 09:06:48 +00:00
|
|
|
|
gdk_wayland_window_attach_image (window);
|
|
|
|
|
|
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
|
|
|
|
/* If there's a committed buffer pending, then track which
|
|
|
|
|
* updates are staged until the next frame, so we can back
|
|
|
|
|
* fill the unstaged parts of the staging buffer with the
|
|
|
|
|
* last frame.
|
|
|
|
|
*/
|
|
|
|
|
if (impl->committed_cairo_surface != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (impl->staged_updates_region == NULL)
|
|
|
|
|
{
|
|
|
|
|
impl->staged_updates_region = cairo_region_copy (window->current_paint.region);
|
|
|
|
|
impl->backfill_cairo_surface = cairo_surface_reference (impl->committed_cairo_surface);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cairo_region_union (impl->staged_updates_region, window->current_paint.region);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
|
n = cairo_region_num_rectangles (window->current_paint.region);
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
cairo_region_get_rectangle (window->current_paint.region, i, &rect);
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_surface_damage (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
}
|
2016-02-16 05:05:25 +00:00
|
|
|
|
|
|
|
|
|
impl->pending_commit = TRUE;
|
2014-06-21 21:29:08 +00:00
|
|
|
|
}
|
2016-09-26 08:56:42 +00:00
|
|
|
|
|
2016-12-06 17:01:34 +00:00
|
|
|
|
gdk_wayland_window_sync (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_wayland_window_sync (GdkWindow *window)
|
|
|
|
|
{
|
2016-09-26 08:56:42 +00:00
|
|
|
|
gdk_wayland_window_sync_margin (window);
|
|
|
|
|
gdk_wayland_window_sync_opaque_region (window);
|
|
|
|
|
gdk_wayland_window_sync_input_region (window);
|
2014-06-21 21:29:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-07 04:41:31 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_window_impl_wayland_beep (GdkWindow *window)
|
|
|
|
|
{
|
2017-03-13 06:33:06 +00:00
|
|
|
|
gdk_wayland_display_system_bell (gdk_window_get_display (window),
|
|
|
|
|
window);
|
2016-03-07 04:41:31 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-04 13:05:27 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_impl_wayland_finalize (GObject *object)
|
|
|
|
|
{
|
2017-05-08 04:09:00 +00:00
|
|
|
|
GdkWindow *window = GDK_WINDOW (object);
|
2012-04-04 13:05:27 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (object));
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (object);
|
|
|
|
|
|
2017-05-08 04:09:00 +00:00
|
|
|
|
if (gdk_wayland_window_is_exported (window))
|
|
|
|
|
gdk_wayland_window_unexport_handle (window);
|
|
|
|
|
|
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);
|
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
|
|
|
|
g_clear_pointer (&impl->staged_updates_region, cairo_region_destroy);
|
2014-03-17 20:08:35 +00:00
|
|
|
|
|
2017-03-22 09:21:02 +00:00
|
|
|
|
g_hash_table_destroy (impl->shortcuts_inhibitors);
|
|
|
|
|
|
2012-04-04 13:05:27 +00:00
|
|
|
|
G_OBJECT_CLASS (_gdk_window_impl_wayland_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-30 14:04:45 +00:00
|
|
|
|
static void
|
2012-01-29 12:15:12 +00:00
|
|
|
|
gdk_wayland_window_configure (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
int width,
|
2015-02-24 08:11:48 +00:00
|
|
|
|
int height,
|
|
|
|
|
int scale)
|
2012-01-29 12:15:12 +00:00
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
|
|
event = gdk_event_new (GDK_CONFIGURE);
|
2014-06-19 18:33:35 +00:00
|
|
|
|
event->configure.window = g_object_ref (window);
|
2012-01-29 12:15:12 +00:00
|
|
|
|
event->configure.send_event = FALSE;
|
|
|
|
|
event->configure.width = width;
|
|
|
|
|
event->configure.height = height;
|
|
|
|
|
|
2015-02-24 08:11:48 +00:00
|
|
|
|
gdk_wayland_window_update_size (window, width, height, scale);
|
2013-05-14 14:25:30 +00:00
|
|
|
|
_gdk_window_update_size (window);
|
2012-01-29 12:15:12 +00:00
|
|
|
|
|
2014-06-19 18:34:22 +00:00
|
|
|
|
display = gdk_window_get_display (window);
|
2012-01-29 12:15:12 +00:00
|
|
|
|
_gdk_wayland_display_deliver_event (display, event);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-04 12:55:38 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_maybe_configure (GdkWindow *window,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int scale)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-11-25 13:24:52 +00:00
|
|
|
|
gboolean is_xdg_popup;
|
|
|
|
|
gboolean is_visible;
|
2016-04-04 12:55:38 +00:00
|
|
|
|
|
|
|
|
|
if (window->width == width &&
|
|
|
|
|
window->height == height &&
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
is_xdg_popup = (impl->display_server.xdg_popup != NULL);
|
|
|
|
|
is_visible = gdk_window_is_visible (window);
|
|
|
|
|
|
|
|
|
|
if (is_xdg_popup && is_visible && !impl->initial_configure_received)
|
|
|
|
|
gdk_window_hide (window);
|
|
|
|
|
|
2016-04-04 12:55:38 +00:00
|
|
|
|
gdk_wayland_window_configure (window, width, height, scale);
|
2016-11-25 13:24:52 +00:00
|
|
|
|
|
|
|
|
|
if (is_xdg_popup && is_visible && !impl->initial_configure_received)
|
|
|
|
|
gdk_window_show (window);
|
2016-04-04 12:55:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 22:20:14 +00:00
|
|
|
|
static void
|
2015-12-08 15:33:45 +00:00
|
|
|
|
gdk_wayland_window_sync_parent (GdkWindow *window,
|
|
|
|
|
GdkWindow *parent)
|
2011-02-11 22:20:14 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
GdkWindowImplWayland *impl_parent = NULL;
|
2016-07-01 09:03:36 +00:00
|
|
|
|
struct zxdg_toplevel_v6 *parent_toplevel;
|
2012-07-11 18:18:37 +00:00
|
|
|
|
|
2016-04-26 03:46:25 +00:00
|
|
|
|
g_assert (parent == NULL ||
|
|
|
|
|
gdk_window_get_display (window) == gdk_window_get_display (parent));
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
2013-11-11 23:02:19 +00:00
|
|
|
|
return;
|
2013-02-07 11:27:25 +00:00
|
|
|
|
|
2013-11-19 17:36:12 +00:00
|
|
|
|
if (impl->transient_for)
|
2015-12-08 15:33:45 +00:00
|
|
|
|
impl_parent = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
|
|
|
|
|
else if (parent)
|
|
|
|
|
impl_parent = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
|
2013-11-19 17:36:12 +00:00
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
if (impl_parent)
|
|
|
|
|
{
|
2013-11-19 17:36:12 +00:00
|
|
|
|
/* XXX: Is this correct? */
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl_parent->display_server.wl_surface)
|
2013-11-19 17:36:12 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
parent_toplevel = impl_parent->display_server.xdg_toplevel;
|
2013-11-19 17:36:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-07-01 09:03:36 +00:00
|
|
|
|
parent_toplevel = NULL;
|
2013-02-07 11:27:25 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_parent (impl->display_server.xdg_toplevel,
|
|
|
|
|
parent_toplevel);
|
2011-02-11 22:20:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_update_dialogs (GdkWindow *window)
|
|
|
|
|
{
|
2016-04-26 03:46:25 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2015-12-08 15:33:45 +00:00
|
|
|
|
GList *l;
|
|
|
|
|
|
2016-04-26 03:46:25 +00:00
|
|
|
|
if (!display_wayland->orphan_dialogs)
|
2015-12-08 15:33:45 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-04-26 03:46:25 +00:00
|
|
|
|
for (l = display_wayland->orphan_dialogs; l; l = l->next)
|
2015-12-08 15:33:45 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindow *w = l->data;
|
2016-02-29 09:14:56 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
if (!GDK_IS_WINDOW_IMPL_WAYLAND(w->impl))
|
|
|
|
|
continue;
|
2015-12-08 15:33:45 +00:00
|
|
|
|
|
2016-02-29 09:14:56 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (w->impl);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
if (w == window)
|
|
|
|
|
continue;
|
|
|
|
|
if (impl->hint != GDK_WINDOW_TYPE_HINT_DIALOG)
|
|
|
|
|
continue;
|
|
|
|
|
if (impl->transient_for)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Update the parent relationship only for dialogs without transients */
|
|
|
|
|
gdk_wayland_window_sync_parent (w, window);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-21 17:03:18 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_sync_title (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
2013-11-21 17:03:18 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!impl->title)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_title (impl->display_server.xdg_toplevel, impl->title);
|
2013-11-21 17:03:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 09:02:11 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_get_window_geometry (GdkWindow *window,
|
|
|
|
|
GdkRectangle *geometry)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
*geometry = (GdkRectangle) {
|
|
|
|
|
.x = impl->margin_left,
|
|
|
|
|
.y = impl->margin_top,
|
|
|
|
|
.width = window->width - (impl->margin_left + impl->margin_right),
|
|
|
|
|
.height = window->height - (impl->margin_top + impl->margin_bottom)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 21:54:20 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_sync_margin (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-07-01 09:02:11 +00:00
|
|
|
|
GdkRectangle geometry;
|
2014-02-27 21:54:20 +00:00
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.xdg_surface)
|
2014-02-27 21:54:20 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:02:11 +00:00
|
|
|
|
gdk_wayland_window_get_window_geometry (window, &geometry);
|
2016-04-05 16:17:40 +00:00
|
|
|
|
gdk_window_set_geometry_hints (window,
|
|
|
|
|
&impl->geometry_hints,
|
|
|
|
|
impl->geometry_mask);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_surface_v6_set_window_geometry (impl->display_server.xdg_surface,
|
|
|
|
|
geometry.x,
|
|
|
|
|
geometry.y,
|
|
|
|
|
geometry.width,
|
|
|
|
|
geometry.height);
|
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
|
|
|
|
|
gdk_wayland_window_sync_opaque_region (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
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)
|
|
|
|
|
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)),
|
|
|
|
|
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
|
|
|
|
|
gdk_wayland_window_sync_input_region (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
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)
|
|
|
|
|
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)),
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 14:05:43 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_set_input_region_if_empty (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWaylandDisplay *display;
|
|
|
|
|
struct wl_region *empty;
|
|
|
|
|
|
|
|
|
|
if (!impl->input_region_dirty)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (impl->input_region == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!cairo_region_is_empty (impl->input_region))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
empty = wl_compositor_create_region (display->compositor);
|
|
|
|
|
|
|
|
|
|
wl_surface_set_input_region (impl->display_server.wl_surface, empty);
|
|
|
|
|
wl_region_destroy (empty);
|
|
|
|
|
|
|
|
|
|
impl->input_region_dirty = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2015-02-28 05:15:13 +00:00
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
|
g_message ("surface enter, window %p output %p", window, output));
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
window_update_scale (window);
|
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
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2015-02-28 05:15:13 +00:00
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
|
g_message ("surface leave, window %p output %p", window, output));
|
|
|
|
|
|
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)
|
|
|
|
|
window_update_scale (window);
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-10 09:42:21 +00:00
|
|
|
|
static void
|
|
|
|
|
on_parent_surface_committed (GdkWindowImplWayland *parent_impl,
|
|
|
|
|
GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-05-06 08:31:41 +00:00
|
|
|
|
g_signal_handler_disconnect (parent_impl,
|
|
|
|
|
impl->parent_surface_committed_handler);
|
|
|
|
|
impl->parent_surface_committed_handler = 0;
|
2015-09-10 09:42:21 +00:00
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_subsurface_set_desync (impl->display_server.wl_subsurface);
|
2016-11-16 14:05:43 +00:00
|
|
|
|
|
|
|
|
|
/* Special case if the input region is empty, it won't change on resize */
|
|
|
|
|
gdk_wayland_set_input_region_if_empty (window);
|
2015-09-10 09:42:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-21 15:31:50 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_create_subsurface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl, *parent_impl = NULL;
|
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.wl_surface)
|
2014-08-21 15:31:50 +00:00
|
|
|
|
return; /* Bail out, surface and subsurface will be created later when shown */
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.wl_subsurface)
|
2014-08-21 15:31:50 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (impl->transient_for)
|
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
|
|
|
|
|
|
2017-05-16 14:13:34 +00:00
|
|
|
|
if (parent_impl && parent_impl->display_server.wl_surface)
|
2014-08-21 15:31:50 +00:00
|
|
|
|
{
|
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2016-02-02 16:42:52 +00:00
|
|
|
|
impl->display_server.wl_subsurface =
|
2014-08-21 15:31:50 +00:00
|
|
|
|
wl_subcompositor_get_subsurface (display_wayland->subcompositor,
|
2016-02-02 16:42:52 +00:00
|
|
|
|
impl->display_server.wl_surface, parent_impl->display_server.wl_surface);
|
2016-11-23 13:55:40 +00:00
|
|
|
|
wl_subsurface_set_position (impl->display_server.wl_subsurface,
|
|
|
|
|
window->x + window->abs_x,
|
|
|
|
|
window->y + window->abs_y);
|
2015-09-10 09:42:21 +00:00
|
|
|
|
|
|
|
|
|
/* In order to synchronize the initial position with the initial frame
|
|
|
|
|
* content, wait with making the subsurface desynchronized until after
|
|
|
|
|
* the parent was committed.
|
|
|
|
|
*/
|
2016-05-06 08:31:41 +00:00
|
|
|
|
impl->parent_surface_committed_handler =
|
|
|
|
|
g_signal_connect_object (parent_impl, "committed",
|
|
|
|
|
G_CALLBACK (on_parent_surface_committed),
|
|
|
|
|
window, 0);
|
2015-06-17 09:31:19 +00:00
|
|
|
|
gdk_window_request_transient_parent_commit (window);
|
2014-08-21 15:31:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_create_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
impl->display_server.wl_surface = wl_compositor_create_surface (display_wayland->compositor);
|
|
|
|
|
wl_surface_add_listener (impl->display_server.wl_surface, &surface_listener, window);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
}
|
2013-06-04 09:39:36 +00:00
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
static void
|
2016-07-01 09:03:36 +00:00
|
|
|
|
xdg_surface_configure (void *data,
|
|
|
|
|
struct zxdg_surface_v6 *xdg_surface,
|
|
|
|
|
uint32_t serial)
|
2011-12-05 15:55:37 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
2012-01-09 17:15:00 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
GdkWindowState new_state;
|
|
|
|
|
int width = impl->pending.width;
|
|
|
|
|
int height = impl->pending.height;
|
2016-06-06 08:48:36 +00:00
|
|
|
|
gboolean fixed_size;
|
2011-12-05 15:55:37 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (!impl->initial_configure_received)
|
2014-04-12 00:31:27 +00:00
|
|
|
|
{
|
2016-07-01 09:03:36 +00:00
|
|
|
|
gdk_window_thaw_updates (window);
|
|
|
|
|
impl->initial_configure_received = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (impl->display_server.xdg_popup)
|
|
|
|
|
{
|
|
|
|
|
zxdg_surface_v6_ack_configure (xdg_surface, serial);
|
|
|
|
|
return;
|
2014-04-12 00:31:27 +00:00
|
|
|
|
}
|
2014-02-06 19:28:51 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
new_state = impl->pending.state;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
impl->pending.state = 0;
|
|
|
|
|
|
2016-06-28 07:01:04 +00:00
|
|
|
|
fixed_size =
|
|
|
|
|
new_state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_TILED);
|
|
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
if (width == 0 && height == 0 && !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
|
|
|
|
{
|
|
|
|
|
GdkWindowHints geometry_mask = impl->geometry_mask;
|
|
|
|
|
|
|
|
|
|
/* Ignore size increments for maximized/fullscreen windows */
|
2016-06-06 08:48:36 +00:00
|
|
|
|
if (fixed_size)
|
2015-06-23 09:54:48 +00:00
|
|
|
|
geometry_mask &= ~GDK_HINT_RESIZE_INC;
|
|
|
|
|
|
|
|
|
|
gdk_window_constrain_size (&impl->geometry_hints,
|
|
|
|
|
geometry_mask,
|
|
|
|
|
width + impl->margin_left + impl->margin_right,
|
|
|
|
|
height + impl->margin_top + impl->margin_bottom,
|
|
|
|
|
&width,
|
|
|
|
|
&height);
|
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
/* Save size for next time we get 0x0 */
|
|
|
|
|
_gdk_wayland_window_save_size (window);
|
|
|
|
|
|
2015-06-23 09:54:48 +00:00
|
|
|
|
gdk_wayland_window_configure (window, width, height, impl->scale);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-28 05:15:13 +00:00
|
|
|
|
GDK_NOTE (EVENTS,
|
2016-05-25 13:07:51 +00:00
|
|
|
|
g_message ("configure, window %p %dx%d,%s%s%s%s",
|
2015-02-28 05:15:13 +00:00
|
|
|
|
window, width, height,
|
|
|
|
|
(new_state & GDK_WINDOW_STATE_FULLSCREEN) ? " fullscreen" : "",
|
|
|
|
|
(new_state & GDK_WINDOW_STATE_MAXIMIZED) ? " maximized" : "",
|
2016-05-25 13:07:51 +00:00
|
|
|
|
(new_state & GDK_WINDOW_STATE_FOCUSED) ? " focused" : "",
|
|
|
|
|
(new_state & GDK_WINDOW_STATE_TILED) ? " tiled" : ""));
|
2015-02-28 05:15:13 +00:00
|
|
|
|
|
2014-04-12 00:31:27 +00:00
|
|
|
|
_gdk_set_window_state (window, new_state);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_surface_v6_ack_configure (xdg_surface, serial);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
if (impl->hint != GDK_WINDOW_TYPE_HINT_DIALOG &&
|
|
|
|
|
new_state & GDK_WINDOW_STATE_FOCUSED)
|
|
|
|
|
gdk_wayland_window_update_dialogs (window);
|
2014-02-06 19:28:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
static const struct zxdg_surface_v6_listener xdg_surface_listener = {
|
|
|
|
|
xdg_surface_configure,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xdg_toplevel_configure (void *data,
|
|
|
|
|
struct zxdg_toplevel_v6 *xdg_toplevel,
|
|
|
|
|
int32_t width,
|
|
|
|
|
int32_t height,
|
|
|
|
|
struct wl_array *states)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
uint32_t *p;
|
|
|
|
|
|
|
|
|
|
wl_array_for_each (p, states)
|
|
|
|
|
{
|
|
|
|
|
uint32_t state = *p;
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
|
|
|
|
|
impl->pending.state |= GDK_WINDOW_STATE_FULLSCREEN;
|
|
|
|
|
break;
|
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
|
|
|
|
|
impl->pending.state |= GDK_WINDOW_STATE_MAXIMIZED;
|
|
|
|
|
break;
|
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
|
|
|
|
|
impl->pending.state |= GDK_WINDOW_STATE_FOCUSED;
|
|
|
|
|
break;
|
|
|
|
|
case ZXDG_TOPLEVEL_V6_STATE_RESIZING:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* Unknown state */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->pending.width = width;
|
|
|
|
|
impl->pending.height = height;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 22:16:40 +00:00
|
|
|
|
static void
|
2016-07-01 09:03:36 +00:00
|
|
|
|
xdg_toplevel_close (void *data,
|
|
|
|
|
struct zxdg_toplevel_v6 *xdg_toplevel)
|
2014-02-07 22:16:40 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
2015-02-28 05:15:13 +00:00
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
|
g_message ("close %p", window));
|
|
|
|
|
|
2014-02-07 22:16:40 +00:00
|
|
|
|
event = gdk_event_new (GDK_DELETE);
|
2014-06-19 18:55:04 +00:00
|
|
|
|
event->any.window = g_object_ref (window);
|
2014-02-07 22:16:40 +00:00
|
|
|
|
event->any.send_event = TRUE;
|
|
|
|
|
|
2014-06-19 18:34:22 +00:00
|
|
|
|
display = gdk_window_get_display (window);
|
2014-02-07 22:16:40 +00:00
|
|
|
|
_gdk_wayland_display_deliver_event (display, event);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
|
|
|
|
|
xdg_toplevel_configure,
|
|
|
|
|
xdg_toplevel_close,
|
2013-11-11 23:02:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
2012-07-11 13:15:04 +00:00
|
|
|
|
static void
|
2016-07-01 09:03:36 +00:00
|
|
|
|
gdk_wayland_window_create_xdg_toplevel (GdkWindow *window)
|
2012-07-11 13:15:04 +00:00
|
|
|
|
{
|
2013-11-11 23:02:19 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2015-03-23 05:08:09 +00:00
|
|
|
|
const gchar *app_id;
|
2016-09-04 19:52:55 +00:00
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
2015-07-13 16:30:42 +00:00
|
|
|
|
struct wl_output *fullscreen_output = NULL;
|
2015-07-26 00:22:41 +00:00
|
|
|
|
if (impl->initial_fullscreen_monitor >= 0 &&
|
2016-09-04 19:52:55 +00:00
|
|
|
|
impl->initial_fullscreen_monitor < gdk_display_get_n_monitors (display))
|
|
|
|
|
fullscreen_output = _gdk_wayland_screen_get_wl_output (gdk_window_get_screen (window), impl->initial_fullscreen_monitor);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
impl->display_server.xdg_surface =
|
|
|
|
|
zxdg_shell_v6_get_xdg_surface (display_wayland->xdg_shell,
|
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
|
zxdg_surface_v6_add_listener (impl->display_server.xdg_surface,
|
|
|
|
|
&xdg_surface_listener,
|
|
|
|
|
window);
|
|
|
|
|
gdk_window_freeze_updates (window);
|
|
|
|
|
|
|
|
|
|
impl->display_server.xdg_toplevel =
|
|
|
|
|
zxdg_surface_v6_get_toplevel (impl->display_server.xdg_surface);
|
|
|
|
|
zxdg_toplevel_v6_add_listener (impl->display_server.xdg_toplevel,
|
|
|
|
|
&xdg_toplevel_listener,
|
|
|
|
|
window);
|
2013-11-21 17:03:18 +00:00
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
gdk_wayland_window_sync_parent (window, NULL);
|
2013-11-21 17:03:18 +00:00
|
|
|
|
gdk_wayland_window_sync_title (window);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
|
|
|
|
|
if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_maximized (impl->display_server.xdg_toplevel);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
|
|
|
|
fullscreen_output);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
|
2015-08-18 00:38:07 +00:00
|
|
|
|
app_id = g_get_prgname ();
|
2015-03-23 05:08:09 +00:00
|
|
|
|
if (app_id == NULL)
|
|
|
|
|
app_id = gdk_get_program_class ();
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_app_id (impl->display_server.xdg_toplevel, app_id);
|
2015-03-23 05:08:09 +00:00
|
|
|
|
|
2015-03-06 03:40:12 +00:00
|
|
|
|
maybe_set_gtk_surface_dbus_properties (window);
|
2015-08-01 15:03:49 +00:00
|
|
|
|
maybe_set_gtk_surface_modal (window);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
|
|
|
|
|
if (impl->hint == GDK_WINDOW_TYPE_HINT_DIALOG)
|
|
|
|
|
_gdk_wayland_screen_add_orphan_dialog (window);
|
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
|
|
|
|
|
xdg_popup_configure (void *data,
|
|
|
|
|
struct zxdg_popup_v6 *xdg_popup,
|
|
|
|
|
int32_t x,
|
|
|
|
|
int32_t y,
|
|
|
|
|
int32_t width,
|
|
|
|
|
int32_t height)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkRectangle flipped_rect;
|
|
|
|
|
GdkRectangle final_rect;
|
|
|
|
|
gboolean flipped_x;
|
|
|
|
|
gboolean flipped_y;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (impl->transient_for);
|
|
|
|
|
|
2016-09-16 07:42:37 +00:00
|
|
|
|
if (impl->position_method != POSITION_METHOD_MOVE_TO_RECT)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
|
calculate_moved_to_rect_result (window, x, y, width, height,
|
|
|
|
|
&flipped_rect,
|
|
|
|
|
&final_rect,
|
|
|
|
|
&flipped_x,
|
|
|
|
|
&flipped_y);
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (window,
|
|
|
|
|
"moved-to-rect",
|
|
|
|
|
&flipped_rect,
|
|
|
|
|
&final_rect,
|
|
|
|
|
flipped_x,
|
|
|
|
|
flipped_y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xdg_popup_done (void *data,
|
|
|
|
|
struct zxdg_popup_v6 *xdg_popup)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
|
g_message ("done %p", window));
|
|
|
|
|
|
|
|
|
|
gdk_window_hide (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_popup_v6_listener xdg_popup_listener = {
|
|
|
|
|
xdg_popup_configure,
|
|
|
|
|
xdg_popup_done,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static enum zxdg_positioner_v6_anchor
|
|
|
|
|
rect_anchor_to_anchor (GdkGravity rect_anchor)
|
|
|
|
|
{
|
|
|
|
|
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 ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static enum zxdg_positioner_v6_gravity
|
|
|
|
|
window_anchor_to_gravity (GdkGravity rect_anchor)
|
|
|
|
|
{
|
|
|
|
|
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 ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkWindow *
|
2016-09-12 10:24:14 +00:00
|
|
|
|
get_real_parent_and_translate (GdkWindow *window,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y)
|
2016-09-12 06:53:51 +00:00
|
|
|
|
{
|
2016-09-12 10:24:14 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindow *parent = impl->transient_for;
|
|
|
|
|
|
2017-01-05 08:01:49 +00:00
|
|
|
|
while (parent)
|
2016-09-12 06:53:51 +00:00
|
|
|
|
{
|
2017-01-05 08:01:49 +00:00
|
|
|
|
GdkWindowImplWayland *parent_impl =
|
|
|
|
|
GDK_WINDOW_IMPL_WAYLAND (parent->impl);
|
|
|
|
|
GdkWindow *effective_parent = gdk_window_get_parent (parent);
|
|
|
|
|
|
|
|
|
|
if ((gdk_window_has_native (parent) &&
|
|
|
|
|
!parent_impl->display_server.wl_subsurface) ||
|
|
|
|
|
!effective_parent)
|
|
|
|
|
break;
|
|
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
|
*x += parent->x;
|
|
|
|
|
*y += parent->y;
|
2017-01-05 08:01:49 +00:00
|
|
|
|
|
|
|
|
|
if (gdk_window_has_native (parent) &&
|
|
|
|
|
parent_impl->display_server.wl_subsurface)
|
|
|
|
|
parent = parent->transient_for;
|
|
|
|
|
else
|
|
|
|
|
parent = effective_parent;
|
2016-09-12 06:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 10:39:06 +00:00
|
|
|
|
static void
|
|
|
|
|
translate_to_real_parent_window_geometry (GdkWindow *window,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *parent;
|
|
|
|
|
|
|
|
|
|
parent = get_real_parent_and_translate (window, x, y);
|
|
|
|
|
|
|
|
|
|
*x -= parent->shadow_left;
|
|
|
|
|
*y -= parent->shadow_top;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 10:46:44 +00:00
|
|
|
|
static GdkWindow *
|
2016-09-12 10:41:36 +00:00
|
|
|
|
translate_from_real_parent_window_geometry (GdkWindow *window,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *parent;
|
|
|
|
|
gint dx = 0;
|
|
|
|
|
gint dy = 0;
|
|
|
|
|
|
|
|
|
|
parent = get_real_parent_and_translate (window, &dx, &dy);
|
|
|
|
|
|
|
|
|
|
*x -= dx - parent->shadow_left;
|
|
|
|
|
*y -= dy - parent->shadow_top;
|
2016-09-12 10:46:44 +00:00
|
|
|
|
|
|
|
|
|
return parent;
|
2016-09-12 10:41:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
static void
|
|
|
|
|
calculate_popup_rect (GdkWindow *window,
|
|
|
|
|
GdkGravity rect_anchor,
|
|
|
|
|
GdkGravity window_anchor,
|
|
|
|
|
GdkRectangle *out_rect)
|
|
|
|
|
{
|
2016-09-12 07:00:21 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
GdkRectangle geometry;
|
2016-09-12 07:00:21 +00:00
|
|
|
|
GdkRectangle anchor_rect;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
int x = 0, y = 0;
|
|
|
|
|
|
|
|
|
|
gdk_wayland_window_get_window_geometry (window, &geometry);
|
|
|
|
|
|
2016-09-12 07:00:21 +00:00
|
|
|
|
anchor_rect = (GdkRectangle) {
|
|
|
|
|
.x = (impl->pending_move_to_rect.rect.x +
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dx),
|
|
|
|
|
.y = (impl->pending_move_to_rect.rect.y +
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dy),
|
|
|
|
|
.width = impl->pending_move_to_rect.rect.width,
|
|
|
|
|
.height = impl->pending_move_to_rect.rect.height
|
|
|
|
|
};
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
|
|
switch (rect_anchor)
|
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (window_anchor)
|
|
|
|
|
{
|
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:
|
|
|
|
|
x -= geometry.width / 2;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
x -= geometry.width;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
y -= geometry.height / 2;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
x -= geometry.width / 2;
|
|
|
|
|
y -= geometry.height / 2;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
x -= geometry.width;
|
|
|
|
|
y -= geometry.height / 2;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
y -= geometry.height;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
x -= geometry.width / 2;
|
|
|
|
|
y -= geometry.height;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
x -= geometry.width;
|
|
|
|
|
y -= geometry.height;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*out_rect = (GdkRectangle) {
|
|
|
|
|
.x = x,
|
|
|
|
|
.y = y,
|
|
|
|
|
.width = geometry.width,
|
|
|
|
|
.height = geometry.height
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
|
flip_anchor_horizontally (GdkGravity anchor)
|
|
|
|
|
{
|
|
|
|
|
switch (anchor)
|
|
|
|
|
{
|
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:
|
|
|
|
|
return GDK_GRAVITY_NORTH_EAST;
|
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
|
return GDK_GRAVITY_NORTH;
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_NORTH_WEST;
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
return GDK_GRAVITY_EAST;
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
return GDK_GRAVITY_CENTER;
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
return GDK_GRAVITY_WEST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_EAST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
return GDK_GRAVITY_SOUTH;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_WEST;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
|
flip_anchor_vertically (GdkGravity anchor)
|
|
|
|
|
{
|
|
|
|
|
switch (anchor)
|
|
|
|
|
{
|
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:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_WEST;
|
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
|
return GDK_GRAVITY_SOUTH;
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_EAST;
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
return GDK_GRAVITY_WEST;
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
return GDK_GRAVITY_CENTER;
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
return GDK_GRAVITY_EAST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
return GDK_GRAVITY_NORTH_WEST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
return GDK_GRAVITY_NORTH;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_NORTH_EAST;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
static void
|
2016-09-12 06:53:51 +00:00
|
|
|
|
calculate_moved_to_rect_result (GdkWindow *window,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
GdkRectangle *flipped_rect,
|
|
|
|
|
GdkRectangle *final_rect,
|
|
|
|
|
gboolean *flipped_x,
|
|
|
|
|
gboolean *flipped_y)
|
2016-07-01 09:03:36 +00:00
|
|
|
|
{
|
2016-07-08 08:54:36 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-09-12 10:46:44 +00:00
|
|
|
|
GdkWindow *parent;
|
|
|
|
|
gint window_x, window_y;
|
|
|
|
|
gint window_width, window_height;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
GdkRectangle best_rect;
|
|
|
|
|
|
2016-09-12 10:46:44 +00:00
|
|
|
|
parent = translate_from_real_parent_window_geometry (window, &x, &y);
|
2016-09-12 10:41:36 +00:00
|
|
|
|
*final_rect = (GdkRectangle) {
|
|
|
|
|
.x = x,
|
|
|
|
|
.y = y,
|
|
|
|
|
.width = width,
|
|
|
|
|
.height = height,
|
|
|
|
|
};
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
2016-09-12 10:46:44 +00:00
|
|
|
|
window_x = parent->x + x;
|
|
|
|
|
window_y = parent->y + y;
|
|
|
|
|
window_width = width + window->shadow_left + window->shadow_right;
|
|
|
|
|
window_height = height + window->shadow_top + window->shadow_bottom;
|
|
|
|
|
|
|
|
|
|
gdk_window_move_resize (window,
|
|
|
|
|
window_x, window_y,
|
|
|
|
|
window_width, window_height);
|
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
calculate_popup_rect (window,
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor,
|
|
|
|
|
impl->pending_move_to_rect.window_anchor,
|
|
|
|
|
&best_rect);
|
|
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
|
*flipped_rect = best_rect;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
|
|
if (x != best_rect.x &&
|
|
|
|
|
impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_FLIP_X)
|
|
|
|
|
{
|
|
|
|
|
GdkRectangle flipped_x_rect;
|
|
|
|
|
GdkGravity flipped_rect_anchor;
|
|
|
|
|
GdkGravity flipped_window_anchor;
|
|
|
|
|
|
|
|
|
|
flipped_rect_anchor =
|
|
|
|
|
flip_anchor_horizontally (impl->pending_move_to_rect.rect_anchor);
|
|
|
|
|
flipped_window_anchor =
|
|
|
|
|
flip_anchor_horizontally (impl->pending_move_to_rect.window_anchor),
|
|
|
|
|
calculate_popup_rect (window,
|
|
|
|
|
flipped_rect_anchor,
|
|
|
|
|
flipped_window_anchor,
|
|
|
|
|
&flipped_x_rect);
|
|
|
|
|
|
|
|
|
|
if (flipped_x_rect.x == x)
|
2016-09-12 06:53:51 +00:00
|
|
|
|
flipped_rect->x = x;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
}
|
|
|
|
|
if (y != best_rect.y &&
|
|
|
|
|
impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_FLIP_Y)
|
|
|
|
|
{
|
|
|
|
|
GdkRectangle flipped_y_rect;
|
|
|
|
|
GdkGravity flipped_rect_anchor;
|
|
|
|
|
GdkGravity flipped_window_anchor;
|
|
|
|
|
|
|
|
|
|
flipped_rect_anchor =
|
|
|
|
|
flip_anchor_vertically (impl->pending_move_to_rect.rect_anchor);
|
|
|
|
|
flipped_window_anchor =
|
|
|
|
|
flip_anchor_vertically (impl->pending_move_to_rect.window_anchor),
|
|
|
|
|
calculate_popup_rect (window,
|
|
|
|
|
flipped_rect_anchor,
|
|
|
|
|
flipped_window_anchor,
|
|
|
|
|
&flipped_y_rect);
|
|
|
|
|
|
|
|
|
|
if (flipped_y_rect.y == y)
|
2016-09-12 06:53:51 +00:00
|
|
|
|
flipped_rect->y = y;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 06:53:51 +00:00
|
|
|
|
*flipped_x = flipped_rect->x != best_rect.x;
|
|
|
|
|
*flipped_y = flipped_rect->y != best_rect.y;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct zxdg_positioner_v6 *
|
2016-09-12 10:24:50 +00:00
|
|
|
|
create_dynamic_positioner (GdkWindow *window)
|
2013-04-25 15:11:02 +00:00
|
|
|
|
{
|
2013-11-11 23:02:19 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
GdkWaylandDisplay *display =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2016-07-01 09:03:36 +00:00
|
|
|
|
struct zxdg_positioner_v6 *positioner;
|
|
|
|
|
GdkRectangle geometry;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
enum zxdg_positioner_v6_anchor anchor;
|
2017-03-20 13:36:29 +00:00
|
|
|
|
enum zxdg_positioner_v6_gravity gravity;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
uint32_t constraint_adjustment = ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE;
|
|
|
|
|
gint real_anchor_rect_x, real_anchor_rect_y;
|
|
|
|
|
gint anchor_rect_width, anchor_rect_height;
|
2013-04-25 15:11:02 +00:00
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
positioner = zxdg_shell_v6_create_positioner (display->xdg_shell);
|
2013-04-25 15:11:02 +00:00
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
gdk_wayland_window_get_window_geometry (window, &geometry);
|
|
|
|
|
zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
|
2013-08-30 11:55:37 +00:00
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
real_anchor_rect_x = impl->pending_move_to_rect.rect.x;
|
|
|
|
|
real_anchor_rect_y = impl->pending_move_to_rect.rect.y;
|
2016-09-12 10:39:06 +00:00
|
|
|
|
translate_to_real_parent_window_geometry (window,
|
|
|
|
|
&real_anchor_rect_x,
|
|
|
|
|
&real_anchor_rect_y);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
|
|
anchor_rect_width = impl->pending_move_to_rect.rect.width;
|
|
|
|
|
anchor_rect_height = impl->pending_move_to_rect.rect.height;
|
|
|
|
|
zxdg_positioner_v6_set_anchor_rect (positioner,
|
2016-09-12 10:39:06 +00:00
|
|
|
|
real_anchor_rect_x,
|
|
|
|
|
real_anchor_rect_y,
|
2016-07-08 08:54:36 +00:00
|
|
|
|
anchor_rect_width,
|
|
|
|
|
anchor_rect_height);
|
|
|
|
|
|
|
|
|
|
zxdg_positioner_v6_set_offset (positioner,
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dx,
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dy);
|
|
|
|
|
|
|
|
|
|
anchor = rect_anchor_to_anchor (impl->pending_move_to_rect.rect_anchor);
|
|
|
|
|
zxdg_positioner_v6_set_anchor (positioner, anchor);
|
|
|
|
|
|
|
|
|
|
gravity = window_anchor_to_gravity (impl->pending_move_to_rect.window_anchor);
|
|
|
|
|
zxdg_positioner_v6_set_gravity (positioner, gravity);
|
|
|
|
|
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_FLIP_X)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X;
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_FLIP_Y)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y;
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_SLIDE_X)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X;
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_SLIDE_Y)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y;
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_RESIZE_X)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X;
|
|
|
|
|
if (impl->pending_move_to_rect.anchor_hints & GDK_ANCHOR_RESIZE_Y)
|
|
|
|
|
constraint_adjustment |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y;
|
|
|
|
|
|
|
|
|
|
zxdg_positioner_v6_set_constraint_adjustment (positioner,
|
|
|
|
|
constraint_adjustment);
|
|
|
|
|
|
|
|
|
|
return positioner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct zxdg_positioner_v6 *
|
|
|
|
|
create_simple_positioner (GdkWindow *window,
|
|
|
|
|
GdkWindow *parent)
|
|
|
|
|
{
|
|
|
|
|
GdkWaylandDisplay *display =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
struct zxdg_positioner_v6 *positioner;
|
|
|
|
|
GdkRectangle geometry;
|
|
|
|
|
GdkRectangle parent_geometry;
|
|
|
|
|
int parent_x, parent_y;
|
2014-03-10 17:30:21 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
positioner = zxdg_shell_v6_create_positioner (display->xdg_shell);
|
2016-08-04 06:07:47 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
gdk_wayland_window_get_window_geometry (window, &geometry);
|
|
|
|
|
zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
|
|
|
|
|
|
|
|
|
|
parent_x = parent->x;
|
|
|
|
|
parent_y = parent->y;
|
|
|
|
|
|
|
|
|
|
gdk_wayland_window_get_window_geometry (parent, &parent_geometry);
|
|
|
|
|
parent_x += parent_geometry.x;
|
|
|
|
|
parent_y += parent_geometry.y;
|
|
|
|
|
|
|
|
|
|
zxdg_positioner_v6_set_anchor_rect (positioner,
|
|
|
|
|
(window->x + geometry.x) - parent_x,
|
|
|
|
|
(window->y + geometry.y) - parent_y,
|
|
|
|
|
1, 1);
|
|
|
|
|
zxdg_positioner_v6_set_anchor (positioner,
|
|
|
|
|
(ZXDG_POSITIONER_V6_ANCHOR_TOP |
|
|
|
|
|
ZXDG_POSITIONER_V6_ANCHOR_LEFT));
|
|
|
|
|
zxdg_positioner_v6_set_gravity (positioner,
|
|
|
|
|
(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
|
|
|
|
|
ZXDG_POSITIONER_V6_GRAVITY_RIGHT));
|
|
|
|
|
|
2016-07-08 08:54:36 +00:00
|
|
|
|
return positioner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_create_xdg_popup (GdkWindow *window,
|
|
|
|
|
GdkWindow *parent,
|
|
|
|
|
struct wl_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindowImplWayland *parent_impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
|
|
|
|
|
struct zxdg_positioner_v6 *positioner;
|
|
|
|
|
GdkSeat *gdk_seat;
|
|
|
|
|
guint32 serial;
|
|
|
|
|
|
|
|
|
|
if (!impl->display_server.wl_surface)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!parent_impl->display_server.xdg_surface)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Can't map popup, already mapped as toplevel");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (impl->display_server.xdg_popup)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Can't map popup, already mapped");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-09-02 10:51:34 +00:00
|
|
|
|
if ((display->current_popups &&
|
|
|
|
|
g_list_last (display->current_popups)->data != parent) ||
|
|
|
|
|
(!display->current_popups &&
|
|
|
|
|
!parent_impl->display_server.xdg_toplevel))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Tried to map a popup with a non-top most parent");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
|
|
impl->display_server.xdg_surface =
|
|
|
|
|
zxdg_shell_v6_get_xdg_surface (display->xdg_shell,
|
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
|
zxdg_surface_v6_add_listener (impl->display_server.xdg_surface,
|
|
|
|
|
&xdg_surface_listener,
|
|
|
|
|
window);
|
|
|
|
|
gdk_window_freeze_updates (window);
|
|
|
|
|
|
|
|
|
|
if (impl->position_method == POSITION_METHOD_MOVE_TO_RECT)
|
2016-09-12 10:24:50 +00:00
|
|
|
|
positioner = create_dynamic_positioner (window);
|
2016-07-08 08:54:36 +00:00
|
|
|
|
else
|
|
|
|
|
positioner = create_simple_positioner (window, parent);
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
impl->display_server.xdg_popup =
|
|
|
|
|
zxdg_surface_v6_get_popup (impl->display_server.xdg_surface,
|
|
|
|
|
parent_impl->display_server.xdg_surface,
|
|
|
|
|
positioner);
|
|
|
|
|
zxdg_popup_v6_add_listener (impl->display_server.xdg_popup,
|
|
|
|
|
&xdg_popup_listener,
|
|
|
|
|
window);
|
|
|
|
|
|
|
|
|
|
zxdg_positioner_v6_destroy (positioner);
|
2014-03-10 17:30:21 +00:00
|
|
|
|
|
2016-10-18 17:18:14 +00:00
|
|
|
|
if (seat)
|
|
|
|
|
{
|
|
|
|
|
gdk_seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
|
|
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_seat, NULL);
|
|
|
|
|
zxdg_popup_v6_grab (impl->display_server.xdg_popup, seat, serial);
|
|
|
|
|
}
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
wl_surface_commit (impl->display_server.wl_surface);
|
2016-09-02 10:51:34 +00:00
|
|
|
|
|
2016-09-05 15:53:38 +00:00
|
|
|
|
impl->popup_parent = parent;
|
2016-09-02 10:51:34 +00:00
|
|
|
|
display->current_popups = g_list_append (display->current_popups, window);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-15 21:12:09 +00:00
|
|
|
|
static struct wl_seat *
|
|
|
|
|
find_grab_input_seat (GdkWindow *window, GdkWindow *transient_for)
|
|
|
|
|
{
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
GdkWindow *attached_grab_window;
|
2014-05-15 21:12:09 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindowImplWayland *tmp_impl;
|
|
|
|
|
|
|
|
|
|
/* Use the device that was used for the grab as the device for
|
|
|
|
|
* the popup window setup - so this relies on GTK+ taking the
|
|
|
|
|
* grab before showing the popup window.
|
|
|
|
|
*/
|
2014-05-15 21:14:26 +00:00
|
|
|
|
if (impl->grab_input_seat)
|
2015-12-09 11:56:26 +00:00
|
|
|
|
return gdk_wayland_seat_get_wl_seat (impl->grab_input_seat);
|
2014-05-15 21:12:09 +00:00
|
|
|
|
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
/* HACK: GtkMenu grabs a special window known as the "grab transfer window"
|
|
|
|
|
* and then transfers the grab over to the correct window later. Look for
|
|
|
|
|
* this window when taking the grab to know it's correct.
|
|
|
|
|
*
|
|
|
|
|
* See: associate_menu_grab_transfer_window in gtkmenu.c
|
|
|
|
|
*/
|
|
|
|
|
attached_grab_window = g_object_get_data (G_OBJECT (window), "gdk-attached-grab-window");
|
|
|
|
|
if (attached_grab_window)
|
|
|
|
|
{
|
|
|
|
|
tmp_impl = GDK_WINDOW_IMPL_WAYLAND (attached_grab_window->impl);
|
|
|
|
|
if (tmp_impl->grab_input_seat)
|
2015-12-09 11:56:26 +00:00
|
|
|
|
return gdk_wayland_seat_get_wl_seat (tmp_impl->grab_input_seat);
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-15 21:14:26 +00:00
|
|
|
|
while (transient_for)
|
2014-05-15 21:12:09 +00:00
|
|
|
|
{
|
2014-05-15 21:14:26 +00:00
|
|
|
|
tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl);
|
2014-05-15 21:12:09 +00:00
|
|
|
|
|
2014-05-15 21:14:26 +00:00
|
|
|
|
if (tmp_impl->grab_input_seat)
|
2015-12-09 11:56:26 +00:00
|
|
|
|
return gdk_wayland_seat_get_wl_seat (tmp_impl->grab_input_seat);
|
2014-05-15 21:14:26 +00:00
|
|
|
|
|
|
|
|
|
transient_for = tmp_impl->transient_for;
|
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
|
|
|
|
|
should_be_mapped (GdkWindow *window)
|
|
|
|
|
{
|
2015-10-13 12:39:02 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2014-08-13 23:01:52 +00:00
|
|
|
|
/* Don't map crazy temp that GTK+ uses for internal X11 shenanigans. */
|
|
|
|
|
if (window->window_type == GDK_WINDOW_TEMP && window->x < 0 && window->y < 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (impl->hint == GDK_WINDOW_TYPE_HINT_DND)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-08-13 23:01:52 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
static gboolean
|
2015-12-21 13:35:53 +00:00
|
|
|
|
should_map_as_popup (GdkWindow *window)
|
2015-10-13 12:39:02 +00:00
|
|
|
|
{
|
2015-10-13 12:48:51 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2015-12-21 13:35:53 +00:00
|
|
|
|
/* Ideally, popup would be temp windows with a parent and grab */
|
|
|
|
|
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
|
|
|
|
|
{
|
|
|
|
|
/* If a temp window has a parent and a grab, we can use a popup */
|
|
|
|
|
if (impl->transient_for)
|
|
|
|
|
{
|
|
|
|
|
if (impl->grab_input_seat)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
2016-01-31 01:56:17 +00:00
|
|
|
|
g_message ("Window %p is a temporary window without parent, "
|
2015-12-21 13:35:53 +00:00
|
|
|
|
"application will not be able to position it on screen.",
|
|
|
|
|
window);
|
|
|
|
|
}
|
2015-10-13 12:39:02 +00:00
|
|
|
|
|
2015-12-21 13:35:53 +00:00
|
|
|
|
/* Yet we need to keep the window type hint tests for compatibility */
|
2017-10-06 19:19:42 +00:00
|
|
|
|
switch ((guint) impl->hint)
|
2015-10-18 12:23:07 +00:00
|
|
|
|
{
|
2015-12-21 13:35:53 +00:00
|
|
|
|
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
|
|
|
|
|
case GDK_WINDOW_TYPE_HINT_COMBO:
|
2015-10-18 12:23:07 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-10-13 12:48:51 +00:00
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2015-12-21 13:35:53 +00:00
|
|
|
|
should_map_as_subsurface (GdkWindow *window)
|
2015-10-13 12:39:02 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2015-12-21 13:35:53 +00:00
|
|
|
|
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_SUBSURFACE)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TEMP)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* if we want a popup, we do not want a subsurface */
|
|
|
|
|
if (should_map_as_popup (window))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (impl->transient_for)
|
2015-10-18 12:23:07 +00:00
|
|
|
|
{
|
2015-12-21 13:35:53 +00:00
|
|
|
|
GdkWindowImplWayland *impl_parent;
|
2015-10-18 12:23:07 +00:00
|
|
|
|
|
2015-12-21 13:35:53 +00:00
|
|
|
|
impl_parent = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
|
|
|
|
|
/* subsurface require that the parent is mapped */
|
|
|
|
|
if (impl_parent->mapped)
|
2015-10-18 13:21:51 +00:00
|
|
|
|
return TRUE;
|
2015-12-21 13:35:53 +00:00
|
|
|
|
else
|
2017-04-21 22:27:43 +00:00
|
|
|
|
g_warning ("Couldn't map window %p as subsurface because its parent is not mapped.",
|
2015-12-21 13:35:53 +00:00
|
|
|
|
window);
|
2015-10-18 13:21:51 +00:00
|
|
|
|
|
2015-10-18 12:23:07 +00:00
|
|
|
|
}
|
2015-10-13 12:39:02 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
/* Get the window that can be used as a parent for a popup, i.e. a xdg_toplevel
|
2015-10-18 13:03:52 +00:00
|
|
|
|
* or xdg_popup. If the window is not, traverse up the transiency parents until
|
|
|
|
|
* we find one.
|
|
|
|
|
*/
|
|
|
|
|
static GdkWindow *
|
|
|
|
|
get_popup_parent (GdkWindow *window)
|
|
|
|
|
{
|
2015-11-19 19:39:42 +00:00
|
|
|
|
while (window)
|
2015-10-18 13:03:52 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_popup || impl->display_server.xdg_toplevel)
|
2015-10-18 13:03:52 +00:00
|
|
|
|
return window;
|
|
|
|
|
|
|
|
|
|
window = impl->transient_for;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_map (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2015-06-13 21:49:20 +00:00
|
|
|
|
GdkWindow *transient_for = NULL;
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2014-08-13 23:01:52 +00:00
|
|
|
|
if (!should_be_mapped (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (impl->mapped || impl->use_custom_surface)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (should_map_as_subsurface (window))
|
2013-11-11 23:02:19 +00:00
|
|
|
|
{
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (impl->transient_for)
|
|
|
|
|
gdk_wayland_window_create_subsurface (window);
|
|
|
|
|
else
|
2015-12-21 13:35:53 +00:00
|
|
|
|
g_warning ("Couldn't map window %p as susburface yet because it doesn't have a parent",
|
2015-10-13 12:39:02 +00:00
|
|
|
|
window);
|
|
|
|
|
}
|
|
|
|
|
else if (should_map_as_popup (window))
|
|
|
|
|
{
|
|
|
|
|
gboolean create_fallback = FALSE;
|
|
|
|
|
struct wl_seat *grab_input_seat;
|
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
/* Popup menus can appear without a transient parent, which means they
|
|
|
|
|
* cannot be positioned properly on Wayland. This attempts to guess the
|
|
|
|
|
* surface they should be positioned with by finding the surface beneath
|
2015-06-05 05:29:22 +00:00
|
|
|
|
* the device that created the grab for the popup window.
|
2013-11-11 23:02:19 +00:00
|
|
|
|
*/
|
|
|
|
|
if (!impl->transient_for && impl->hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU)
|
|
|
|
|
{
|
2015-12-09 11:56:26 +00:00
|
|
|
|
GdkDevice *grab_device = NULL;
|
2015-06-05 05:29:22 +00:00
|
|
|
|
|
|
|
|
|
/* The popup menu window is not the grabbed window. This may mean
|
|
|
|
|
* that a "transfer window" (see gtkmenu.c) is used, and we need
|
|
|
|
|
* to find that window to get the grab device. If so is the case
|
|
|
|
|
* the "transfer window" can be retrieved via the
|
|
|
|
|
* "gdk-attached-grab-window" associated data field.
|
|
|
|
|
*/
|
2015-12-09 11:56:26 +00:00
|
|
|
|
if (!impl->grab_input_seat)
|
2015-06-05 05:29:22 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindow *attached_grab_window =
|
|
|
|
|
g_object_get_data (G_OBJECT (window),
|
|
|
|
|
"gdk-attached-grab-window");
|
|
|
|
|
if (attached_grab_window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *attached_impl =
|
|
|
|
|
GDK_WINDOW_IMPL_WAYLAND (attached_grab_window->impl);
|
2015-12-09 11:56:26 +00:00
|
|
|
|
grab_device = gdk_seat_get_pointer (attached_impl->grab_input_seat);
|
2015-06-05 05:29:22 +00:00
|
|
|
|
transient_for =
|
|
|
|
|
gdk_device_get_window_at_position (grab_device,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-09 11:56:26 +00:00
|
|
|
|
grab_device = gdk_seat_get_pointer (impl->grab_input_seat);
|
2015-06-05 05:29:22 +00:00
|
|
|
|
transient_for =
|
|
|
|
|
gdk_device_get_window_at_position (grab_device, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (transient_for)
|
2016-10-25 07:54:37 +00:00
|
|
|
|
transient_for = get_popup_parent (gdk_window_get_toplevel (transient_for));
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2015-06-05 05:35:21 +00:00
|
|
|
|
/* If the position was not explicitly set, start the popup at the
|
|
|
|
|
* position of the device that holds the grab.
|
|
|
|
|
*/
|
2016-07-08 08:54:36 +00:00
|
|
|
|
if (impl->position_method == POSITION_METHOD_NONE && grab_device)
|
2015-12-09 11:56:26 +00:00
|
|
|
|
gdk_window_get_device_position (transient_for, grab_device,
|
2015-06-05 05:35:21 +00:00
|
|
|
|
&window->x, &window->y, NULL);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-08-04 06:05:06 +00:00
|
|
|
|
{
|
2016-10-25 07:54:37 +00:00
|
|
|
|
transient_for = gdk_window_get_toplevel (impl->transient_for);
|
2016-08-04 06:05:06 +00:00
|
|
|
|
transient_for = get_popup_parent (transient_for);
|
|
|
|
|
}
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (!transient_for)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Couldn't map as window %p as popup because it doesn't have a parent",
|
|
|
|
|
window);
|
|
|
|
|
|
|
|
|
|
create_fallback = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
2013-11-11 23:02:19 +00:00
|
|
|
|
{
|
2015-10-13 12:39:02 +00:00
|
|
|
|
grab_input_seat = find_grab_input_seat (window, transient_for);
|
2013-11-11 23:02:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (!create_fallback)
|
|
|
|
|
{
|
|
|
|
|
gdk_wayland_window_create_xdg_popup (window,
|
|
|
|
|
transient_for,
|
|
|
|
|
grab_input_seat);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-07-01 09:03:36 +00:00
|
|
|
|
gdk_wayland_window_create_xdg_toplevel (window);
|
2015-10-13 12:39:02 +00:00
|
|
|
|
}
|
2013-11-11 23:02:19 +00:00
|
|
|
|
}
|
2015-10-13 12:39:02 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-07-01 09:03:36 +00:00
|
|
|
|
gdk_wayland_window_create_xdg_toplevel (window);
|
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
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_wayland_window_show (GdkWindow *window,
|
|
|
|
|
gboolean already_mapped)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.wl_surface)
|
2013-04-25 15:11:02 +00:00
|
|
|
|
gdk_wayland_window_create_surface (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2014-04-22 23:16:48 +00:00
|
|
|
|
gdk_wayland_window_map (window);
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
_gdk_make_event (window, GDK_MAP, NULL, FALSE);
|
2011-02-11 03:21:08 +00:00
|
|
|
|
|
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
|
|
|
|
if (impl->staging_cairo_surface &&
|
|
|
|
|
_gdk_wayland_is_shm_surface (impl->staging_cairo_surface))
|
2011-02-11 03:21:08 +00:00
|
|
|
|
gdk_wayland_window_attach_image (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-10 09:42:21 +00:00
|
|
|
|
static void
|
|
|
|
|
unmap_subsurface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindowImplWayland *parent_impl;
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
g_return_if_fail (impl->display_server.wl_subsurface);
|
2015-09-10 09:42:21 +00:00
|
|
|
|
g_return_if_fail (impl->transient_for);
|
|
|
|
|
|
|
|
|
|
parent_impl = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_subsurface_destroy (impl->display_server.wl_subsurface);
|
2016-05-06 08:31:41 +00:00
|
|
|
|
if (impl->parent_surface_committed_handler)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handler_disconnect (parent_impl,
|
|
|
|
|
impl->parent_surface_committed_handler);
|
|
|
|
|
impl->parent_surface_committed_handler = 0;
|
|
|
|
|
}
|
2016-02-02 16:42:52 +00:00
|
|
|
|
impl->display_server.wl_subsurface = NULL;
|
2015-09-10 09:42:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 15:53:38 +00:00
|
|
|
|
static void
|
|
|
|
|
unmap_popups_for_window (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
for (l = display_wayland->current_popups; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *popup = l->data;
|
|
|
|
|
GdkWindowImplWayland *popup_impl = GDK_WINDOW_IMPL_WAYLAND (popup->impl);
|
|
|
|
|
|
|
|
|
|
if (popup_impl->popup_parent == window)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Tried to unmap the parent of a popup");
|
|
|
|
|
gdk_window_hide (popup);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
static void
|
2017-01-20 13:04:29 +00:00
|
|
|
|
gdk_wayland_window_hide_surface (GdkWindow *window)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2014-10-09 09:06:48 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-07-13 07:24:19 +00:00
|
|
|
|
unset_transient_for_exported (window);
|
|
|
|
|
|
2016-09-05 15:53:38 +00:00
|
|
|
|
unmap_popups_for_window (window);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.wl_surface)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2014-10-09 14:09:05 +00:00
|
|
|
|
if (impl->dummy_egl_surface)
|
|
|
|
|
{
|
2015-08-28 17:51:11 +00:00
|
|
|
|
eglDestroySurface (display_wayland->egl_display, impl->dummy_egl_surface);
|
2014-10-09 14:09:05 +00:00
|
|
|
|
impl->dummy_egl_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.dummy_egl_window)
|
2014-10-09 14:09:05 +00:00
|
|
|
|
{
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_egl_window_destroy (impl->display_server.dummy_egl_window);
|
|
|
|
|
impl->display_server.dummy_egl_window = NULL;
|
2014-10-09 14:09:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
|
if (impl->egl_surface)
|
|
|
|
|
{
|
2015-08-28 17:51:11 +00:00
|
|
|
|
eglDestroySurface (display_wayland->egl_display, impl->egl_surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
impl->egl_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.egl_window)
|
2014-10-09 09:06:48 +00:00
|
|
|
|
{
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_egl_window_destroy (impl->display_server.egl_window);
|
|
|
|
|
impl->display_server.egl_window = NULL;
|
2014-10-09 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
2014-06-19 19:10:01 +00:00
|
|
|
|
{
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_destroy (impl->display_server.xdg_toplevel);
|
|
|
|
|
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
|
|
|
|
{
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_popup_v6_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 =
|
|
|
|
|
g_list_remove (display_wayland->current_popups, window);
|
2014-06-19 19:10:01 +00:00
|
|
|
|
}
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_surface)
|
|
|
|
|
{
|
|
|
|
|
zxdg_surface_v6_destroy (impl->display_server.xdg_surface);
|
|
|
|
|
impl->display_server.xdg_surface = NULL;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
if (!impl->initial_configure_received)
|
|
|
|
|
gdk_window_thaw_updates (window);
|
|
|
|
|
else
|
|
|
|
|
impl->initial_configure_received = FALSE;
|
2016-07-01 09:03:36 +00:00
|
|
|
|
}
|
2014-06-19 19:10:01 +00:00
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.wl_subsurface)
|
2015-09-10 09:42:21 +00:00
|
|
|
|
unmap_subsurface (window);
|
2014-08-21 15:31:50 +00:00
|
|
|
|
|
2015-02-25 13:46:54 +00:00
|
|
|
|
if (impl->awaiting_frame)
|
|
|
|
|
{
|
2015-08-28 17:55:23 +00:00
|
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
|
|
2015-02-25 13:46:54 +00:00
|
|
|
|
impl->awaiting_frame = FALSE;
|
2015-08-28 17:55:23 +00:00
|
|
|
|
frame_clock = gdk_window_get_frame_clock (window);
|
|
|
|
|
if (frame_clock)
|
|
|
|
|
_gdk_frame_clock_thaw (frame_clock);
|
2015-02-25 13:46:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
wl_surface_destroy (impl->display_server.wl_surface);
|
|
|
|
|
impl->display_server.wl_surface = NULL;
|
2013-04-25 15:19:31 +00:00
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
g_slist_free (impl->display_server.outputs);
|
|
|
|
|
impl->display_server.outputs = NULL;
|
2015-12-08 15:33:45 +00:00
|
|
|
|
|
|
|
|
|
if (impl->hint == GDK_WINDOW_TYPE_HINT_DIALOG && !impl->transient_for)
|
2016-04-26 03:46:25 +00:00
|
|
|
|
display_wayland->orphan_dialogs =
|
|
|
|
|
g_list_remove (display_wayland->orphan_dialogs, window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
2013-09-16 22:36:18 +00:00
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
_gdk_wayland_window_clear_saved_size (window);
|
2014-09-01 18:20:49 +00:00
|
|
|
|
impl->pending_commit = FALSE;
|
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
|
|
|
|
|
gdk_wayland_window_hide (GdkWindow *window)
|
|
|
|
|
{
|
2017-01-20 13:04:29 +00:00
|
|
|
|
gdk_wayland_window_hide_surface (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
_gdk_window_clear_update_area (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_withdraw (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (!window->destroyed)
|
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_WITHDRAWN);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
g_assert (!GDK_WINDOW_IS_MAPPED (window));
|
|
|
|
|
|
2017-01-20 13:04:29 +00:00
|
|
|
|
gdk_wayland_window_hide_surface (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_set_events (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkEventMask event_mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
GDK_WINDOW (window)->event_mask = event_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkEventMask
|
|
|
|
|
gdk_window_wayland_get_events (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return GDK_WINDOW (window)->event_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_raise (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_lower (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_restack_toplevel (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindow *sibling,
|
|
|
|
|
gboolean above)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-04 18:26:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_request_transient_parent_commit (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *window_impl, *impl;
|
|
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
|
|
|
|
|
|
window_impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (!window_impl->transient_for)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window_impl->transient_for->impl);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.wl_surface || impl->pending_commit)
|
2014-11-04 18:26:25 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
frame_clock = gdk_window_get_frame_clock (window_impl->transient_for);
|
|
|
|
|
|
|
|
|
|
if (!frame_clock)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->pending_commit = TRUE;
|
|
|
|
|
gdk_frame_clock_request_phase (frame_clock,
|
|
|
|
|
GDK_FRAME_CLOCK_PHASE_AFTER_PAINT);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_move_resize (GdkWindow *window,
|
2012-04-20 16:57:33 +00:00
|
|
|
|
gboolean with_move,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
2015-02-24 08:11:48 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2012-04-20 16:57:33 +00:00
|
|
|
|
if (with_move)
|
|
|
|
|
{
|
2014-08-21 15:39:09 +00:00
|
|
|
|
/* Each toplevel has in its own "root" coordinate system */
|
2017-10-20 00:52:11 +00:00
|
|
|
|
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TOPLEVEL)
|
2014-08-21 15:39:09 +00:00
|
|
|
|
{
|
|
|
|
|
window->x = x;
|
|
|
|
|
window->y = y;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
impl->position_method = POSITION_METHOD_MOVE_RESIZE;
|
2014-08-21 15:31:50 +00:00
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.wl_subsurface)
|
2014-08-27 10:03:28 +00:00
|
|
|
|
{
|
2016-11-23 13:55:40 +00:00
|
|
|
|
wl_subsurface_set_position (impl->display_server.wl_subsurface,
|
|
|
|
|
window->x + window->abs_x,
|
|
|
|
|
window->y + window->abs_y);
|
2014-11-04 18:26:25 +00:00
|
|
|
|
gdk_window_request_transient_parent_commit (window);
|
2014-08-27 10:03:28 +00:00
|
|
|
|
}
|
2014-08-21 15:39:09 +00:00
|
|
|
|
}
|
2012-04-20 16:57:33 +00:00
|
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
2012-01-17 14:59:03 +00:00
|
|
|
|
/* If this function is called with width and height = -1 then that means
|
|
|
|
|
* just move the window - don't update its size
|
|
|
|
|
*/
|
|
|
|
|
if (width > 0 && height > 0)
|
2016-04-04 12:55:38 +00:00
|
|
|
|
gdk_wayland_window_maybe_configure (window, width, height, impl->scale);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-12 17:08:32 +00:00
|
|
|
|
/* Avoid zero width/height as this is a protocol error */
|
|
|
|
|
static void
|
|
|
|
|
sanitize_anchor_rect (GdkWindow *window,
|
|
|
|
|
GdkRectangle *rect)
|
|
|
|
|
{
|
|
|
|
|
gint original_width = rect->width;
|
|
|
|
|
gint original_height = rect->height;
|
|
|
|
|
|
|
|
|
|
rect->width = MAX (1, rect->width);
|
|
|
|
|
rect->height = MAX (1, rect->height);
|
2017-02-01 08:41:07 +00:00
|
|
|
|
rect->x = MAX (rect->x + original_width - rect->width, 0);
|
|
|
|
|
rect->y = MAX (rect->y + original_height - rect->height, 0);
|
2017-01-12 17:08:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 07:00:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_move_to_rect (GdkWindow *window,
|
|
|
|
|
const GdkRectangle *rect,
|
|
|
|
|
GdkGravity rect_anchor,
|
|
|
|
|
GdkGravity window_anchor,
|
|
|
|
|
GdkAnchorHints anchor_hints,
|
|
|
|
|
gint rect_anchor_dx,
|
|
|
|
|
gint rect_anchor_dy)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
impl->pending_move_to_rect.rect = *rect;
|
2017-01-12 17:08:32 +00:00
|
|
|
|
sanitize_anchor_rect (window, &impl->pending_move_to_rect.rect);
|
|
|
|
|
|
2016-08-08 07:00:42 +00:00
|
|
|
|
impl->pending_move_to_rect.rect_anchor = rect_anchor;
|
|
|
|
|
impl->pending_move_to_rect.window_anchor = window_anchor;
|
|
|
|
|
impl->pending_move_to_rect.anchor_hints = anchor_hints;
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dx = rect_anchor_dx;
|
|
|
|
|
impl->pending_move_to_rect.rect_anchor_dy = rect_anchor_dy;
|
2016-07-08 08:54:36 +00:00
|
|
|
|
|
|
|
|
|
impl->position_method = POSITION_METHOD_MOVE_TO_RECT;
|
2016-08-08 07:00:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_set_device_cursor (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkCursor *cursor)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
if (!GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_get_geometry (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
if (!GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
|
|
|
|
if (x)
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*x = window->x;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (y)
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*y = window->y;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (width)
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*width = window->width;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (height)
|
2013-09-16 21:23:29 +00:00
|
|
|
|
*height = window->height;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
|
static void
|
2010-12-18 20:38:49 +00:00
|
|
|
|
gdk_window_wayland_get_root_coords (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint *root_x,
|
|
|
|
|
gint *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
|
|
|
|
|
* some amount of control over the placement of our window, and we can
|
|
|
|
|
* semi-accurately control the x/y position of these windows, if they are
|
|
|
|
|
* relative to another surface.
|
|
|
|
|
*
|
|
|
|
|
* To pretend we have something called a root coordinate space, assume all
|
|
|
|
|
* parent-less windows are positioned in (0, 0), and all relative positioned
|
|
|
|
|
* popups and subsurfaces are placed within this fake root coordinate space.
|
|
|
|
|
*
|
|
|
|
|
* For example a 200x200 large toplevel window will have the position (0, 0).
|
|
|
|
|
* 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
|
|
|
|
|
* relative position (50,50). These three windows would make up one single
|
|
|
|
|
* fake root coordinate space.
|
|
|
|
|
*/
|
2012-04-23 16:26:49 +00:00
|
|
|
|
|
2013-08-30 07:23:56 +00:00
|
|
|
|
if (root_x)
|
2016-08-04 06:07:47 +00:00
|
|
|
|
*root_x = window->x + x;
|
2013-08-30 07:23:56 +00:00
|
|
|
|
|
|
|
|
|
if (root_y)
|
2016-08-04 06:07:47 +00:00
|
|
|
|
*root_y = window->y + y;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_window_wayland_get_device_state (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkDevice *device,
|
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y,
|
|
|
|
|
GdkModifierType *mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean return_val;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
|
|
|
|
|
|
if (!GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *child;
|
|
|
|
|
|
|
|
|
|
GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
|
2017-08-08 19:43:03 +00:00
|
|
|
|
&child,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
NULL, NULL,
|
|
|
|
|
x, y, mask);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
return_val = (child != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_window_wayland_shape_combine_region (GdkWindow *window,
|
|
|
|
|
const cairo_region_t *shape_region,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-16 21:23:29 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_window_wayland_input_shape_combine_region (GdkWindow *window,
|
|
|
|
|
const cairo_region_t *shape_region,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2014-03-17 20:02:47 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->input_region, cairo_region_destroy);
|
2014-11-07 16:16:59 +00:00
|
|
|
|
|
|
|
|
|
if (shape_region)
|
|
|
|
|
{
|
|
|
|
|
impl->input_region = cairo_region_copy (shape_region);
|
|
|
|
|
cairo_region_translate (impl->input_region, offset_x, offset_y);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 08:48:16 +00:00
|
|
|
|
impl->input_region_dirty = TRUE;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_destroy (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean recursing,
|
|
|
|
|
gboolean foreign_destroy)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2013-04-25 15:11:02 +00:00
|
|
|
|
/* Wayland windows 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);
|
|
|
|
|
|
2017-01-20 13:04:29 +00:00
|
|
|
|
gdk_wayland_window_hide_surface (window);
|
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
|
|
|
|
drop_cairo_surfaces (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_focus (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2016-03-08 09:03:06 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_wayland_window_set_type_hint (GdkWindow *window,
|
|
|
|
|
GdkWindowTypeHint hint)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2012-01-13 14:48:46 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2012-01-13 14:48:46 +00:00
|
|
|
|
impl->hint = hint;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkWindowTypeHint
|
|
|
|
|
gdk_wayland_window_get_type_hint (GdkWindow *window)
|
|
|
|
|
{
|
2014-08-28 12:10:00 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return GDK_WINDOW_TYPE_HINT_NORMAL;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
return impl->hint;
|
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)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindowState new_state = 0;
|
|
|
|
|
uint32_t *p;
|
|
|
|
|
|
|
|
|
|
wl_array_for_each (p, states)
|
|
|
|
|
{
|
|
|
|
|
uint32_t state = *p;
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case GTK_SURFACE1_STATE_TILED:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_TILED;
|
|
|
|
|
break;
|
2017-08-17 03:35:52 +00:00
|
|
|
|
|
|
|
|
|
/* Since v2 */
|
|
|
|
|
case GTK_SURFACE1_STATE_TILED_TOP:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_TOP_TILED;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_STATE_TILED_RIGHT:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_RIGHT_TILED;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_STATE_TILED_BOTTOM:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_BOTTOM_TILED;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_STATE_TILED_LEFT:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_LEFT_TILED;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* Unknown state */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->pending.state |= new_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_surface_configure_edges (void *data,
|
|
|
|
|
struct gtk_surface1 *gtk_surface,
|
|
|
|
|
struct wl_array *edge_constraints)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = GDK_WINDOW (data);
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWindowState new_state = 0;
|
|
|
|
|
uint32_t *p;
|
|
|
|
|
|
|
|
|
|
wl_array_for_each (p, edge_constraints)
|
|
|
|
|
{
|
|
|
|
|
uint32_t constraint = *p;
|
|
|
|
|
|
|
|
|
|
switch (constraint)
|
|
|
|
|
{
|
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_TOP:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_TOP_RESIZABLE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_RIGHT:
|
2017-10-05 00:03:19 +00:00
|
|
|
|
new_state |= GDK_WINDOW_STATE_RIGHT_RESIZABLE;
|
2017-08-17 03:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_BOTTOM:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_BOTTOM_RESIZABLE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_LEFT:
|
|
|
|
|
new_state |= GDK_WINDOW_STATE_LEFT_RESIZABLE;
|
|
|
|
|
break;
|
2016-06-28 07:01:22 +00:00
|
|
|
|
default:
|
|
|
|
|
/* Unknown state */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->pending.state |= new_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
gdk_wayland_window_init_gtk_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWaylandDisplay *display =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.gtk_surface != NULL)
|
2015-03-06 03:40:12 +00:00
|
|
|
|
return;
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.xdg_surface == NULL)
|
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);
|
2016-04-05 16:17:40 +00:00
|
|
|
|
gdk_window_set_geometry_hints (window,
|
|
|
|
|
&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,
|
|
|
|
|
window);
|
2015-03-06 03:40:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-06 00:41:06 +00:00
|
|
|
|
static void
|
2015-08-01 15:03:49 +00:00
|
|
|
|
maybe_set_gtk_surface_modal (GdkWindow *window)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2015-03-06 03:40:12 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
gdk_wayland_window_init_gtk_surface (window);
|
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-08-01 15:03:49 +00:00
|
|
|
|
if (window->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
|
|
|
|
|
gdk_wayland_window_set_modal_hint (GdkWindow *window,
|
|
|
|
|
gboolean modal)
|
|
|
|
|
{
|
|
|
|
|
window->modal_hint = modal;
|
|
|
|
|
maybe_set_gtk_surface_modal (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_skip_taskbar_hint (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean skips_taskbar)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_skip_pager_hint (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean skips_pager)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_urgency_hint (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean urgent)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_geometry_hints (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
const GdkGeometry *geometry,
|
|
|
|
|
GdkWindowHints geom_mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2012-01-09 17:11:22 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
2016-04-05 16:17:40 +00:00
|
|
|
|
int width, height;
|
2012-01-09 17:11:22 +00:00
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2012-01-09 17:11:22 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
impl->geometry_hints = *geometry;
|
|
|
|
|
impl->geometry_mask = geom_mask;
|
2016-04-05 16:17:40 +00:00
|
|
|
|
|
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MIN_SIZE)
|
|
|
|
|
{
|
2016-09-27 14:48:57 +00:00
|
|
|
|
width = MAX (0, geometry->min_width - (impl->margin_left + impl->margin_right));
|
|
|
|
|
height = MAX (0, geometry->min_height - (impl->margin_top + impl->margin_bottom));
|
2016-04-05 16:17:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
width = 0;
|
|
|
|
|
height = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zxdg_toplevel_v6_set_min_size (impl->display_server.xdg_toplevel, width, height);
|
|
|
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MAX_SIZE)
|
|
|
|
|
{
|
2016-09-27 14:48:57 +00:00
|
|
|
|
width = MAX (0, geometry->max_width - (impl->margin_left + impl->margin_right));
|
|
|
|
|
height = MAX (0, geometry->max_height - (impl->margin_top + impl->margin_bottom));
|
2016-04-05 16:17:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
width = 0;
|
|
|
|
|
height = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zxdg_toplevel_v6_set_max_size (impl->display_server.xdg_toplevel, width, height);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_title (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
const gchar *title)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2013-03-16 23:57:17 +00:00
|
|
|
|
GdkWindowImplWayland *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);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
2013-03-16 23:57:17 +00:00
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
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);
|
|
|
|
|
g_warning ("Invalid utf8 passed to gdk_window_set_title: '%s'", title);
|
|
|
|
|
}
|
2013-11-21 17:03:18 +00:00
|
|
|
|
|
|
|
|
|
gdk_wayland_window_sync_title (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_role (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
const gchar *role)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_startup_id (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
const gchar *startup_id)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 15:34:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
check_transient_for_loop (GdkWindow *window,
|
|
|
|
|
GdkWindow *parent)
|
|
|
|
|
{
|
|
|
|
|
while (parent)
|
|
|
|
|
{
|
2016-02-29 09:14:56 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
if (!GDK_IS_WINDOW_IMPL_WAYLAND(parent->impl))
|
|
|
|
|
return FALSE;
|
2015-12-14 15:34:00 +00:00
|
|
|
|
|
2016-02-29 09:14:56 +00:00
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
|
2015-12-14 15:34:00 +00:00
|
|
|
|
if (impl->transient_for == window)
|
|
|
|
|
return TRUE;
|
|
|
|
|
parent = impl->transient_for;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_transient_for (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindow *parent)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2015-09-10 09:42:21 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-04-26 03:46:25 +00:00
|
|
|
|
GdkWaylandDisplay *display_wayland =
|
|
|
|
|
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2015-12-08 15:33:45 +00:00
|
|
|
|
GdkWindow *previous_parent;
|
2015-09-10 09:42:21 +00:00
|
|
|
|
|
2016-04-26 03:46:25 +00:00
|
|
|
|
g_assert (parent == NULL ||
|
|
|
|
|
gdk_window_get_display (window) == gdk_window_get_display (parent));
|
|
|
|
|
|
2015-12-14 15:34:00 +00:00
|
|
|
|
if (check_transient_for_loop (window, parent))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Setting %p transient for %p would create a loop", window, parent);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-13 07:24:19 +00:00
|
|
|
|
unset_transient_for_exported (window);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (impl->display_server.wl_subsurface)
|
2015-09-10 09:42:21 +00:00
|
|
|
|
unmap_subsurface (window);
|
2011-02-11 22:20:14 +00:00
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
previous_parent = impl->transient_for;
|
2011-02-11 22:20:14 +00:00
|
|
|
|
impl->transient_for = parent;
|
2013-11-11 23:02:19 +00:00
|
|
|
|
|
2015-12-08 15:33:45 +00:00
|
|
|
|
if (impl->hint == GDK_WINDOW_TYPE_HINT_DIALOG)
|
|
|
|
|
{
|
|
|
|
|
if (!parent)
|
|
|
|
|
_gdk_wayland_screen_add_orphan_dialog (window);
|
|
|
|
|
else if (!previous_parent)
|
2016-04-26 03:46:25 +00:00
|
|
|
|
display_wayland->orphan_dialogs =
|
|
|
|
|
g_list_remove (display_wayland->orphan_dialogs, window);
|
2015-12-08 15:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
gdk_wayland_window_sync_parent (window, NULL);
|
2015-10-13 12:39:02 +00:00
|
|
|
|
if (should_map_as_subsurface (window) &&
|
2015-09-10 09:42:21 +00:00
|
|
|
|
parent && gdk_window_is_visible (window))
|
|
|
|
|
gdk_wayland_window_create_subsurface (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_get_frame_extents (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkRectangle *rect)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2016-08-04 06:07:47 +00:00
|
|
|
|
*rect = (GdkRectangle) {
|
|
|
|
|
.x = window->x,
|
|
|
|
|
.y = window->y,
|
|
|
|
|
.width = window->width,
|
|
|
|
|
.height = window->height
|
|
|
|
|
};
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_accept_focus (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean accept_focus)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_focus_on_map (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gboolean focus_on_map)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_icon_list (GdkWindow *window,
|
2017-10-23 11:43:50 +00:00
|
|
|
|
GList *surfaces)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_icon_name (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
const gchar *name)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_iconify (GdkWindow *window)
|
|
|
|
|
{
|
2015-02-10 23:06:38 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
2015-02-10 23:06:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_set_minimized (impl->display_server.xdg_toplevel);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_deiconify (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_window_show (window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
else
|
2013-09-16 21:23:29 +00:00
|
|
|
|
/* Flip our client side flag, the real work happens on map. */
|
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_stick (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_unstick (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_maximize (GdkWindow *window)
|
|
|
|
|
{
|
2013-11-11 23:02:19 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2013-03-16 23:34:57 +00:00
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
2010-12-18 20:38:49 +00:00
|
|
|
|
return;
|
2013-03-16 23:34:57 +00:00
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
_gdk_wayland_window_save_size (window);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
zxdg_toplevel_v6_set_maximized (impl->display_server.xdg_toplevel);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
else
|
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_unmaximize (GdkWindow *window)
|
|
|
|
|
{
|
2013-11-11 23:02:19 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2013-03-16 23:34:57 +00:00
|
|
|
|
|
2013-11-11 23:02:19 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
2010-12-18 20:38:49 +00:00
|
|
|
|
return;
|
2013-03-16 23:34:57 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
zxdg_toplevel_v6_unset_maximized (impl->display_server.xdg_toplevel);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
else
|
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_fullscreen_on_monitor (GdkWindow *window, gint monitor)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkScreen *screen = gdk_window_get_screen (window);
|
2016-09-10 18:39:07 +00:00
|
|
|
|
struct wl_output *fullscreen_output =
|
2015-07-13 16:30:42 +00:00
|
|
|
|
_gdk_wayland_screen_get_wl_output (screen, monitor);
|
2016-09-10 18:39:07 +00:00
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
_gdk_wayland_window_save_size (window);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
{
|
|
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
|
|
|
|
fullscreen_output);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
|
|
|
|
impl->initial_fullscreen_monitor = monitor;
|
|
|
|
|
}
|
2015-07-13 16:30:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_fullscreen (GdkWindow *window)
|
|
|
|
|
{
|
2013-01-29 18:40:02 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
2013-01-29 18:40:02 +00:00
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
|
impl->initial_fullscreen_monitor = -1;
|
|
|
|
|
|
2016-02-26 12:35:35 +00:00
|
|
|
|
_gdk_wayland_window_save_size (window);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel, NULL);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
else
|
|
|
|
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_unfullscreen (GdkWindow *window)
|
|
|
|
|
{
|
2013-01-29 18:40:02 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2016-09-10 18:39:07 +00:00
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
2013-01-29 18:40:02 +00:00
|
|
|
|
|
2015-07-13 16:30:42 +00:00
|
|
|
|
impl->initial_fullscreen_monitor = -1;
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
if (impl->display_server.xdg_toplevel)
|
|
|
|
|
zxdg_toplevel_v6_unset_fullscreen (impl->display_server.xdg_toplevel);
|
2015-02-27 23:18:00 +00:00
|
|
|
|
else
|
|
|
|
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-03-17 19:42:43 +00:00
|
|
|
|
gdk_wayland_window_set_keep_above (GdkWindow *window, gboolean setting)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_keep_below (GdkWindow *window, gboolean setting)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkWindow *
|
|
|
|
|
gdk_wayland_window_get_group (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_group (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindow *leader)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_wayland_window_set_decorations (GdkWindow *window,
|
|
|
|
|
GdkWMDecoration decorations)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_wayland_window_get_decorations (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWMDecoration *decorations)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdk_wayland_window_set_functions (GdkWindow *window,
|
|
|
|
|
GdkWMFunction functions)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_begin_resize_drag (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkWindowEdge edge,
|
2011-11-05 05:12:26 +00:00
|
|
|
|
GdkDevice *device,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gint button,
|
|
|
|
|
gint root_x,
|
|
|
|
|
gint root_y,
|
|
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
2014-08-20 18:23:58 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
|
|
|
|
uint32_t resize_edges, serial;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (edge)
|
|
|
|
|
{
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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;
|
|
|
|
|
|
|
|
|
|
case GDK_WINDOW_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:
|
2013-09-16 21:23:29 +00:00
|
|
|
|
g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!", edge);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2017-06-02 13:54:50 +00:00
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
2013-03-20 15:38:36 +00:00
|
|
|
|
return;
|
2013-09-16 21:23:29 +00:00
|
|
|
|
|
2016-02-23 19:32:31 +00:00
|
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_device_get_seat (device),
|
|
|
|
|
&sequence);
|
2014-08-20 18:23:58 +00:00
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_resize (impl->display_server.xdg_toplevel,
|
|
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
|
serial, resize_edges);
|
2014-08-20 18:23:58 +00:00
|
|
|
|
|
|
|
|
|
if (sequence)
|
|
|
|
|
gdk_wayland_device_unset_touch_grab (device, sequence);
|
2012-01-06 16:49:22 +00:00
|
|
|
|
|
2012-01-09 16:00:14 +00:00
|
|
|
|
/* This is needed since Wayland will absorb all the pointer events after the
|
|
|
|
|
* above function - FIXME: Is this always safe..?
|
2012-01-06 16:49:22 +00:00
|
|
|
|
*/
|
2015-12-09 11:55:39 +00:00
|
|
|
|
gdk_seat_ungrab (gdk_device_get_seat (device));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_begin_move_drag (GdkWindow *window,
|
2011-11-05 05:12:26 +00:00
|
|
|
|
GdkDevice *device,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gint button,
|
|
|
|
|
gint root_x,
|
|
|
|
|
gint root_y,
|
|
|
|
|
guint32 timestamp)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
2014-08-20 18:23:58 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
|
|
|
|
uint32_t serial;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window) ||
|
|
|
|
|
!WINDOW_IS_TOPLEVEL (window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2017-06-02 13:54:50 +00:00
|
|
|
|
if (!impl->display_server.xdg_toplevel)
|
2013-03-20 15:38:36 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-02-23 19:32:31 +00:00
|
|
|
|
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_device_get_seat (device),
|
|
|
|
|
&sequence);
|
2016-07-01 09:03:36 +00:00
|
|
|
|
zxdg_toplevel_v6_move (impl->display_server.xdg_toplevel,
|
|
|
|
|
gdk_wayland_device_get_wl_seat (device),
|
|
|
|
|
serial);
|
2014-08-20 18:23:58 +00:00
|
|
|
|
if (sequence)
|
|
|
|
|
gdk_wayland_device_unset_touch_grab (device, sequence);
|
2012-01-09 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
/* This is needed since Wayland will absorb all the pointer events after the
|
|
|
|
|
* above function - FIXME: Is this always safe..?
|
|
|
|
|
*/
|
2015-12-09 11:55:39 +00:00
|
|
|
|
gdk_seat_ungrab (gdk_device_get_seat (device));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_opacity (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
gdouble opacity)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_destroy_notify (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
if (!GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
2013-09-16 21:23:29 +00:00
|
|
|
|
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
|
|
|
|
|
g_warning ("GdkWindow %p unexpectedly destroyed", window);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
_gdk_window_destroy (window, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_wayland_window_get_property (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkAtom property,
|
|
|
|
|
GdkAtom type,
|
|
|
|
|
gulong offset,
|
|
|
|
|
gulong length,
|
|
|
|
|
gint pdelete,
|
|
|
|
|
GdkAtom *actual_property_type,
|
|
|
|
|
gint *actual_format_type,
|
|
|
|
|
gint *actual_length,
|
|
|
|
|
guchar **data)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_change_property (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkAtom property,
|
|
|
|
|
GdkAtom type,
|
|
|
|
|
gint format,
|
|
|
|
|
GdkPropMode mode,
|
|
|
|
|
const guchar *data,
|
|
|
|
|
gint nelements)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
2014-08-21 16:49:44 +00:00
|
|
|
|
if (property == gdk_atom_intern_static_string ("GDK_SELECTION"))
|
|
|
|
|
gdk_wayland_selection_store (window, type, mode, data, nelements * (format / 8));
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_delete_property (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
GdkAtom property)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-04 09:39:36 +00:00
|
|
|
|
static gint
|
|
|
|
|
gdk_wayland_window_get_scale_factor (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return impl->scale;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 20:23:33 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_wayland_window_set_opaque_region (GdkWindow *window,
|
|
|
|
|
cairo_region_t *region)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
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
|
|
|
|
|
gdk_wayland_window_set_shadow_width (GdkWindow *window,
|
|
|
|
|
int left,
|
|
|
|
|
int right,
|
|
|
|
|
int top,
|
|
|
|
|
int bottom)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
2014-11-11 11:07:24 +00:00
|
|
|
|
gint new_width, new_height;
|
2014-02-07 22:20:14 +00:00
|
|
|
|
|
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-11-11 11:07:24 +00:00
|
|
|
|
/* Reconfigure window to keep the same window geometry */
|
|
|
|
|
new_width = window->width -
|
|
|
|
|
(impl->margin_left + impl->margin_right) + (left + right);
|
|
|
|
|
new_height = window->height -
|
|
|
|
|
(impl->margin_top + impl->margin_bottom) + (top + bottom);
|
2016-04-04 12:55:38 +00:00
|
|
|
|
gdk_wayland_window_maybe_configure (window, 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
|
|
|
|
|
gdk_wayland_window_show_window_menu (GdkWindow *window,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
struct wl_seat *seat;
|
2014-08-13 19:05:58 +00:00
|
|
|
|
GdkWaylandDevice *device;
|
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
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.xdg_surface)
|
2014-05-24 03:01:27 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-08-13 19:05:58 +00:00
|
|
|
|
device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
|
|
|
|
|
seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
|
2014-05-24 03:01:27 +00:00
|
|
|
|
gdk_event_get_coords (event, &x, &y);
|
|
|
|
|
|
2016-07-01 09:03:36 +00:00
|
|
|
|
serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
|
|
|
|
|
zxdg_toplevel_v6_show_window_menu (impl->display_server.xdg_toplevel,
|
|
|
|
|
seat, serial, x, y);
|
2014-05-24 03:01:27 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 02:09:10 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_wayland_window_supports_edge_constraints (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
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
|
|
|
|
|
_gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gdk_window_impl_wayland_finalize;
|
|
|
|
|
|
|
|
|
|
impl_class->ref_cairo_surface = gdk_wayland_window_ref_cairo_surface;
|
2013-07-03 14:03:25 +00:00
|
|
|
|
impl_class->create_similar_image_surface = gdk_wayland_window_create_similar_image_surface;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
impl_class->show = gdk_wayland_window_show;
|
|
|
|
|
impl_class->hide = gdk_wayland_window_hide;
|
|
|
|
|
impl_class->withdraw = gdk_window_wayland_withdraw;
|
|
|
|
|
impl_class->set_events = gdk_window_wayland_set_events;
|
|
|
|
|
impl_class->get_events = gdk_window_wayland_get_events;
|
|
|
|
|
impl_class->raise = gdk_window_wayland_raise;
|
|
|
|
|
impl_class->lower = gdk_window_wayland_lower;
|
|
|
|
|
impl_class->restack_toplevel = gdk_window_wayland_restack_toplevel;
|
|
|
|
|
impl_class->move_resize = gdk_window_wayland_move_resize;
|
2016-08-08 07:00:42 +00:00
|
|
|
|
impl_class->move_to_rect = gdk_window_wayland_move_to_rect;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
impl_class->set_device_cursor = gdk_window_wayland_set_device_cursor;
|
|
|
|
|
impl_class->get_geometry = gdk_window_wayland_get_geometry;
|
|
|
|
|
impl_class->get_root_coords = gdk_window_wayland_get_root_coords;
|
|
|
|
|
impl_class->get_device_state = gdk_window_wayland_get_device_state;
|
|
|
|
|
impl_class->shape_combine_region = gdk_window_wayland_shape_combine_region;
|
|
|
|
|
impl_class->input_shape_combine_region = gdk_window_wayland_input_shape_combine_region;
|
|
|
|
|
impl_class->destroy = gdk_wayland_window_destroy;
|
2014-11-22 16:08:34 +00:00
|
|
|
|
impl_class->begin_paint = gdk_window_impl_wayland_begin_paint;
|
2014-06-21 21:29:08 +00:00
|
|
|
|
impl_class->end_paint = gdk_window_impl_wayland_end_paint;
|
2016-03-07 04:41:31 +00:00
|
|
|
|
impl_class->beep = gdk_window_impl_wayland_beep;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
|
|
impl_class->focus = gdk_wayland_window_focus;
|
|
|
|
|
impl_class->set_type_hint = gdk_wayland_window_set_type_hint;
|
|
|
|
|
impl_class->get_type_hint = gdk_wayland_window_get_type_hint;
|
|
|
|
|
impl_class->set_modal_hint = gdk_wayland_window_set_modal_hint;
|
|
|
|
|
impl_class->set_skip_taskbar_hint = gdk_wayland_window_set_skip_taskbar_hint;
|
|
|
|
|
impl_class->set_skip_pager_hint = gdk_wayland_window_set_skip_pager_hint;
|
|
|
|
|
impl_class->set_urgency_hint = gdk_wayland_window_set_urgency_hint;
|
|
|
|
|
impl_class->set_geometry_hints = gdk_wayland_window_set_geometry_hints;
|
|
|
|
|
impl_class->set_title = gdk_wayland_window_set_title;
|
|
|
|
|
impl_class->set_role = gdk_wayland_window_set_role;
|
|
|
|
|
impl_class->set_startup_id = gdk_wayland_window_set_startup_id;
|
|
|
|
|
impl_class->set_transient_for = gdk_wayland_window_set_transient_for;
|
|
|
|
|
impl_class->get_frame_extents = gdk_wayland_window_get_frame_extents;
|
|
|
|
|
impl_class->set_accept_focus = gdk_wayland_window_set_accept_focus;
|
|
|
|
|
impl_class->set_focus_on_map = gdk_wayland_window_set_focus_on_map;
|
|
|
|
|
impl_class->set_icon_list = gdk_wayland_window_set_icon_list;
|
|
|
|
|
impl_class->set_icon_name = gdk_wayland_window_set_icon_name;
|
|
|
|
|
impl_class->iconify = gdk_wayland_window_iconify;
|
|
|
|
|
impl_class->deiconify = gdk_wayland_window_deiconify;
|
|
|
|
|
impl_class->stick = gdk_wayland_window_stick;
|
|
|
|
|
impl_class->unstick = gdk_wayland_window_unstick;
|
|
|
|
|
impl_class->maximize = gdk_wayland_window_maximize;
|
|
|
|
|
impl_class->unmaximize = gdk_wayland_window_unmaximize;
|
|
|
|
|
impl_class->fullscreen = gdk_wayland_window_fullscreen;
|
2015-07-13 16:30:42 +00:00
|
|
|
|
impl_class->fullscreen_on_monitor = gdk_wayland_window_fullscreen_on_monitor;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
impl_class->unfullscreen = gdk_wayland_window_unfullscreen;
|
|
|
|
|
impl_class->set_keep_above = gdk_wayland_window_set_keep_above;
|
|
|
|
|
impl_class->set_keep_below = gdk_wayland_window_set_keep_below;
|
|
|
|
|
impl_class->get_group = gdk_wayland_window_get_group;
|
|
|
|
|
impl_class->set_group = gdk_wayland_window_set_group;
|
|
|
|
|
impl_class->set_decorations = gdk_wayland_window_set_decorations;
|
|
|
|
|
impl_class->get_decorations = gdk_wayland_window_get_decorations;
|
|
|
|
|
impl_class->set_functions = gdk_wayland_window_set_functions;
|
|
|
|
|
impl_class->begin_resize_drag = gdk_wayland_window_begin_resize_drag;
|
|
|
|
|
impl_class->begin_move_drag = gdk_wayland_window_begin_move_drag;
|
|
|
|
|
impl_class->set_opacity = gdk_wayland_window_set_opacity;
|
|
|
|
|
impl_class->destroy_notify = gdk_wayland_window_destroy_notify;
|
2011-02-08 13:12:59 +00:00
|
|
|
|
impl_class->get_drag_protocol = _gdk_wayland_window_get_drag_protocol;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
impl_class->register_dnd = _gdk_wayland_window_register_dnd;
|
|
|
|
|
impl_class->drag_begin = _gdk_wayland_window_drag_begin;
|
|
|
|
|
impl_class->get_property = gdk_wayland_window_get_property;
|
|
|
|
|
impl_class->change_property = gdk_wayland_window_change_property;
|
|
|
|
|
impl_class->delete_property = gdk_wayland_window_delete_property;
|
2013-06-04 09:39:36 +00:00
|
|
|
|
impl_class->get_scale_factor = gdk_wayland_window_get_scale_factor;
|
2013-05-14 20:23:33 +00:00
|
|
|
|
impl_class->set_opaque_region = gdk_wayland_window_set_opaque_region;
|
2014-02-07 22:20:14 +00:00
|
|
|
|
impl_class->set_shadow_width = gdk_wayland_window_set_shadow_width;
|
2014-05-24 03:01:27 +00:00
|
|
|
|
impl_class->show_window_menu = gdk_wayland_window_show_window_menu;
|
2014-10-09 09:06:48 +00:00
|
|
|
|
impl_class->create_gl_context = gdk_wayland_window_create_gl_context;
|
2017-09-18 02:09:10 +00:00
|
|
|
|
impl_class->supports_edge_constraints = gdk_wayland_window_supports_edge_constraints;
|
2015-09-10 09:42:21 +00:00
|
|
|
|
|
|
|
|
|
signals[COMMITTED] = g_signal_new ("committed",
|
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
}
|
2012-02-27 14:06:22 +00:00
|
|
|
|
|
|
|
|
|
void
|
2015-12-09 11:56:26 +00:00
|
|
|
|
_gdk_wayland_window_set_grab_seat (GdkWindow *window,
|
|
|
|
|
GdkSeat *seat)
|
2012-02-27 14:06:22 +00:00
|
|
|
|
{
|
2012-03-05 19:41:11 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
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
|
|
|
|
|
2016-11-06 20:36:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_wayland_window_new_subsurface: (constructor)
|
|
|
|
|
* @display: the display to create the window on
|
|
|
|
|
* @event_mask: event mask (see gdk_window_set_events())
|
|
|
|
|
* @position: position relative to the transient window
|
|
|
|
|
*
|
|
|
|
|
* Creates a new subsurface window.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new #GdkWindow
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.90
|
|
|
|
|
**/
|
|
|
|
|
GdkWindow *
|
|
|
|
|
gdk_wayland_window_new_subsurface (GdkDisplay *display,
|
|
|
|
|
int event_mask,
|
|
|
|
|
const GdkRectangle *position)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowAttr attr;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
|
|
|
|
g_return_val_if_fail (position != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
attr.event_mask = event_mask;
|
|
|
|
|
attr.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
|
attr.x = position->x;
|
|
|
|
|
attr.y = position->y;
|
|
|
|
|
attr.width = position->width;
|
|
|
|
|
attr.height = position->height;
|
|
|
|
|
attr.window_type = GDK_WINDOW_SUBSURFACE;
|
|
|
|
|
|
2017-08-12 13:36:49 +00:00
|
|
|
|
return gdk_window_new (display,
|
|
|
|
|
gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
|
2016-11-07 00:33:43 +00:00
|
|
|
|
&attr);
|
2016-11-06 20:36:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 21:20:05 +00:00
|
|
|
|
/**
|
2015-02-28 03:28:28 +00:00
|
|
|
|
* gdk_wayland_window_get_wl_surface:
|
2013-01-23 21:20:05 +00:00
|
|
|
|
* @window: (type GdkWaylandWindow): a #GdkWindow
|
|
|
|
|
*
|
2015-02-28 03:28:28 +00:00
|
|
|
|
* Returns the Wayland surface of a #GdkWindow.
|
2013-01-23 21:20:05 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): a Wayland wl_surface
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.8
|
|
|
|
|
*/
|
|
|
|
|
struct wl_surface *
|
|
|
|
|
gdk_wayland_window_get_wl_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
return GDK_WINDOW_IMPL_WAYLAND (window->impl)->display_server.wl_surface;
|
2013-01-23 21:20:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 13:02:01 +00:00
|
|
|
|
struct wl_output *
|
|
|
|
|
gdk_wayland_window_get_wl_output (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
/* 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 *
|
|
|
|
|
gdk_wayland_window_get_wl_egl_window (GdkWindow *window)
|
|
|
|
|
{
|
2015-02-28 03:28:28 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
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,
|
2015-02-28 03:28:28 +00:00
|
|
|
|
impl->wrapper->width * impl->scale,
|
|
|
|
|
impl->wrapper->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
|
|
|
|
|
gdk_wayland_window_get_egl_surface (GdkWindow *window,
|
2015-02-28 03:28:28 +00:00
|
|
|
|
EGLConfig config)
|
2014-10-09 09:06:48 +00:00
|
|
|
|
{
|
2015-02-28 03:28:28 +00:00
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2014-10-09 09:06:48 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
struct wl_egl_window *egl_window;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
if (impl->egl_surface == NULL)
|
|
|
|
|
{
|
|
|
|
|
egl_window = gdk_wayland_window_get_wl_egl_window (window);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
gdk_wayland_window_get_dummy_egl_surface (GdkWindow *window,
|
2015-02-28 03:28:28 +00:00
|
|
|
|
EGLConfig config)
|
2014-10-09 14:09:05 +00:00
|
|
|
|
{
|
2015-02-28 03:28:28 +00:00
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
2014-10-09 14:09:05 +00:00
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
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 *
|
|
|
|
|
gdk_wayland_window_get_gtk_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
|
|
|
|
|
|
|
|
return GDK_WINDOW_IMPL_WAYLAND (window->impl)->display_server.gtk_surface;
|
|
|
|
|
}
|
2014-10-09 14:09:05 +00:00
|
|
|
|
|
2013-03-20 15:38:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_wayland_window_set_use_custom_surface:
|
|
|
|
|
* @window: (type GdkWaylandWindow): a #GdkWindow
|
|
|
|
|
*
|
|
|
|
|
* Marks a #GdkWindow as a custom Wayland surface. The application is
|
|
|
|
|
* expected to register the surface as some type of surface using
|
|
|
|
|
* some Wayland interface.
|
|
|
|
|
*
|
2013-09-16 21:23:29 +00:00
|
|
|
|
* A good example would be writing a panel or on-screen-keyboard as an
|
2013-03-20 15:38:36 +00:00
|
|
|
|
* out-of-process helper - as opposed to having those in the compositor
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* process. In this case the underlying surface isn’t an xdg_shell
|
2013-03-20 15:38:36 +00:00
|
|
|
|
* surface and the panel or OSK client need to identify the wl_surface
|
|
|
|
|
* as a panel or OSK to the compositor. The assumption is that the
|
|
|
|
|
* compositor will expose a private interface to the special client
|
|
|
|
|
* that lets the client identify the wl_surface as a panel or such.
|
|
|
|
|
*
|
|
|
|
|
* This function should be called before a #GdkWindow is shown. This is
|
2014-01-21 23:46:05 +00:00
|
|
|
|
* best done by connecting to the #GtkWidget::realize signal:
|
2013-03-20 15:38:36 +00:00
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2013-03-20 15:38:36 +00:00
|
|
|
|
* static void
|
|
|
|
|
* widget_realize_cb (GtkWidget *widget)
|
|
|
|
|
* {
|
|
|
|
|
* GdkWindow *window;
|
|
|
|
|
* struct wl_surface *surface;
|
|
|
|
|
* struct input_panel_surface *ip_surface;
|
|
|
|
|
*
|
|
|
|
|
* window = gtk_widget_get_window (widget);
|
|
|
|
|
* gdk_wayland_window_set_custom_surface (window);
|
|
|
|
|
*
|
|
|
|
|
* surface = gdk_wayland_window_get_wl_surface (window);
|
|
|
|
|
* ip_surface = input_panel_get_input_panel_surface (input_panel, surface);
|
|
|
|
|
* input_panel_surface_set_panel (ip_surface);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* static void
|
|
|
|
|
* setup_window (GtkWindow *window)
|
|
|
|
|
* {
|
|
|
|
|
* g_signal_connect (window, "realize", G_CALLBACK (widget_realize_cb), NULL);
|
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2013-03-20 15:38:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.10
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_wayland_window_set_use_custom_surface (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
2016-02-02 16:42:52 +00:00
|
|
|
|
if (!impl->display_server.wl_surface)
|
2013-04-25 15:11:02 +00:00
|
|
|
|
gdk_wayland_window_create_surface (window);
|
2013-03-20 15:38:36 +00:00
|
|
|
|
|
|
|
|
|
impl->use_custom_surface = TRUE;
|
|
|
|
|
}
|
2013-08-30 11:56:45 +00:00
|
|
|
|
|
2015-03-23 05:08:09 +00:00
|
|
|
|
static void
|
2015-03-06 03:40:12 +00:00
|
|
|
|
maybe_set_gtk_surface_dbus_properties (GdkWindow *window)
|
2015-03-23 05:08:09 +00:00
|
|
|
|
{
|
2015-03-06 03:40:12 +00:00
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
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;
|
|
|
|
|
|
2015-03-06 03:40:12 +00:00
|
|
|
|
gdk_wayland_window_init_gtk_surface (window);
|
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
|
|
|
|
|
gdk_wayland_window_set_dbus_properties_libgtk_only (GdkWindow *window,
|
2013-09-16 21:23:29 +00:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
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
|
|
|
|
|
2015-03-06 03:40:12 +00:00
|
|
|
|
maybe_set_gtk_surface_dbus_properties (window);
|
2013-08-30 11:56:45 +00:00
|
|
|
|
}
|
2015-12-08 10:19:33 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_wayland_window_offset_next_wl_buffer (GdkWindow *window,
|
|
|
|
|
int x,
|
|
|
|
|
int y)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = data;
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
impl->exported.callback (window, handle, impl->exported.user_data);
|
2017-05-05 11:07:04 +00:00
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
* GdkWaylandWindowExported:
|
|
|
|
|
* @window: the #GdkWindow that is exported
|
|
|
|
|
* @handle: the handle
|
|
|
|
|
* @user_data: user data that was passed to gdk_wayland_window_export_handle()
|
|
|
|
|
*
|
|
|
|
|
* Callback that gets called when the handle for a window has been
|
|
|
|
|
* obtained from the Wayland compositor. The handle can be passed
|
|
|
|
|
* to other processes, for the purpose of marking windows as transient
|
|
|
|
|
* for out-of-process surfaces.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.22
|
|
|
|
|
*/
|
|
|
|
|
|
2017-05-08 04:09:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_wayland_window_is_exported (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
return !!impl->display_server.xdg_exported;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 03:49:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_wayland_window_export_handle:
|
2016-08-29 17:12:56 +00:00
|
|
|
|
* @window: the #GdkWindow to obtain a handle for
|
|
|
|
|
* @callback: callback to call with the handle
|
|
|
|
|
* @user_data: user data for @callback
|
|
|
|
|
* @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.
|
|
|
|
|
*
|
|
|
|
|
* It is an error to call this function on a window that is already
|
|
|
|
|
* exported.
|
|
|
|
|
*
|
|
|
|
|
* When the handle is no longer needed, gdk_wayland_window_unexport_handle()
|
|
|
|
|
* should be called to clean up resources.
|
|
|
|
|
*
|
|
|
|
|
* The main purpose for obtaining a handle is to mark a surface
|
|
|
|
|
* from another window as transient for this one, see
|
|
|
|
|
* gdk_wayland_window_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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.22
|
2016-07-12 03:49:39 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2016-08-29 17:12:56 +00:00
|
|
|
|
gdk_wayland_window_export_handle (GdkWindow *window,
|
|
|
|
|
GdkWaylandWindowExported callback,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GDestroyNotify destroy_func)
|
2016-07-12 03:49:39 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
|
struct zxdg_exported_v1 *xdg_exported;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), FALSE);
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), FALSE);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
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);
|
|
|
|
|
zxdg_exported_v1_add_listener (xdg_exported, &xdg_exported_listener, window);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_wayland_window_unexport_handle:
|
2016-08-29 17:12:56 +00:00
|
|
|
|
* @window: the #GdkWindow to unexport
|
|
|
|
|
*
|
|
|
|
|
* Destroys the handle that was obtained with
|
|
|
|
|
* gdk_wayland_window_export_handle().
|
|
|
|
|
*
|
|
|
|
|
* It is an error to call this function on a window that
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.22
|
2016-07-12 03:49:39 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_wayland_window_unexport_handle (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (impl->display_server.xdg_exported);
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->display_server.xdg_exported,
|
|
|
|
|
zxdg_exported_v1_destroy);
|
|
|
|
|
g_clear_pointer (&impl->exported.user_data,
|
|
|
|
|
impl->exported.destroy_func);
|
|
|
|
|
}
|
2016-07-13 07:24:19 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
unset_transient_for_exported (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
GdkWindow *window = data;
|
|
|
|
|
|
|
|
|
|
unset_transient_for_exported (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_imported_v1_listener xdg_imported_listener = {
|
|
|
|
|
xdg_imported_destroyed,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_wayland_window_set_transient_for_exported:
|
2016-08-29 17:12:56 +00:00
|
|
|
|
* @window: the #GdkWindow to make as transient
|
|
|
|
|
* @parent_handle_str: an exported handle for a surface
|
|
|
|
|
*
|
|
|
|
|
* Marks @window as transient for the surface to which the given
|
|
|
|
|
* @parent_handle_str refers. Typically, the handle will originate
|
|
|
|
|
* from a gdk_wayland_window_export_handle() call in another process.
|
|
|
|
|
*
|
|
|
|
|
* Note that this API depends on an unstable Wayland protocol,
|
|
|
|
|
* and thus may require changes in the future.
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the window has been marked as transient,
|
|
|
|
|
* %FALSE if an error occurred.
|
2016-07-13 07:24:19 +00:00
|
|
|
|
*
|
2016-08-29 17:12:56 +00:00
|
|
|
|
* Since: 3.22
|
2016-07-13 07:24:19 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_wayland_window_set_transient_for_exported (GdkWindow *window,
|
|
|
|
|
char *parent_handle_str)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl;
|
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), FALSE);
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), FALSE);
|
|
|
|
|
|
|
|
|
|
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (impl->display_server.xdg_surface, FALSE);
|
|
|
|
|
|
|
|
|
|
if (!display_wayland->xdg_importer)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Server is missing xdg_foreign support");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdk_window_set_transient_for (window, NULL);
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
window);
|
|
|
|
|
|
|
|
|
|
zxdg_imported_v1_set_parent_of (impl->imported_transient_for,
|
|
|
|
|
impl->display_server.wl_surface);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2017-03-22 09:21:02 +00:00
|
|
|
|
|
|
|
|
|
static struct zwp_keyboard_shortcuts_inhibitor_v1 *
|
|
|
|
|
gdk_wayland_window_get_inhibitor (GdkWindowImplWayland *impl,
|
|
|
|
|
struct wl_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
return g_hash_table_lookup (impl->shortcuts_inhibitors, seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_wayland_window_inhibit_shortcuts (GdkWindow *window,
|
|
|
|
|
GdkSeat *gdk_seat)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl= GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
|
|
|
struct wl_surface *surface = impl->display_server.wl_surface;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
if (gdk_wayland_window_get_inhibitor (impl, seat))
|
|
|
|
|
return; /* Already inhibitted */
|
|
|
|
|
|
|
|
|
|
inhibitor =
|
|
|
|
|
zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts (
|
|
|
|
|
display->keyboard_shortcuts_inhibit, surface, seat);
|
|
|
|
|
|
|
|
|
|
g_hash_table_insert (impl->shortcuts_inhibitors, seat, inhibitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_wayland_window_restore_shortcuts (GdkWindow *window,
|
|
|
|
|
GdkSeat *gdk_seat)
|
|
|
|
|
{
|
|
|
|
|
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
|
|
|
struct wl_seat *seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
|
|
|
|
|
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
|
|
|
|
|
|
|
|
|
|
inhibitor = gdk_wayland_window_get_inhibitor (impl, seat);
|
|
|
|
|
if (inhibitor == NULL)
|
|
|
|
|
return; /* Not inhibitted */
|
|
|
|
|
|
|
|
|
|
zwp_keyboard_shortcuts_inhibitor_v1_destroy (inhibitor);
|
|
|
|
|
g_hash_table_remove (impl->shortcuts_inhibitors, seat);
|
|
|
|
|
}
|
|
|
|
|
|