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"
|
2010-11-12 12:18:58 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
2020-03-07 22:11:16 +00:00
|
|
|
#include "gdkdisplay-broadway.h"
|
2020-08-26 20:03:31 +00:00
|
|
|
#include "gdkdevice-broadway.h"
|
2020-03-07 22:11:16 +00:00
|
|
|
#include "gdkdisplay.h"
|
|
|
|
#include "gdkdragsurfaceprivate.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
#include "gdkeventsource.h"
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdkframeclockidleprivate.h"
|
2020-03-07 22:11:16 +00:00
|
|
|
#include "gdkinternals.h"
|
|
|
|
#include "gdkpopupprivate.h"
|
|
|
|
#include "gdkprivate-broadway.h"
|
|
|
|
#include "gdksurfaceprivate.h"
|
|
|
|
#include "gdktextureprivate.h"
|
|
|
|
#include "gdktoplevelprivate.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
#include <graphene.h>
|
2010-11-12 12:18:58 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* Forward declarations */
|
2019-04-22 01:14:46 +00:00
|
|
|
static void gdk_broadway_surface_finalize (GObject *object);
|
2010-12-04 21:28:31 +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
|
|
|
|
2020-03-07 22:11:16 +00:00
|
|
|
GType gdk_broadway_toplevel_get_type (void) G_GNUC_CONST;
|
|
|
|
GType gdk_broadway_popup_get_type (void) G_GNUC_CONST;
|
|
|
|
GType gdk_broadway_drag_surface_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define GDK_TYPE_BROADWAY_TOPLEVEL (gdk_broadway_toplevel_get_type ())
|
|
|
|
#define GDK_TYPE_BROADWAY_POPUP (gdk_broadway_popup_get_type ())
|
|
|
|
#define GDK_TYPE_BROADWAY_DRAG_SURFACE (gdk_broadway_drag_surface_get_type ())
|
|
|
|
|
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
|
|
|
{
|
2019-03-29 10:13:24 +00:00
|
|
|
gdk_broadway_display_flush_in_idle (gdk_surface_get_display (surface));
|
2010-11-16 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_init (GdkBroadwaySurface *impl)
|
2010-11-16 21:11:53 +00:00
|
|
|
{
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_finalize (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
g_return_if_fail (GDK_IS_BROADWAY_SURFACE (object));
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
_gdk_broadway_surface_grab_check_destroy (GDK_SURFACE (impl));
|
2011-04-15 14:17:27 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (GDK_SURFACE (impl)));
|
2010-11-25 19:07:26 +00:00
|
|
|
|
2020-05-16 13:10:28 +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
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
G_OBJECT_CLASS (gdk_broadway_surface_parent_class)->finalize (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 09:22:23 +00:00
|
|
|
static gboolean
|
2019-06-28 16:45:44 +00:00
|
|
|
thaw_updates_cb (GdkSurface *surface)
|
2017-11-23 09:22:23 +00:00
|
|
|
{
|
2020-05-16 17:47:18 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
|
|
|
gdk_surface_thaw_updates (surface);
|
2019-06-28 16:45:44 +00:00
|
|
|
g_object_unref (surface);
|
2017-11-23 09:22:23 +00:00
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-21 08:17:50 +00:00
|
|
|
_gdk_broadway_roundtrip_notify (GdkSurface *surface,
|
2019-04-22 01:14:46 +00:00
|
|
|
guint32 tag,
|
|
|
|
gboolean local_reply)
|
2017-11-23 09:22:23 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
2019-03-29 11:31:42 +00:00
|
|
|
GdkFrameTimings *timings;
|
|
|
|
|
|
|
|
timings = gdk_frame_clock_get_timings (clock, impl->pending_frame_counter);
|
|
|
|
impl->pending_frame_counter = 0;
|
2017-11-23 09:22:23 +00:00
|
|
|
|
2019-05-24 11:18:31 +00:00
|
|
|
/* If there is no remote web client, rate limit update to once a second */
|
2017-11-23 09:22:23 +00:00
|
|
|
if (local_reply)
|
2019-06-28 16:45:44 +00:00
|
|
|
g_timeout_add_seconds (1, (GSourceFunc)thaw_updates_cb, g_object_ref (surface));
|
2017-11-23 09:22:23 +00:00
|
|
|
else
|
2019-06-28 16:45:44 +00:00
|
|
|
gdk_surface_thaw_updates (surface);
|
2019-03-29 11:31:42 +00:00
|
|
|
|
|
|
|
if (timings)
|
|
|
|
{
|
|
|
|
timings->refresh_interval = 33333; /* default to 1/30th of a second */
|
2020-08-21 12:41:13 +00:00
|
|
|
// This isn't quite right, since we've done a roundtrip back too, can we do better?
|
2019-03-29 11:31:42 +00:00
|
|
|
timings->presentation_time = g_get_monotonic_time ();
|
|
|
|
timings->complete = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
|
|
|
|
_gdk_frame_clock_debug_print_timings (clock, timings);
|
2019-05-24 11:18:31 +00:00
|
|
|
|
2020-02-12 10:05:01 +00:00
|
|
|
if (GDK_PROFILER_IS_RUNNING)
|
2019-05-24 11:18:31 +00:00
|
|
|
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
|
2019-03-29 11:31:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
2017-11-23 09:22:23 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:22:42 +00:00
|
|
|
static void
|
|
|
|
on_frame_clock_after_paint (GdkFrameClock *clock,
|
2019-04-22 01:14:46 +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);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
2017-11-23 09:22:23 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
2019-03-29 11:31:42 +00:00
|
|
|
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
2019-06-28 16:45:44 +00:00
|
|
|
gdk_surface_freeze_updates (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
|
|
|
}
|
|
|
|
|
2019-03-29 11:31:42 +00:00
|
|
|
static void
|
|
|
|
on_frame_clock_before_paint (GdkFrameClock *clock,
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurface *surface)
|
2019-03-29 11:31:42 +00:00
|
|
|
{
|
|
|
|
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
|
|
|
|
gint64 presentation_time;
|
|
|
|
gint64 refresh_interval;
|
|
|
|
|
|
|
|
if (surface->update_freeze_count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_frame_clock_get_refresh_info (clock,
|
|
|
|
timings->frame_time,
|
|
|
|
&refresh_interval, &presentation_time);
|
|
|
|
if (presentation_time != 0)
|
|
|
|
{
|
|
|
|
timings->predicted_presentation_time = presentation_time + refresh_interval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
2013-03-28 18:22:42 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
g_signal_connect (frame_clock, "before-paint",
|
|
|
|
G_CALLBACK (on_frame_clock_before_paint), surface);
|
|
|
|
g_signal_connect (frame_clock, "after-paint",
|
|
|
|
G_CALLBACK (on_frame_clock_after_paint), surface);
|
2013-03-28 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
2019-05-24 01:55:23 +00:00
|
|
|
static void
|
|
|
|
disconnect_frame_clock (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (frame_clock,
|
|
|
|
on_frame_clock_before_paint, surface);
|
|
|
|
g_signal_handlers_disconnect_by_func (frame_clock,
|
|
|
|
on_frame_clock_after_paint, surface);
|
|
|
|
}
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurface *
|
|
|
|
_gdk_broadway_display_create_surface (GdkDisplay *display,
|
|
|
|
GdkSurfaceType surface_type,
|
|
|
|
GdkSurface *parent,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
GdkSurface *surface;
|
|
|
|
GdkBroadwaySurface *impl;
|
2020-03-07 22:11:16 +00:00
|
|
|
GType type;
|
2019-04-22 01:14:46 +00:00
|
|
|
|
2020-03-13 14:26:22 +00:00
|
|
|
if (parent)
|
|
|
|
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
|
|
|
|
else
|
|
|
|
frame_clock = _gdk_frame_clock_idle_new ();
|
2019-04-22 01:14:46 +00:00
|
|
|
|
2020-03-07 22:11:16 +00:00
|
|
|
switch (surface_type)
|
|
|
|
{
|
|
|
|
case GDK_SURFACE_TOPLEVEL:
|
|
|
|
type = GDK_TYPE_BROADWAY_TOPLEVEL;
|
|
|
|
break;
|
|
|
|
case GDK_SURFACE_POPUP:
|
|
|
|
type = GDK_TYPE_BROADWAY_POPUP;
|
|
|
|
break;
|
|
|
|
case GDK_SURFACE_TEMP:
|
|
|
|
type = GDK_TYPE_BROADWAY_DRAG_SURFACE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface = g_object_new (type,
|
2019-04-22 01:14:46 +00:00
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_unref (frame_clock);
|
|
|
|
|
2019-04-22 14:21:17 +00:00
|
|
|
surface->parent = parent;
|
2019-04-22 01:14:46 +00:00
|
|
|
surface->x = x;
|
|
|
|
surface->y = y;
|
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
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
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
2020-03-13 13:33:07 +00:00
|
|
|
impl->root_x = x;
|
|
|
|
impl->root_y = y;
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
impl->root_x += GDK_BROADWAY_SURFACE (parent)->root_x;
|
|
|
|
impl->root_y += GDK_BROADWAY_SURFACE (parent)->root_y;
|
|
|
|
}
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
2020-03-13 13:33:07 +00:00
|
|
|
impl->root_x,
|
|
|
|
impl->root_y,
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->width,
|
2020-03-13 13:33:07 +00:00
|
|
|
surface->height);
|
2018-03-21 08:17:50 +00:00
|
|
|
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
|
|
|
|
2020-05-16 13:10:28 +00:00
|
|
|
g_object_ref (surface);
|
|
|
|
|
2019-04-22 20:27:08 +00:00
|
|
|
if (!surface->parent)
|
|
|
|
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);
|
2019-04-22 01:14:46 +00:00
|
|
|
|
2020-03-13 13:35:43 +00:00
|
|
|
/* We treat the real parent as a default transient for to get stacking right */
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
impl->transient_for = GDK_BROADWAY_SURFACE (parent)->id;
|
|
|
|
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, impl->id, impl->transient_for);
|
|
|
|
}
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
return surface;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-12-04 21:28:31 +00:00
|
|
|
static cairo_surface_t *
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_ref_cairo_surface (GdkSurface *surface)
|
2010-12-04 21:28:31 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
if (GDK_IS_BROADWAY_SURFACE (surface) &&
|
|
|
|
GDK_SURFACE_DESTROYED (surface))
|
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,
|
2019-04-22 01:14:46 +00:00
|
|
|
gboolean foreign_destroy)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *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
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
2010-11-16 21:11:53 +00:00
|
|
|
|
2019-05-24 01:55:23 +00:00
|
|
|
disconnect_frame_clock (surface);
|
|
|
|
|
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);
|
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,
|
2019-04-22 01:14:46 +00:00
|
|
|
GArray *nodes,
|
|
|
|
GPtrArray *node_textures)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *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
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_show (GdkSurface *surface,
|
|
|
|
gboolean already_mapped)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-15 21:12:04 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_hide (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2020-03-12 10:12:01 +00:00
|
|
|
gdk_broadway_surface_get_scale_factor (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
|
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
|
|
|
|
|
|
|
return broadway_display->scale_factor;
|
|
|
|
}
|
|
|
|
|
2020-03-13 13:33:07 +00:00
|
|
|
static void
|
|
|
|
sync_child_root_pos (GdkSurface *parent)
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (parent);
|
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (parent));
|
|
|
|
|
|
|
|
for (l = parent->children; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface *child_impl = l->data;
|
|
|
|
GdkSurface *child = GDK_SURFACE (child_impl);
|
|
|
|
int root_x, root_y;
|
|
|
|
|
|
|
|
root_x = child->x + parent_impl->root_x;
|
|
|
|
root_y = child->y + parent_impl->root_y;
|
|
|
|
|
|
|
|
if (root_x != child_impl->root_x ||
|
|
|
|
root_y != child_impl->root_y)
|
|
|
|
{
|
|
|
|
child_impl->root_x = root_x;
|
|
|
|
child_impl->root_y = root_y;
|
|
|
|
|
|
|
|
_gdk_broadway_server_surface_move_resize (broadway_display->server,
|
|
|
|
child_impl->id,
|
|
|
|
TRUE,
|
|
|
|
child_impl->root_x, child_impl->root_y,
|
|
|
|
child->width, child->height);
|
|
|
|
sync_child_root_pos (child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* x, y is relative to parent */
|
2010-11-21 19:46:50 +00:00
|
|
|
static void
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
|
|
|
gboolean with_move,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2018-03-21 08:17:50 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
|
|
|
2020-03-13 13:33:07 +00:00
|
|
|
if (with_move)
|
|
|
|
{
|
|
|
|
surface->x = x;
|
|
|
|
surface->y = y;
|
|
|
|
impl->root_x = x;
|
|
|
|
impl->root_y = y;
|
|
|
|
if (surface->parent)
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (surface->parent);
|
|
|
|
impl->root_x += parent_impl->root_x;
|
|
|
|
impl->root_y += parent_impl->root_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
2020-03-13 13:33:07 +00:00
|
|
|
impl->root_x, impl->root_y,
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->width, surface->height);
|
2020-03-13 13:33:07 +00:00
|
|
|
sync_child_root_pos (surface);
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
void
|
|
|
|
gdk_broadway_surface_move_resize (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2019-07-15 13:47:12 +00:00
|
|
|
{
|
|
|
|
gdk_broadway_surface_move_resize_internal (surface, TRUE,
|
|
|
|
x, y,
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
2019-07-15 08:54:44 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_surface_toplevel_resize (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int width,
|
|
|
|
int height)
|
2019-07-15 08:54:44 +00:00
|
|
|
{
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize_internal (surface, FALSE,
|
|
|
|
0, 0,
|
|
|
|
width, height);
|
2019-07-15 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 09:32:35 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_surface_move (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y)
|
2019-07-15 09:32:35 +00:00
|
|
|
{
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize_internal (surface, TRUE, x, y, -1, -1);
|
2019-07-15 09:32:35 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 09:35:24 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_broadway_surface_layout_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2019-07-15 09:35:24 +00:00
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkRectangle bounds;
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkRectangle final_rect;
|
2019-07-15 09:35:24 +00:00
|
|
|
int x, y;
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
monitor = gdk_surface_get_layout_monitor (surface, layout,
|
|
|
|
gdk_monitor_get_geometry);
|
|
|
|
gdk_monitor_get_geometry (monitor, &bounds);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_surface_layout_popup_helper (surface,
|
|
|
|
width,
|
|
|
|
height,
|
2020-07-29 13:47:48 +00:00
|
|
|
monitor,
|
|
|
|
&bounds,
|
2020-02-16 11:59:24 +00:00
|
|
|
layout,
|
|
|
|
&final_rect);
|
2019-07-15 09:35:24 +00:00
|
|
|
|
2020-03-13 13:33:07 +00:00
|
|
|
x = final_rect.x;
|
|
|
|
y = final_rect.y;
|
2019-07-15 09:35:24 +00:00
|
|
|
|
|
|
|
if (final_rect.width != surface->width ||
|
|
|
|
final_rect.height != surface->height)
|
|
|
|
{
|
|
|
|
gdk_broadway_surface_move_resize (surface,
|
2020-02-16 11:59:24 +00:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
final_rect.width,
|
|
|
|
final_rect.height);
|
2019-07-15 09:35:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_broadway_surface_move (surface, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
show_popup (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
|
|
|
|
gdk_broadway_surface_show (surface, FALSE);
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_grabbing_popup (GdkSeat *seat,
|
|
|
|
GdkSurface *surface,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
show_popup (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_surface_present_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
gdk_broadway_surface_layout_popup (surface, width, height, layout);
|
|
|
|
|
|
|
|
if (GDK_SURFACE_IS_MAPPED (surface))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (surface->autohide)
|
|
|
|
{
|
|
|
|
gdk_seat_grab (gdk_display_get_default_seat (surface->display),
|
|
|
|
surface,
|
|
|
|
GDK_SEAT_CAPABILITY_ALL,
|
|
|
|
TRUE,
|
|
|
|
NULL, NULL,
|
|
|
|
show_grabbing_popup, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
show_popup (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GDK_SURFACE_IS_MAPPED (surface);
|
2019-07-15 09:35:24 +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
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *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
|
|
|
|
2020-03-14 14:06:57 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2013-11-12 11:03:50 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
|
|
_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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_set_geometry_hints (GdkSurface *surface,
|
2018-03-21 08:17:50 +00:00
|
|
|
const GdkGeometry *geometry,
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurfaceHints geom_mask)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2013-03-28 19:03:13 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_set_title (GdkSurface *surface,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_set_startup_id (GdkSurface *surface,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *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;
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2011-04-05 10:02:46 +00:00
|
|
|
int parent_id;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
2011-04-05 10:02:46 +00:00
|
|
|
|
2020-03-13 13:35:43 +00:00
|
|
|
/* We treat the real parent as a default transient for to get stacking right */
|
|
|
|
if (parent == NULL)
|
|
|
|
parent = surface->parent;
|
|
|
|
|
2011-04-05 10:02:46 +00:00
|
|
|
parent_id = 0;
|
|
|
|
if (parent)
|
2019-04-22 01:14:46 +00:00
|
|
|
parent_id = GDK_BROADWAY_SURFACE (parent)->id;
|
2011-04-05 10:02:46 +00:00
|
|
|
|
|
|
|
impl->transient_for = parent_id;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
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
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_get_geometry (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
2010-11-12 12:18:58 +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
|
|
|
|
|
|
|
/* TODO: These should really roundtrip to the client to get the current data */
|
|
|
|
|
|
|
|
if (x)
|
2019-04-22 01:14:46 +00:00
|
|
|
*x = surface->x;
|
2011-03-14 10:22:12 +00:00
|
|
|
if (y)
|
2019-04-22 01:14:46 +00:00
|
|
|
*y = surface->y;
|
2011-03-14 10:22:12 +00:00
|
|
|
if (width)
|
2019-04-22 01:14:46 +00:00
|
|
|
*width = surface->width;
|
2011-03-14 10:22:12 +00:00
|
|
|
if (height)
|
2019-04-22 01:14:46 +00:00
|
|
|
*height = surface->height;
|
2011-03-14 10:22:12 +00:00
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_get_root_coords (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *root_x,
|
|
|
|
int *root_y)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-03-13 13:33:07 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
|
|
|
|
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
if (root_x)
|
2020-03-13 13:33:07 +00:00
|
|
|
*root_x = x + impl->root_x;
|
2010-11-12 12:18:58 +00:00
|
|
|
if (root_y)
|
2020-03-13 13:33:07 +00:00
|
|
|
*root_y = y + impl->root_y;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_get_device_state (GdkSurface *surface,
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkDevice *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *x,
|
|
|
|
double *y,
|
2018-03-21 08:17:50 +00:00
|
|
|
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;
|
|
|
|
|
2020-08-26 20:03:31 +00:00
|
|
|
gdk_broadway_device_query_state (device, surface, &child, x, y, mask);
|
2011-03-11 07:26:37 +00:00
|
|
|
return child != NULL;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
static void
|
2020-03-01 19:29:06 +00:00
|
|
|
gdk_broadway_surface_set_input_region (GdkSurface *surface,
|
|
|
|
cairo_region_t *shape_region)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_broadway_surface_minimize (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_broadway_surface_unminimize (GdkSurface *surface)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (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
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2016-09-09 12:53:18 +00:00
|
|
|
GdkDisplay *display;
|
|
|
|
GdkRectangle geom;
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-11-12 12:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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);
|
2020-05-17 03:58:20 +00:00
|
|
|
gdk_monitor_get_geometry (GDK_BROADWAY_DISPLAY (display)->monitor, &geom);
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize (surface,
|
|
|
|
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
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *impl;
|
2015-06-26 11:49:23 +00:00
|
|
|
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
2010-11-15 19:08:18 +00:00
|
|
|
return;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_BROADWAY_SURFACE (surface);
|
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
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize (surface,
|
|
|
|
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-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;
|
2020-07-24 13:54:49 +00:00
|
|
|
int moveresize_button;
|
|
|
|
int moveresize_x;
|
|
|
|
int moveresize_y;
|
|
|
|
int moveresize_orig_x;
|
|
|
|
int moveresize_orig_y;
|
|
|
|
int moveresize_orig_width;
|
|
|
|
int moveresize_orig_height;
|
2011-04-15 14:31:56 +00:00
|
|
|
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,
|
2020-07-24 13:54:49 +00:00
|
|
|
int new_root_x,
|
|
|
|
int new_root_y)
|
2011-04-15 14:31:56 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int dx, dy;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
dx = new_root_x - mv_resize->moveresize_x;
|
|
|
|
dy = new_root_y - mv_resize->moveresize_y;
|
|
|
|
|
|
|
|
if (mv_resize->is_resize)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y, w, h;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize (mv_resize->moveresize_surface,
|
|
|
|
x, y, w, h);
|
2011-04-15 14:31:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y;
|
2011-04-15 14:31:56 +00:00
|
|
|
|
|
|
|
x = mv_resize->moveresize_orig_x + dx;
|
|
|
|
y = mv_resize->moveresize_orig_y + dy;
|
|
|
|
|
2019-07-15 09:32:35 +00:00
|
|
|
gdk_broadway_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;
|
2019-04-20 01:29:25 +00:00
|
|
|
GdkRectangle rect = { -100, -100, 1, 1 };
|
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
|
|
|
|
2019-04-21 16:51:10 +00:00
|
|
|
mv_resize->moveresize_emulation_surface = gdk_surface_new_temp (mv_resize->display, &rect);
|
2011-04-15 14:31:56 +00:00
|
|
|
|
2020-03-09 17:24:52 +00:00
|
|
|
gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
|
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,
|
2020-06-22 21:54:46 +00:00
|
|
|
mv_resize->moveresize_emulation_surface,
|
|
|
|
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)
|
|
|
|
{
|
2020-07-30 03:02:30 +00:00
|
|
|
gdk_surface_get_geometry (mv_resize->moveresize_surface,
|
|
|
|
&mv_resize->moveresize_orig_x,
|
|
|
|
&mv_resize->moveresize_orig_y,
|
|
|
|
NULL, NULL);
|
2013-03-28 19:03:13 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_broadway_toplevel_begin_resize (GdkToplevel *toplevel,
|
|
|
|
GdkSurfaceEdge edge,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
2011-04-15 14:31:56 +00:00
|
|
|
MoveResizeData *mv_resize;
|
|
|
|
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (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-04-22 20:27:08 +00:00
|
|
|
mv_resize->moveresize_x = x + surface->x;
|
2019-04-22 01:14:46 +00:00
|
|
|
mv_resize->moveresize_y = y + surface->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
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_broadway_toplevel_begin_move (GdkToplevel *toplevel,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
|
|
|
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
2013-11-06 12:28:12 +00:00
|
|
|
MoveResizeData *mv_resize;
|
|
|
|
|
2020-02-23 23:15:59 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (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-04-22 01:14:46 +00:00
|
|
|
mv_resize->moveresize_x = x + surface->x;
|
|
|
|
mv_resize->moveresize_y = y + surface->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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-22 01:14:46 +00:00
|
|
|
gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
|
2010-12-04 21:28:31 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_broadway_surface_finalize;
|
|
|
|
|
|
|
|
impl_class->ref_cairo_surface = gdk_broadway_surface_ref_cairo_surface;
|
|
|
|
impl_class->hide = gdk_broadway_surface_hide;
|
|
|
|
impl_class->get_geometry = gdk_broadway_surface_get_geometry;
|
|
|
|
impl_class->get_root_coords = gdk_broadway_surface_get_root_coords;
|
|
|
|
impl_class->get_device_state = gdk_broadway_surface_get_device_state;
|
2020-03-01 19:29:06 +00:00
|
|
|
impl_class->set_input_region = gdk_broadway_surface_set_input_region;
|
2018-03-20 10:40:08 +00:00
|
|
|
impl_class->destroy = _gdk_broadway_surface_destroy;
|
|
|
|
impl_class->beep = gdk_broadway_surface_beep;
|
|
|
|
impl_class->destroy_notify = gdk_broadway_surface_destroy_notify;
|
|
|
|
impl_class->drag_begin = _gdk_broadway_surface_drag_begin;
|
2020-03-12 10:12:01 +00:00
|
|
|
impl_class->get_scale_factor = gdk_broadway_surface_get_scale_factor;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
2020-03-07 22:11:16 +00:00
|
|
|
|
|
|
|
#define LAST_PROP 1
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface parent_instance;
|
|
|
|
} GdkBroadwayPopup;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurfaceClass parent_class;
|
|
|
|
} GdkBroadwayPopupClass;
|
|
|
|
|
|
|
|
static void gdk_broadway_popup_iface_init (GdkPopupInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkBroadwayPopup, gdk_broadway_popup, GDK_TYPE_BROADWAY_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
|
|
|
gdk_broadway_popup_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_popup_init (GdkBroadwayPopup *popup)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_popup_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
g_value_set_object (value, surface->parent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
g_value_set_boolean (value, surface->autohide);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_popup_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
surface->parent = g_value_dup_object (value);
|
|
|
|
if (surface->parent != NULL)
|
|
|
|
surface->parent->children = g_list_prepend (surface->parent->children, surface);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
surface->autohide = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_popup_class_init (GdkBroadwayPopupClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_broadway_popup_get_property;
|
|
|
|
object_class->set_property = gdk_broadway_popup_set_property;
|
|
|
|
|
|
|
|
gdk_popup_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_popup_present (GdkPopup *popup,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
|
|
|
{
|
|
|
|
return gdk_broadway_surface_present_popup (GDK_SURFACE (popup), width, height, layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_broadway_popup_get_surface_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.surface_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_broadway_popup_get_rect_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.rect_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_broadway_popup_get_position_x (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_broadway_popup_get_position_y (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_popup_iface_init (GdkPopupInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_broadway_popup_present;
|
|
|
|
iface->get_surface_anchor = gdk_broadway_popup_get_surface_anchor;
|
|
|
|
iface->get_rect_anchor = gdk_broadway_popup_get_rect_anchor;
|
|
|
|
iface->get_position_x = gdk_broadway_popup_get_position_x;
|
|
|
|
iface->get_position_y = gdk_broadway_popup_get_position_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface parent_instance;
|
|
|
|
} GdkBroadwayToplevel;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurfaceClass parent_class;
|
|
|
|
} GdkBroadwayToplevelClass;
|
|
|
|
|
|
|
|
static void gdk_broadway_toplevel_iface_init (GdkToplevelInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkBroadwayToplevel, gdk_broadway_toplevel, GDK_TYPE_BROADWAY_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
|
|
|
gdk_broadway_toplevel_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_init (GdkBroadwayToplevel *toplevel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
gdk_broadway_surface_set_title (surface, g_value_get_string (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
gdk_broadway_surface_set_startup_id (surface, g_value_get_string (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
|
|
|
gdk_broadway_surface_set_transient_for (surface, g_value_get_object (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
2020-03-27 16:13:16 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
break;
|
|
|
|
|
2020-03-07 22:11:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STATE:
|
|
|
|
g_value_set_flags (value, surface->state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
|
|
|
g_value_set_object (value, surface->transient_for);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
g_value_set_pointer (value, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
2020-03-27 16:13:16 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
g_value_set_boolean (value, surface->shortcuts_inhibited);
|
|
|
|
break;
|
|
|
|
|
2020-03-07 22:11:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_class_init (GdkBroadwayToplevelClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_broadway_toplevel_get_property;
|
|
|
|
object_class->set_property = gdk_broadway_toplevel_set_property;
|
|
|
|
|
|
|
|
gdk_toplevel_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_surface (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
gboolean was_mapped;
|
|
|
|
|
|
|
|
if (surface->destroyed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
|
|
|
|
|
|
|
if (!was_mapped)
|
|
|
|
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
|
|
|
|
|
|
|
|
gdk_broadway_surface_show (surface, FALSE);
|
|
|
|
|
|
|
|
if (!was_mapped)
|
2020-05-16 22:41:44 +00:00
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
2020-03-07 22:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_toplevel_present (GdkToplevel *toplevel,
|
|
|
|
GdkToplevelLayout *layout)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
2020-07-30 21:06:59 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkToplevelSize size;
|
|
|
|
int bounds_width, bounds_height;
|
|
|
|
int width, height;
|
2020-03-07 22:11:16 +00:00
|
|
|
GdkGeometry geometry;
|
|
|
|
GdkSurfaceHints mask;
|
|
|
|
|
|
|
|
gdk_broadway_surface_unminimize (surface);
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
monitor = gdk_display_get_monitor_at_surface (display, surface);
|
|
|
|
if (monitor)
|
|
|
|
{
|
|
|
|
GdkRectangle monitor_geometry;
|
|
|
|
|
|
|
|
gdk_monitor_get_geometry (monitor, &monitor_geometry);
|
|
|
|
bounds_width = monitor_geometry.width;
|
|
|
|
bounds_height = monitor_geometry.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bounds_width = G_MAXINT;
|
|
|
|
bounds_height = G_MAXINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
|
|
|
|
gdk_toplevel_notify_compute_size (toplevel, &size);
|
|
|
|
g_warn_if_fail (size.width > 0);
|
|
|
|
g_warn_if_fail (size.height > 0);
|
|
|
|
width = size.width;
|
|
|
|
height = size.height;
|
|
|
|
|
2020-03-07 22:11:16 +00:00
|
|
|
if (gdk_toplevel_layout_get_resizable (layout))
|
|
|
|
{
|
2020-07-30 21:06:59 +00:00
|
|
|
geometry.min_width = size.min_width;
|
|
|
|
geometry.min_height = size.min_height;
|
2020-03-07 22:11:16 +00:00
|
|
|
mask = GDK_HINT_MIN_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geometry.max_width = geometry.min_width = width;
|
|
|
|
geometry.max_height = geometry.min_height = height;
|
|
|
|
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
|
|
|
|
}
|
|
|
|
gdk_broadway_surface_set_geometry_hints (surface, &geometry, mask);
|
|
|
|
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
|
|
|
|
gdk_broadway_surface_toplevel_resize (surface, width, height);
|
|
|
|
|
|
|
|
if (gdk_toplevel_layout_get_maximized (layout))
|
|
|
|
gdk_broadway_surface_maximize (surface);
|
|
|
|
else
|
|
|
|
gdk_broadway_surface_unmaximize (surface);
|
|
|
|
|
|
|
|
show_surface (surface);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_toplevel_minimize (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
gdk_broadway_surface_minimize (GDK_SURFACE (toplevel));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_toplevel_lower (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_focus (GdkToplevel *toplevel,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
gdk_broadway_surface_focus (GDK_SURFACE (toplevel), timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_toplevel_show_window_menu (GdkToplevel *toplevel,
|
|
|
|
GdkEvent *event)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_toplevel_iface_init (GdkToplevelInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_broadway_toplevel_present;
|
|
|
|
iface->minimize = gdk_broadway_toplevel_minimize;
|
|
|
|
iface->lower = gdk_broadway_toplevel_lower;
|
|
|
|
iface->focus = gdk_broadway_toplevel_focus;
|
|
|
|
iface->show_window_menu = gdk_broadway_toplevel_show_window_menu;
|
2020-05-17 16:35:45 +00:00
|
|
|
iface->begin_resize = gdk_broadway_toplevel_begin_resize;
|
|
|
|
iface->begin_move = gdk_broadway_toplevel_begin_move;
|
2020-03-07 22:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurface parent_instance;
|
|
|
|
} GdkBroadwayDragSurface;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkBroadwaySurfaceClass parent_class;
|
|
|
|
} GdkBroadwayDragSurfaceClass;
|
|
|
|
|
|
|
|
static void gdk_broadway_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkBroadwayDragSurface, gdk_broadway_drag_surface, GDK_TYPE_BROADWAY_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
|
|
|
gdk_broadway_drag_surface_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_drag_surface_init (GdkBroadwayDragSurface *surface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_drag_surface_class_init (GdkBroadwayDragSurfaceClass *class)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_drag_surface_present (GdkDragSurface *drag_surface,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (drag_surface);
|
|
|
|
|
|
|
|
gdk_broadway_surface_toplevel_resize (surface, width, height);
|
|
|
|
show_surface (surface);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_broadway_drag_surface_present;
|
|
|
|
}
|