2010-11-12 12:18:58 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball,
|
|
|
|
* Josh MacDonald, Ryan Lortie
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-12 12:18:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdksurface-broadway.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2014-10-25 14:31:31 +00:00
|
|
|
#include "gdkbroadwaydisplay.h"
|
|
|
|
#include "gdkdisplay.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdksurface.h"
|
|
|
|
#include "gdksurfaceimpl.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
#include "gdkdisplay-broadway.h"
|
|
|
|
#include "gdkprivate-broadway.h"
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
#include "gdkdeviceprivate.h"
|
|
|
|
#include "gdkeventsource.h"
|
2017-11-18 19:36:57 +00:00
|
|
|
#include <gdk/gdktextureprivate.h>
|
2017-11-23 09:22:23 +00:00
|
|
|
#include <gdk/gdkframeclockprivate.h>
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* Forward declarations */
|
2018-03-20 10:40:08 +00:00
|
|
|
static void gdk_surface_impl_broadway_finalize (GObject *object);
|
2010-12-04 21:28:31 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
#define SURFACE_IS_TOPLEVEL(surface) \
|
|
|
|
(GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD)
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
struct _GdkBroadwaySurface {
|
|
|
|
GdkSurface parent;
|
2011-01-06 22:36:44 +00:00
|
|
|
};
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
struct _GdkBroadwaySurfaceClass {
|
|
|
|
GdkSurfaceClass parent_class;
|
2011-01-06 22:36:44 +00:00
|
|
|
};
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
G_DEFINE_TYPE (GdkBroadwaySurface, gdk_broadway_surface, GDK_TYPE_SURFACE)
|
2011-01-06 22:36:44 +00:00
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *broadway_surface_class)
|
2011-01-06 22:36:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_broadway_surface_init (GdkBroadwaySurface *broadway_surface)
|
2011-01-06 22:36:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
G_DEFINE_TYPE (GdkSurfaceImplBroadway,
|
|
|
|
gdk_surface_impl_broadway,
|
|
|
|
GDK_TYPE_SURFACE_IMPL)
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2014-10-25 14:31:31 +00:00
|
|
|
static GdkDisplay *
|
|
|
|
find_broadway_display (void)
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
GSList *list, *l;
|
|
|
|
|
|
|
|
display = NULL;
|
|
|
|
|
|
|
|
list = gdk_display_manager_list_displays (gdk_display_manager_get ());
|
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
{
|
|
|
|
if (GDK_IS_BROADWAY_DISPLAY (l->data))
|
|
|
|
{
|
|
|
|
display = l->data;
|
2018-03-21 08:17:50 +00:00
|
|
|
break;
|
2014-10-25 14:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_slist_free (list);
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:22:42 +00:00
|
|
|
static guint flush_id = 0;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
flush_idle (gpointer data)
|
|
|
|
{
|
|
|
|
flush_id = 0;
|
|
|
|
|
2014-10-25 14:31:31 +00:00
|
|
|
gdk_display_flush (find_broadway_display ());
|
2010-11-16 21:11:53 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:22:42 +00:00
|
|
|
/* We need to flush in an idle rather than AFTER_PAINT, as the clock
|
2018-03-21 08:17:50 +00:00
|
|
|
is frozen during e.g. surface resizes so the paint will not happen
|
|
|
|
and the surface resize request is never flushed. */
|
2010-11-16 21:11:53 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
queue_flush (GdkSurface *surface)
|
2010-11-16 21:11:53 +00:00
|
|
|
{
|
2013-03-28 18:22:42 +00:00
|
|
|
if (flush_id == 0)
|
2014-03-22 11:44:01 +00:00
|
|
|
{
|
2018-02-02 14:08:02 +00:00
|
|
|
flush_id = g_idle_add (flush_idle, NULL);
|
2019-02-06 09:37:24 +00:00
|
|
|
g_source_set_name_by_id (flush_id, "[gtk] flush_idle");
|
2014-03-22 11:44:01 +00:00
|
|
|
}
|
2010-11-16 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_impl_broadway_init (GdkSurfaceImplBroadway *impl)
|
2010-11-16 21:11:53 +00:00
|
|
|
{
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_impl_broadway_finalize (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *wrapper;
|
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE_IMPL_BROADWAY (object));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2010-12-04 21:28:31 +00:00
|
|
|
wrapper = impl->wrapper;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_broadway_surface_grab_check_destroy (wrapper);
|
2011-04-15 14:17:27 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (impl->wrapper));
|
2010-11-25 19:07:26 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
g_hash_table_remove (broadway_display->id_ht, GINT_TO_POINTER(impl->id));
|
2010-11-20 21:38:34 +00:00
|
|
|
|
2010-12-04 21:28:31 +00:00
|
|
|
if (impl->cursor)
|
2011-10-15 12:35:28 +00:00
|
|
|
g_object_unref (impl->cursor);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
broadway_display->toplevels = g_list_remove (broadway_display->toplevels, impl);
|
2010-11-15 20:44:38 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
G_OBJECT_CLASS (gdk_surface_impl_broadway_parent_class)->finalize (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 09:22:23 +00:00
|
|
|
static gboolean
|
|
|
|
thaw_clock_cb (GdkFrameClock *clock)
|
|
|
|
{
|
|
|
|
_gdk_frame_clock_thaw (clock);
|
|
|
|
g_object_unref (clock);
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_broadway_roundtrip_notify (GdkSurface *surface,
|
2017-11-23 09:22:23 +00:00
|
|
|
guint32 tag,
|
|
|
|
gboolean local_reply)
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
2017-11-23 09:22:23 +00:00
|
|
|
|
|
|
|
/* If there is no remove web client, rate limit update to once a second */
|
|
|
|
if (local_reply)
|
|
|
|
g_timeout_add_seconds (1, (GSourceFunc)thaw_clock_cb, g_object_ref (clock));
|
|
|
|
else
|
|
|
|
_gdk_frame_clock_thaw (clock);
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:22:42 +00:00
|
|
|
static void
|
|
|
|
on_frame_clock_after_paint (GdkFrameClock *clock,
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurface *surface)
|
2013-03-28 18:22:42 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkSurfaceImplBroadway *impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2017-11-23 09:22:23 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_frame_clock_freeze (gdk_surface_get_frame_clock (surface));
|
2017-11-23 09:22:23 +00:00
|
|
|
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
|
|
|
_gdk_broadway_server_roundtrip (broadway_display->server, impl->id, _gdk_display_get_next_serial (display));
|
|
|
|
|
|
|
|
gdk_display_flush (display);
|
2013-03-28 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
connect_frame_clock (GdkSurface *surface)
|
2013-03-28 18:22:42 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (SURFACE_IS_TOPLEVEL (surface))
|
2013-03-28 18:22:42 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
2013-03-28 18:22:42 +00:00
|
|
|
|
|
|
|
g_signal_connect (frame_clock, "after-paint",
|
2018-03-21 08:17:50 +00:00
|
|
|
G_CALLBACK (on_frame_clock_after_paint), surface);
|
2013-03-28 18:22:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
void
|
2018-03-20 11:05:26 +00:00
|
|
|
_gdk_broadway_display_create_surface_impl (GdkDisplay *display,
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurface *surface,
|
|
|
|
GdkSurface *real_parent,
|
|
|
|
GdkSurfaceAttr *attributes)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
impl = g_object_new (GDK_TYPE_SURFACE_IMPL_BROADWAY, NULL);
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->impl = (GdkSurfaceImpl *)impl;
|
2017-12-05 13:38:57 +00:00
|
|
|
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->x,
|
|
|
|
surface->y,
|
|
|
|
surface->width,
|
|
|
|
surface->height,
|
|
|
|
surface->surface_type == GDK_SURFACE_TEMP);
|
|
|
|
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
|
|
|
impl->wrapper = surface;
|
|
|
|
|
|
|
|
g_assert (surface->surface_type == GDK_SURFACE_TOPLEVEL ||
|
|
|
|
surface->surface_type == GDK_SURFACE_TEMP);
|
|
|
|
g_assert (surface->parent == NULL);
|
2010-11-16 21:11:53 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
|
2013-03-28 18:22:42 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
connect_frame_clock (surface);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-12-04 21:28:31 +00:00
|
|
|
static cairo_surface_t *
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_ref_cairo_surface (GdkSurface *surface)
|
2010-12-04 21:28:31 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurfaceImplBroadway *impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2010-12-04 21:28:31 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_IS_SURFACE_IMPL_BROADWAY (surface) &&
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_DESTROYED (impl->wrapper))
|
2010-12-04 21:28:31 +00:00
|
|
|
return NULL;
|
|
|
|
|
2017-12-04 14:04:48 +00:00
|
|
|
return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
|
2010-12-04 21:28:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_broadway_surface_destroy (GdkSurface *surface,
|
|
|
|
gboolean recursing,
|
|
|
|
gboolean foreign_destroy)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2010-11-16 21:11:53 +00:00
|
|
|
|
2017-11-21 18:33:12 +00:00
|
|
|
if (impl->node_data)
|
|
|
|
g_array_unref (impl->node_data);
|
|
|
|
if (impl->node_data_textures)
|
|
|
|
g_ptr_array_unref (impl->node_data_textures);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_broadway_surface_grab_check_destroy (surface);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2017-11-07 02:11:16 +00:00
|
|
|
g_hash_table_remove (broadway_display->id_ht, GINT_TO_POINTER (impl->id));
|
2011-04-15 14:18:11 +00:00
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
_gdk_broadway_server_destroy_surface (broadway_display->server, impl->id);
|
2017-11-18 19:36:57 +00:00
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 18:33:12 +00:00
|
|
|
void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_nodes (GdkSurface *surface,
|
|
|
|
GArray *nodes,
|
|
|
|
GPtrArray *node_textures)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2017-11-21 18:33:12 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2017-11-21 18:33:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2017-11-21 18:33:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2017-11-21 18:33:12 +00:00
|
|
|
|
|
|
|
if (nodes)
|
|
|
|
g_array_ref (nodes);
|
|
|
|
if (impl->node_data)
|
|
|
|
g_array_unref (impl->node_data);
|
|
|
|
impl->node_data = nodes;
|
|
|
|
|
|
|
|
if (node_textures)
|
|
|
|
g_ptr_array_ref (node_textures);
|
|
|
|
if (impl->node_data_textures)
|
|
|
|
g_ptr_array_unref (impl->node_data_textures);
|
|
|
|
impl->node_data_textures = node_textures;
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
gdk_broadway_server_surface_set_nodes (broadway_display->server, impl->id, impl->node_data);
|
2017-11-21 18:33:12 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
/* This function is called when the XSurface is really gone.
|
2010-11-12 12:18:58 +00:00
|
|
|
*/
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_destroy_notify (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
|
|
|
_gdk_surface_destroy (surface, TRUE);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_object_unref (surface);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_show (GdkSurface *surface,
|
|
|
|
gboolean already_mapped)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 21:12:04 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-04-11 09:56:22 +00:00
|
|
|
impl->visible = TRUE;
|
2010-11-15 21:12:04 +00:00
|
|
|
|
2018-07-15 18:23:54 +00:00
|
|
|
/* FIXME: update state ? */
|
2010-11-15 21:12:04 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2017-12-05 13:38:57 +00:00
|
|
|
if (_gdk_broadway_server_surface_show (broadway_display->server, impl->id))
|
2018-03-21 08:17:50 +00:00
|
|
|
queue_flush (surface);
|
2012-12-19 11:37:02 +00:00
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_hide (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-04-11 09:56:22 +00:00
|
|
|
impl->visible = FALSE;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-07-15 18:23:54 +00:00
|
|
|
/* FIXME: update state ? */
|
2010-11-15 21:12:04 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2013-04-05 15:06:09 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_broadway_surface_grab_check_unmap (surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
_gdk_broadway_server_get_next_serial (broadway_display->server));
|
2013-04-05 15:06:09 +00:00
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
if (_gdk_broadway_server_surface_hide (broadway_display->server, impl->id))
|
2018-03-21 08:17:50 +00:00
|
|
|
queue_flush (surface);
|
2010-11-25 19:07:26 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_surface_clear_update_area (surface);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_withdraw (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_hide (surface);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-11-21 19:46:50 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_move_resize (GdkSurface *surface,
|
|
|
|
gboolean with_move,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
GdkSurfaceImplBroadway *impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2013-01-08 16:33:29 +00:00
|
|
|
gboolean size_changed;
|
2010-11-23 11:52:10 +00:00
|
|
|
|
2013-01-08 16:33:29 +00:00
|
|
|
size_changed = FALSE;
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2010-11-21 19:46:50 +00:00
|
|
|
if (width > 0 || height > 0)
|
|
|
|
{
|
|
|
|
if (width < 1)
|
2017-11-21 18:33:12 +00:00
|
|
|
width = 1;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2010-11-21 19:46:50 +00:00
|
|
|
if (height < 1)
|
2017-11-21 18:33:12 +00:00
|
|
|
height = 1;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (width != surface->width ||
|
|
|
|
height != surface->height)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
|
|
|
size_changed = TRUE;
|
|
|
|
|
|
|
|
/* Resize clears the content */
|
|
|
|
impl->dirty = TRUE;
|
|
|
|
impl->last_synced = FALSE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
2017-11-21 18:33:12 +00:00
|
|
|
}
|
2010-11-23 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
_gdk_broadway_server_surface_move_resize (broadway_display->server,
|
|
|
|
impl->id,
|
|
|
|
with_move,
|
|
|
|
x, y,
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->width, surface->height);
|
|
|
|
queue_flush (surface);
|
2013-01-08 16:33:29 +00:00
|
|
|
if (size_changed)
|
2018-04-24 12:31:24 +00:00
|
|
|
{
|
|
|
|
surface->resize_count++;
|
|
|
|
_gdk_surface_update_size (surface);
|
|
|
|
}
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_raise (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_restack_toplevel (GdkSurface *surface,
|
|
|
|
GdkSurface *sibling,
|
|
|
|
gboolean above)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_lower (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_focus (GdkSurface *surface,
|
|
|
|
guint32 timestamp)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2013-11-12 11:03:50 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2013-11-12 11:03:50 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!surface->accept_focus)
|
2013-11-12 11:03:50 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
2017-12-05 13:38:57 +00:00
|
|
|
_gdk_broadway_server_surface_focus (broadway_display->server,
|
|
|
|
impl->id);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_type_hint (GdkSurface *surface,
|
|
|
|
GdkSurfaceTypeHint hint)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurfaceTypeHint
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_get_type_hint (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
return GDK_SURFACE_TYPE_HINT_NORMAL;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_modal_hint (GdkSurface *surface,
|
|
|
|
gboolean modal)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_skip_taskbar_hint (GdkSurface *surface,
|
|
|
|
gboolean skips_taskbar)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_skip_pager_hint (GdkSurface *surface,
|
|
|
|
gboolean skips_pager)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_urgency_hint (GdkSurface *surface,
|
|
|
|
gboolean urgent)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_geometry_hints (GdkSurface *surface,
|
|
|
|
const GdkGeometry *geometry,
|
|
|
|
GdkSurfaceHints geom_mask)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2013-03-28 19:03:13 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2013-03-28 19:03:13 +00:00
|
|
|
|
|
|
|
impl->geometry_hints = *geometry;
|
|
|
|
impl->geometry_hints_mask = geom_mask;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_title (GdkSurface *surface,
|
|
|
|
const gchar *title)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2010-11-15 19:08:18 +00:00
|
|
|
}
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_startup_id (GdkSurface *surface,
|
|
|
|
const gchar *startup_id)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_transient_for (GdkSurface *surface,
|
|
|
|
GdkSurface *parent)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-04-05 10:02:46 +00:00
|
|
|
GdkBroadwayDisplay *display;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-04-05 10:02:46 +00:00
|
|
|
int parent_id;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-04-05 10:02:46 +00:00
|
|
|
|
|
|
|
parent_id = 0;
|
|
|
|
if (parent)
|
2018-03-20 10:40:08 +00:00
|
|
|
parent_id = GDK_SURFACE_IMPL_BROADWAY (parent->impl)->id;
|
2011-04-05 10:02:46 +00:00
|
|
|
|
|
|
|
impl->transient_for = parent_id;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (impl->wrapper));
|
2017-12-05 13:38:57 +00:00
|
|
|
_gdk_broadway_server_surface_set_transient_for (display->server, impl->id, impl->transient_for);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_get_geometry (GdkSurface *surface,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-03-14 10:22:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2011-03-14 10:22:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-03-14 10:22:12 +00:00
|
|
|
|
|
|
|
/* TODO: These should really roundtrip to the client to get the current data */
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
*x = impl->wrapper->x;
|
|
|
|
if (y)
|
|
|
|
*y = impl->wrapper->y;
|
|
|
|
if (width)
|
|
|
|
*width = impl->wrapper->width;
|
|
|
|
if (height)
|
|
|
|
*height = impl->wrapper->height;
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_get_root_coords (GdkSurface *surface,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint *root_x,
|
|
|
|
gint *root_y)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2011-03-14 10:22:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-03-14 10:22:12 +00:00
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
if (root_x)
|
2011-03-14 10:22:12 +00:00
|
|
|
*root_x = x + impl->wrapper->x;
|
2010-11-12 12:18:58 +00:00
|
|
|
if (root_y)
|
2011-03-14 10:22:12 +00:00
|
|
|
*root_y = y + impl->wrapper->y;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_get_frame_extents (GdkSurface *surface,
|
|
|
|
GdkRectangle *rect)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (rect != NULL);
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2011-03-14 10:22:12 +00:00
|
|
|
/* TODO: This should take wm frame into account */
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
rect->x = surface->x;
|
|
|
|
rect->y = surface->y;
|
|
|
|
rect->width = surface->width;
|
|
|
|
rect->height = surface->height;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_get_device_state (GdkSurface *surface,
|
|
|
|
GdkDevice *device,
|
|
|
|
gdouble *x,
|
|
|
|
gdouble *y,
|
|
|
|
GdkModifierType *mask)
|
2010-11-24 20:28:38 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *child;
|
2011-03-11 07:26:37 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
|
2011-03-11 07:26:37 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2011-03-11 07:26:37 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
GDK_DEVICE_GET_CLASS (device)->query_state (device, surface,
|
2017-08-15 12:57:53 +00:00
|
|
|
&child,
|
2011-03-11 07:26:37 +00:00
|
|
|
NULL, NULL,
|
|
|
|
x, y, mask);
|
|
|
|
return child != NULL;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_broadway_input_shape_combine_region (GdkSurface *surface,
|
|
|
|
const cairo_region_t *shape_region,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_accept_focus (GdkSurface *surface,
|
|
|
|
gboolean accept_focus)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
accept_focus = accept_focus != FALSE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (surface->accept_focus != accept_focus)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->accept_focus = accept_focus;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_focus_on_map (GdkSurface *surface,
|
|
|
|
gboolean focus_on_map)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
focus_on_map = focus_on_map != FALSE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (surface->focus_on_map != focus_on_map)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->focus_on_map = focus_on_map;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_icon_list (GdkSurface *surface,
|
|
|
|
GList *surfaces)
|
2010-11-15 19:08:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_icon_name (GdkSurface *surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
const gchar *name)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_object_set_qdata (G_OBJECT (surface), g_quark_from_static_string ("gdk-icon-name-set"),
|
2017-11-21 18:33:12 +00:00
|
|
|
GUINT_TO_POINTER (name != NULL));
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_iconify (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_deiconify (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_stick (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_unstick (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_maximize (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2016-09-09 12:53:18 +00:00
|
|
|
GdkDisplay *display;
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkRectangle geom;
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
|
|
|
if (impl->maximized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
impl->maximized = TRUE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_MAXIMIZED);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl->pre_maximize_x = surface->x;
|
|
|
|
impl->pre_maximize_y = surface->y;
|
|
|
|
impl->pre_maximize_width = surface->width;
|
|
|
|
impl->pre_maximize_height = surface->height;
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
display = gdk_surface_get_display (surface);
|
2016-09-09 12:53:18 +00:00
|
|
|
monitor = gdk_display_get_primary_monitor (display);
|
|
|
|
gdk_monitor_get_geometry (monitor, &geom);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_move_resize (surface,
|
2016-09-09 12:53:18 +00:00
|
|
|
geom.x, geom.y,
|
|
|
|
geom.width, geom.height);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_unmaximize (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
|
|
|
if (!impl->maximized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
impl->maximized = FALSE;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MAXIMIZED, 0);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_move_resize (surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
impl->pre_maximize_x,
|
|
|
|
impl->pre_maximize_y,
|
|
|
|
impl->pre_maximize_width,
|
|
|
|
impl->pre_maximize_height);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_fullscreen (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
}
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_unfullscreen (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_keep_above (GdkSurface *surface,
|
|
|
|
gboolean setting)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_keep_below (GdkSurface *surface, gboolean setting)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_get_group (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return NULL;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
return surface;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_group (GdkSurface *surface,
|
|
|
|
GdkSurface *leader)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_decorations (GdkSurface *surface,
|
|
|
|
GdkWMDecoration decorations)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
}
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static gboolean
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_get_decorations (GdkSurface *surface,
|
|
|
|
GdkWMDecoration *decorations)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2010-11-15 19:08:18 +00:00
|
|
|
gboolean result = FALSE;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
return result;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_functions (GdkSurface *surface,
|
|
|
|
GdkWMFunction functions)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-15 14:31:56 +00:00
|
|
|
typedef struct _MoveResizeData MoveResizeData;
|
|
|
|
|
|
|
|
struct _MoveResizeData
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurface *moveresize_surface;
|
|
|
|
GdkSurface *moveresize_emulation_surface;
|
2011-04-15 14:31:56 +00:00
|
|
|
gboolean is_resize;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceEdge resize_edge;
|
2011-04-15 14:31:56 +00:00
|
|
|
gint moveresize_button;
|
|
|
|
gint moveresize_x;
|
|
|
|
gint moveresize_y;
|
|
|
|
gint moveresize_orig_x;
|
|
|
|
gint moveresize_orig_y;
|
|
|
|
gint moveresize_orig_width;
|
|
|
|
gint moveresize_orig_height;
|
|
|
|
long moveresize_process_time;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceHints moveresize_geom_mask;
|
2013-03-28 19:03:13 +00:00
|
|
|
GdkGeometry moveresize_geometry;
|
2011-04-15 14:31:56 +00:00
|
|
|
BroadwayInputMsg *moveresize_pending_event;
|
|
|
|
};
|
|
|
|
|
|
|
|
static MoveResizeData *
|
|
|
|
get_move_resize_data (GdkDisplay *display,
|
2017-11-21 18:33:12 +00:00
|
|
|
gboolean create)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
2013-03-28 16:38:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2011-04-15 14:31:56 +00:00
|
|
|
MoveResizeData *mv_resize;
|
|
|
|
|
2013-03-28 16:38:44 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2013-03-28 16:38:44 +00:00
|
|
|
mv_resize = broadway_display->move_resize_data;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
if (!mv_resize && create)
|
|
|
|
{
|
|
|
|
mv_resize = g_new0 (MoveResizeData, 1);
|
|
|
|
mv_resize->display = display;
|
|
|
|
|
2013-03-28 16:38:44 +00:00
|
|
|
broadway_display->move_resize_data = mv_resize;
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mv_resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_pos (MoveResizeData *mv_resize,
|
2017-11-21 18:33:12 +00:00
|
|
|
gint new_root_x,
|
|
|
|
gint new_root_y)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
|
|
|
gint dx, dy;
|
|
|
|
|
|
|
|
dx = new_root_x - mv_resize->moveresize_x;
|
|
|
|
dy = new_root_y - mv_resize->moveresize_y;
|
|
|
|
|
|
|
|
if (mv_resize->is_resize)
|
|
|
|
{
|
|
|
|
gint x, y, w, h;
|
|
|
|
|
|
|
|
x = mv_resize->moveresize_orig_x;
|
|
|
|
y = mv_resize->moveresize_orig_y;
|
|
|
|
|
|
|
|
w = mv_resize->moveresize_orig_width;
|
|
|
|
h = mv_resize->moveresize_orig_height;
|
|
|
|
|
|
|
|
switch (mv_resize->resize_edge)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
2017-11-21 18:33:12 +00:00
|
|
|
x += dx;
|
|
|
|
y += dy;
|
|
|
|
w -= dx;
|
|
|
|
h -= dy;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2017-11-21 18:33:12 +00:00
|
|
|
y += dy;
|
|
|
|
h -= dy;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2017-11-21 18:33:12 +00:00
|
|
|
y += dy;
|
|
|
|
h -= dy;
|
|
|
|
w += dx;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2017-11-21 18:33:12 +00:00
|
|
|
h += dy;
|
|
|
|
x += dx;
|
|
|
|
w -= dx;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2017-11-21 18:33:12 +00:00
|
|
|
w += dx;
|
|
|
|
h += dy;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
2017-11-21 18:33:12 +00:00
|
|
|
h += dy;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
2017-11-21 18:33:12 +00:00
|
|
|
w += dx;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
2017-11-21 18:33:12 +00:00
|
|
|
x += dx;
|
|
|
|
w -= dx;
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
2017-11-21 18:33:12 +00:00
|
|
|
}
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
x = MAX (x, 0);
|
|
|
|
y = MAX (y, 0);
|
|
|
|
w = MAX (w, 1);
|
|
|
|
h = MAX (h, 1);
|
|
|
|
|
2013-03-28 19:03:13 +00:00
|
|
|
if (mv_resize->moveresize_geom_mask)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_constrain_size (&mv_resize->moveresize_geometry,
|
2017-11-21 18:33:12 +00:00
|
|
|
mv_resize->moveresize_geom_mask,
|
|
|
|
w, h, &w, &h);
|
|
|
|
}
|
2013-03-28 19:03:13 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_move_resize (mv_resize->moveresize_surface, x, y, w, h);
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
x = mv_resize->moveresize_orig_x + dx;
|
|
|
|
y = mv_resize->moveresize_orig_y + dy;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_move (mv_resize->moveresize_surface, x, y);
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
finish_drag (MoveResizeData *mv_resize)
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_destroy (mv_resize->moveresize_emulation_surface);
|
|
|
|
mv_resize->moveresize_emulation_surface = NULL;
|
|
|
|
g_object_unref (mv_resize->moveresize_surface);
|
|
|
|
mv_resize->moveresize_surface = NULL;
|
2014-07-14 15:02:13 +00:00
|
|
|
g_clear_pointer (&mv_resize->moveresize_pending_event, g_free);
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
moveresize_lookahead (GdkDisplay *display,
|
2017-11-21 18:33:12 +00:00
|
|
|
MoveResizeData *mv_resize,
|
|
|
|
BroadwayInputMsg *event)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
2012-12-19 11:37:02 +00:00
|
|
|
return !_gdk_broadway_server_lookahead_event (broadway_display->server, "mb");
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gdk_broadway_moveresize_handle_event (GdkDisplay *display,
|
2017-11-21 18:33:12 +00:00
|
|
|
BroadwayInputMsg *event)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
|
|
|
guint button_mask = 0;
|
|
|
|
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (!mv_resize || !mv_resize->moveresize_surface)
|
2011-04-15 14:31:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
|
|
|
|
|
|
|
|
switch (event->base.type)
|
|
|
|
{
|
2013-11-12 15:44:30 +00:00
|
|
|
case BROADWAY_EVENT_TOUCH:
|
|
|
|
if (event->touch.touch_type == 2) /* END */
|
|
|
|
{
|
|
|
|
update_pos (mv_resize,
|
|
|
|
event->touch.root_x,
|
|
|
|
event->touch.root_y);
|
|
|
|
|
|
|
|
finish_drag (mv_resize);
|
|
|
|
}
|
|
|
|
else if (event->touch.touch_type == 1) /* UPDATE */
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
if (mv_resize->moveresize_surface->resize_count > 0)
|
2013-11-12 15:44:30 +00:00
|
|
|
{
|
|
|
|
if (mv_resize->moveresize_pending_event)
|
|
|
|
*mv_resize->moveresize_pending_event = *event;
|
|
|
|
else
|
|
|
|
mv_resize->moveresize_pending_event =
|
|
|
|
g_memdup (event, sizeof (BroadwayInputMsg));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
update_pos (mv_resize,
|
|
|
|
event->touch.root_x,
|
|
|
|
event->touch.root_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2013-03-28 16:38:44 +00:00
|
|
|
case BROADWAY_EVENT_POINTER_MOVE:
|
2018-03-21 08:17:50 +00:00
|
|
|
if (mv_resize->moveresize_surface->resize_count > 0)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
|
|
|
if (mv_resize->moveresize_pending_event)
|
|
|
|
*mv_resize->moveresize_pending_event = *event;
|
|
|
|
else
|
|
|
|
mv_resize->moveresize_pending_event =
|
|
|
|
g_memdup (event, sizeof (BroadwayInputMsg));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2011-04-15 14:31:56 +00:00
|
|
|
if (!moveresize_lookahead (display, mv_resize, event))
|
2017-11-21 18:33:12 +00:00
|
|
|
break;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
update_pos (mv_resize,
|
2017-11-21 18:33:12 +00:00
|
|
|
event->pointer.root_x,
|
|
|
|
event->pointer.root_y);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
/* This should never be triggered in normal cases, but in the
|
|
|
|
* case where the drag started without an implicit grab being
|
|
|
|
* in effect, we could miss the release if it occurs before
|
|
|
|
* we grab the pointer; this ensures that we will never
|
|
|
|
* get a permanently stuck grab.
|
|
|
|
*/
|
|
|
|
if ((event->pointer.state & button_mask) == 0)
|
2017-11-21 18:33:12 +00:00
|
|
|
finish_drag (mv_resize);
|
2011-04-15 14:31:56 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-28 16:38:44 +00:00
|
|
|
case BROADWAY_EVENT_BUTTON_RELEASE:
|
2011-04-15 14:31:56 +00:00
|
|
|
update_pos (mv_resize,
|
2017-11-21 18:33:12 +00:00
|
|
|
event->pointer.root_x,
|
|
|
|
event->pointer.root_y);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
if (event->button.button == mv_resize->moveresize_button)
|
2017-11-21 18:33:12 +00:00
|
|
|
finish_drag (mv_resize);
|
2011-04-15 14:31:56 +00:00
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gdk_broadway_moveresize_configure_done (GdkDisplay *display,
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurface *surface)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
|
|
|
BroadwayInputMsg *tmp_event;
|
|
|
|
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (!mv_resize || surface != mv_resize->moveresize_surface)
|
2011-04-15 14:31:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (mv_resize->moveresize_pending_event)
|
|
|
|
{
|
|
|
|
tmp_event = mv_resize->moveresize_pending_event;
|
|
|
|
mv_resize->moveresize_pending_event = NULL;
|
|
|
|
_gdk_broadway_moveresize_handle_event (display, tmp_event);
|
|
|
|
g_free (tmp_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
create_moveresize_surface (MoveResizeData *mv_resize,
|
|
|
|
guint32 timestamp)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
|
|
|
GdkGrabStatus status;
|
2016-10-24 08:13:14 +00:00
|
|
|
GdkSeat *seat;
|
|
|
|
GdkDevice *pointer;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
g_assert (mv_resize->moveresize_emulation_surface == NULL);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_emulation_surface = gdk_surface_new_temp (mv_resize->display);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_show (mv_resize->moveresize_emulation_surface);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2016-10-24 08:13:14 +00:00
|
|
|
seat = gdk_display_get_default_seat (mv_resize->display);
|
|
|
|
pointer = gdk_seat_get_pointer (seat);
|
|
|
|
|
2013-04-01 13:38:19 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2016-10-24 08:13:14 +00:00
|
|
|
status = gdk_device_grab (pointer,
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_emulation_surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
GDK_OWNERSHIP_APPLICATION,
|
|
|
|
FALSE,
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_POINTER_MOTION_MASK,
|
|
|
|
NULL,
|
|
|
|
timestamp);
|
2013-04-01 13:38:19 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
if (status != GDK_GRAB_SUCCESS)
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
/* If this fails, some other client has grabbed the surface
|
2011-04-15 14:31:56 +00:00
|
|
|
* already.
|
|
|
|
*/
|
|
|
|
finish_drag (mv_resize);
|
|
|
|
}
|
|
|
|
|
|
|
|
mv_resize->moveresize_process_time = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-28 19:03:13 +00:00
|
|
|
static void
|
|
|
|
calculate_unmoving_origin (MoveResizeData *mv_resize)
|
|
|
|
{
|
|
|
|
GdkRectangle rect;
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
|
|
|
|
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_get_origin (mv_resize->moveresize_surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
&mv_resize->moveresize_orig_x,
|
|
|
|
&mv_resize->moveresize_orig_y);
|
2013-03-28 19:03:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_surface_get_frame_extents (mv_resize->moveresize_surface, &rect);
|
|
|
|
gdk_surface_get_geometry (mv_resize->moveresize_surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
NULL, NULL, &width, &height);
|
2013-03-28 19:03:13 +00:00
|
|
|
|
|
|
|
switch (mv_resize->moveresize_geometry.win_gravity)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
|
|
|
|
break;
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x + rect.width - width;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y + rect.height - height;
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
case GDK_GRAVITY_STATIC:
|
2017-11-21 18:33:12 +00:00
|
|
|
default:
|
|
|
|
mv_resize->moveresize_orig_x = rect.x;
|
|
|
|
mv_resize->moveresize_orig_y = rect.y;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-28 19:03:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_begin_resize_drag (GdkSurface *surface,
|
|
|
|
GdkSurfaceEdge edge,
|
|
|
|
GdkDevice *device,
|
|
|
|
gint button,
|
2019-03-28 08:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2018-03-21 08:17:50 +00:00
|
|
|
guint32 timestamp)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-04-15 14:31:56 +00:00
|
|
|
MoveResizeData *mv_resize;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2013-03-28 19:03:13 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-26 11:49:23 +00:00
|
|
|
if (impl->maximized)
|
|
|
|
return;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize = get_move_resize_data (gdk_surface_get_display (surface), TRUE);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2019-03-22 12:52:08 +00:00
|
|
|
if (mv_resize->moveresize_surface != NULL)
|
|
|
|
return; /* already a drag operation in progress */
|
|
|
|
|
2011-04-15 14:31:56 +00:00
|
|
|
mv_resize->is_resize = TRUE;
|
|
|
|
mv_resize->moveresize_button = button;
|
|
|
|
mv_resize->resize_edge = edge;
|
2019-03-28 08:36:30 +00:00
|
|
|
mv_resize->moveresize_x = x + impl->wrapper->x;
|
|
|
|
mv_resize->moveresize_y = y + impl->wrapper->y;
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_surface = g_object_ref (surface);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_orig_width = gdk_surface_get_width (surface);
|
|
|
|
mv_resize->moveresize_orig_height = gdk_surface_get_height (surface);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2013-03-28 19:03:13 +00:00
|
|
|
mv_resize->moveresize_geom_mask = impl->geometry_hints_mask;
|
|
|
|
mv_resize->moveresize_geometry = impl->geometry_hints;
|
|
|
|
|
|
|
|
calculate_unmoving_origin (mv_resize);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
create_moveresize_surface (mv_resize, timestamp);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_begin_move_drag (GdkSurface *surface,
|
|
|
|
GdkDevice *device,
|
|
|
|
gint button,
|
2019-03-28 08:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2018-03-21 08:17:50 +00:00
|
|
|
guint32 timestamp)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2013-11-06 12:28:12 +00:00
|
|
|
MoveResizeData *mv_resize;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplBroadway *impl;
|
2013-11-06 12:28:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
2013-11-06 12:28:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-26 11:49:23 +00:00
|
|
|
if (impl->maximized)
|
|
|
|
return;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize = get_move_resize_data (gdk_surface_get_display (surface), TRUE);
|
2013-11-06 12:28:12 +00:00
|
|
|
|
2019-03-22 12:52:08 +00:00
|
|
|
if (mv_resize->moveresize_surface != NULL)
|
|
|
|
return; /* already a drag operation in progress */
|
|
|
|
|
2013-11-06 12:28:12 +00:00
|
|
|
mv_resize->is_resize = FALSE;
|
|
|
|
mv_resize->moveresize_button = button;
|
2019-03-28 08:36:30 +00:00
|
|
|
mv_resize->moveresize_x = x + impl->wrapper->x;
|
|
|
|
mv_resize->moveresize_y = y + impl->wrapper->y;
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_surface = g_object_ref (surface);
|
2013-11-06 12:28:12 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
mv_resize->moveresize_orig_width = gdk_surface_get_width (surface);
|
|
|
|
mv_resize->moveresize_orig_height = gdk_surface_get_height (surface);
|
2013-11-06 12:28:12 +00:00
|
|
|
|
|
|
|
mv_resize->moveresize_geom_mask = impl->geometry_hints_mask;
|
|
|
|
mv_resize->moveresize_geometry = impl->geometry_hints;
|
|
|
|
|
|
|
|
calculate_unmoving_origin (mv_resize);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
create_moveresize_surface (mv_resize, timestamp);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static gboolean
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_beep (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
return FALSE;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_surface_set_opacity (GdkSurface *surface,
|
2017-11-21 18:33:12 +00:00
|
|
|
gdouble opacity)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (surface));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface) ||
|
|
|
|
!SURFACE_IS_TOPLEVEL (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (opacity < 0)
|
|
|
|
opacity = 0;
|
|
|
|
else if (opacity > 1)
|
|
|
|
opacity = 1;
|
|
|
|
}
|
|
|
|
|
2011-04-07 18:18:13 +00:00
|
|
|
guint32
|
2018-03-21 08:17:50 +00:00
|
|
|
gdk_broadway_get_last_seen_time (GdkSurface *surface)
|
2011-04-07 18:18:13 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
display = gdk_surface_get_display (surface);
|
2012-12-19 11:37:02 +00:00
|
|
|
return _gdk_broadway_server_get_last_seen_time (GDK_BROADWAY_DISPLAY (display)->server);
|
2011-04-07 18:18:13 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_impl_broadway_class_init (GdkSurfaceImplBroadwayClass *klass)
|
2010-12-04 21:28:31 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplClass *impl_class = GDK_SURFACE_IMPL_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_surface_impl_broadway_finalize;
|
|
|
|
|
|
|
|
impl_class->ref_cairo_surface = gdk_surface_broadway_ref_cairo_surface;
|
|
|
|
impl_class->show = gdk_surface_broadway_show;
|
|
|
|
impl_class->hide = gdk_surface_broadway_hide;
|
|
|
|
impl_class->withdraw = gdk_surface_broadway_withdraw;
|
|
|
|
impl_class->raise = gdk_surface_broadway_raise;
|
|
|
|
impl_class->lower = gdk_surface_broadway_lower;
|
|
|
|
impl_class->restack_toplevel = gdk_surface_broadway_restack_toplevel;
|
|
|
|
impl_class->move_resize = gdk_surface_broadway_move_resize;
|
|
|
|
impl_class->get_geometry = gdk_surface_broadway_get_geometry;
|
|
|
|
impl_class->get_root_coords = gdk_surface_broadway_get_root_coords;
|
|
|
|
impl_class->get_device_state = gdk_surface_broadway_get_device_state;
|
|
|
|
impl_class->input_shape_combine_region = gdk_surface_broadway_input_shape_combine_region;
|
|
|
|
impl_class->destroy = _gdk_broadway_surface_destroy;
|
|
|
|
impl_class->beep = gdk_broadway_surface_beep;
|
|
|
|
|
|
|
|
impl_class->focus = gdk_broadway_surface_focus;
|
|
|
|
impl_class->set_type_hint = gdk_broadway_surface_set_type_hint;
|
|
|
|
impl_class->get_type_hint = gdk_broadway_surface_get_type_hint;
|
|
|
|
impl_class->set_modal_hint = gdk_broadway_surface_set_modal_hint;
|
|
|
|
impl_class->set_skip_taskbar_hint = gdk_broadway_surface_set_skip_taskbar_hint;
|
|
|
|
impl_class->set_skip_pager_hint = gdk_broadway_surface_set_skip_pager_hint;
|
|
|
|
impl_class->set_urgency_hint = gdk_broadway_surface_set_urgency_hint;
|
|
|
|
impl_class->set_geometry_hints = gdk_broadway_surface_set_geometry_hints;
|
|
|
|
impl_class->set_title = gdk_broadway_surface_set_title;
|
|
|
|
impl_class->set_startup_id = gdk_broadway_surface_set_startup_id;
|
|
|
|
impl_class->set_transient_for = gdk_broadway_surface_set_transient_for;
|
|
|
|
impl_class->get_frame_extents = gdk_broadway_surface_get_frame_extents;
|
|
|
|
impl_class->set_accept_focus = gdk_broadway_surface_set_accept_focus;
|
|
|
|
impl_class->set_focus_on_map = gdk_broadway_surface_set_focus_on_map;
|
|
|
|
impl_class->set_icon_list = gdk_broadway_surface_set_icon_list;
|
|
|
|
impl_class->set_icon_name = gdk_broadway_surface_set_icon_name;
|
|
|
|
impl_class->iconify = gdk_broadway_surface_iconify;
|
|
|
|
impl_class->deiconify = gdk_broadway_surface_deiconify;
|
|
|
|
impl_class->stick = gdk_broadway_surface_stick;
|
|
|
|
impl_class->unstick = gdk_broadway_surface_unstick;
|
|
|
|
impl_class->maximize = gdk_broadway_surface_maximize;
|
|
|
|
impl_class->unmaximize = gdk_broadway_surface_unmaximize;
|
|
|
|
impl_class->fullscreen = gdk_broadway_surface_fullscreen;
|
|
|
|
impl_class->unfullscreen = gdk_broadway_surface_unfullscreen;
|
|
|
|
impl_class->set_keep_above = gdk_broadway_surface_set_keep_above;
|
|
|
|
impl_class->set_keep_below = gdk_broadway_surface_set_keep_below;
|
|
|
|
impl_class->get_group = gdk_broadway_surface_get_group;
|
|
|
|
impl_class->set_group = gdk_broadway_surface_set_group;
|
|
|
|
impl_class->set_decorations = gdk_broadway_surface_set_decorations;
|
|
|
|
impl_class->get_decorations = gdk_broadway_surface_get_decorations;
|
|
|
|
impl_class->set_functions = gdk_broadway_surface_set_functions;
|
|
|
|
impl_class->begin_resize_drag = gdk_broadway_surface_begin_resize_drag;
|
|
|
|
impl_class->begin_move_drag = gdk_broadway_surface_begin_move_drag;
|
|
|
|
impl_class->set_opacity = gdk_broadway_surface_set_opacity;
|
|
|
|
impl_class->destroy_notify = gdk_broadway_surface_destroy_notify;
|
|
|
|
impl_class->register_dnd = _gdk_broadway_surface_register_dnd;
|
|
|
|
impl_class->drag_begin = _gdk_broadway_surface_drag_begin;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|