gtk2/gdk/broadway/gdksurface-broadway.c

1468 lines
42 KiB
C
Raw Normal View History

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"
#include "gdksurface-broadway.h"
2010-11-12 12:18:58 +00:00
#include "gdkbroadwaydisplay.h"
#include "gdkdisplay.h"
#include "gdksurfaceprivate.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"
#include "gdktextureprivate.h"
#include "gdkframeclockidleprivate.h"
2010-11-12 12:18:58 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Forward declarations */
static void gdk_broadway_surface_finalize (GObject *object);
#define SURFACE_IS_TOPLEVEL(surface) TRUE
2010-11-12 12:18:58 +00:00
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
G_DEFINE_TYPE (GdkBroadwaySurface, gdk_broadway_surface, GDK_TYPE_SURFACE)
/* We need to flush in an idle rather than AFTER_PAINT, as the clock
is frozen during e.g. surface resizes so the paint will not happen
and the surface resize request is never flushed. */
static void
queue_flush (GdkSurface *surface)
{
gdk_broadway_display_flush_in_idle (gdk_surface_get_display (surface));
}
static void
gdk_broadway_surface_init (GdkBroadwaySurface *impl)
{
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_finalize (GObject *object)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
2010-11-15 19:08:18 +00:00
g_return_if_fail (GDK_IS_BROADWAY_SURFACE (object));
2010-11-12 12:18:58 +00:00
impl = GDK_BROADWAY_SURFACE (object);
2010-11-12 12:18:58 +00:00
_gdk_broadway_surface_grab_check_destroy (GDK_SURFACE (impl));
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (GDK_SURFACE (impl)));
g_hash_table_remove (broadway_display->id_ht, GINT_TO_POINTER(impl->id));
2010-11-20 21:38:34 +00:00
if (impl->cursor)
g_object_unref (impl->cursor);
2010-11-12 12:18:58 +00:00
broadway_display->toplevels = g_list_remove (broadway_display->toplevels, impl);
G_OBJECT_CLASS (gdk_broadway_surface_parent_class)->finalize (object);
2010-11-12 12:18:58 +00:00
}
static gboolean
thaw_updates_cb (GdkSurface *surface)
{
gdk_surface_thaw_updates (surface);
g_object_unref (surface);
return G_SOURCE_REMOVE;
}
void
_gdk_broadway_roundtrip_notify (GdkSurface *surface,
guint32 tag,
gboolean local_reply)
{
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
GdkFrameTimings *timings;
timings = gdk_frame_clock_get_timings (clock, impl->pending_frame_counter);
impl->pending_frame_counter = 0;
/* If there is no remote web client, rate limit update to once a second */
if (local_reply)
g_timeout_add_seconds (1, (GSourceFunc)thaw_updates_cb, g_object_ref (surface));
else
gdk_surface_thaw_updates (surface);
if (timings)
{
timings->refresh_interval = 33333; /* default to 1/30th of a second */
// This isn't quite right, since we've done a rountrip back too, can we do better?
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);
if (GDK_PROFILER_IS_RUNNING)
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
#endif
}
}
static void
on_frame_clock_after_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
GdkBroadwayDisplay *broadway_display;
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
gdk_surface_freeze_updates (surface);
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);
}
static void
on_frame_clock_before_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
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;
}
}
static void
connect_frame_clock (GdkSurface *surface)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
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);
}
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);
}
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
{
GdkBroadwayDisplay *broadway_display;
GdkFrameClock *frame_clock;
GdkSurface *surface;
GdkBroadwaySurface *impl;
frame_clock = _gdk_frame_clock_idle_new ();
surface = g_object_new (GDK_TYPE_BROADWAY_SURFACE,
"surface-type", surface_type,
"display", display,
"frame-clock", frame_clock,
NULL);
g_object_unref (frame_clock);
surface->parent = parent;
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
2010-11-15 19:08:18 +00:00
broadway_display = GDK_BROADWAY_DISPLAY (display);
2010-11-15 19:08:18 +00:00
impl = GDK_BROADWAY_SURFACE (surface);
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
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);
if (!surface->parent)
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
connect_frame_clock (surface);
return surface;
2010-11-12 12:18:58 +00:00
}
static cairo_surface_t *
gdk_broadway_surface_ref_cairo_surface (GdkSurface *surface)
{
if (GDK_IS_BROADWAY_SURFACE (surface) &&
GDK_SURFACE_DESTROYED (surface))
return NULL;
return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
}
2010-11-12 12:18:58 +00:00
static void
_gdk_broadway_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
2010-11-15 19:08:18 +00:00
g_return_if_fail (GDK_IS_SURFACE (surface));
2010-11-12 12:18:58 +00:00
impl = GDK_BROADWAY_SURFACE (surface);
disconnect_frame_clock (surface);
if (impl->node_data)
g_array_unref (impl->node_data);
if (impl->node_data_textures)
g_ptr_array_unref (impl->node_data_textures);
_gdk_broadway_surface_grab_check_destroy (surface);
2010-11-12 12:18:58 +00:00
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
g_hash_table_remove (broadway_display->id_ht, GINT_TO_POINTER (impl->id));
_gdk_broadway_server_destroy_surface (broadway_display->server, impl->id);
2010-11-12 12:18:58 +00:00
}
void
gdk_broadway_surface_set_nodes (GdkSurface *surface,
GArray *nodes,
GPtrArray *node_textures)
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
g_return_if_fail (GDK_IS_SURFACE (surface));
impl = GDK_BROADWAY_SURFACE (surface);
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
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;
gdk_broadway_server_surface_set_nodes (broadway_display->server, impl->id, impl->node_data);
}
/* This function is called when the XSurface is really gone.
2010-11-12 12:18:58 +00:00
*/
static void
gdk_broadway_surface_destroy_notify (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
if (!GDK_SURFACE_DESTROYED (surface))
_gdk_surface_destroy (surface, TRUE);
2010-11-12 12:18:58 +00:00
g_object_unref (surface);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_show (GdkSurface *surface,
gboolean already_mapped)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
impl = GDK_BROADWAY_SURFACE (surface);
impl->visible = TRUE;
/* FIXME: update state ? */
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
if (_gdk_broadway_server_surface_show (broadway_display->server, impl->id))
queue_flush (surface);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_hide (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
2010-11-12 12:18:58 +00:00
impl = GDK_BROADWAY_SURFACE (surface);
impl->visible = FALSE;
2010-11-12 12:18:58 +00:00
/* FIXME: update state ? */
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
_gdk_broadway_surface_grab_check_unmap (surface,
_gdk_broadway_server_get_next_serial (broadway_display->server));
if (_gdk_broadway_server_surface_hide (broadway_display->server, impl->id))
queue_flush (surface);
_gdk_surface_clear_update_area (surface);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_withdraw (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
gdk_broadway_surface_hide (surface);
2010-11-12 12:18:58 +00:00
}
2010-11-21 19:46:50 +00:00
static void
gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
gboolean with_move,
gint x,
gint y,
gint width,
gint height)
{
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
GdkBroadwayDisplay *broadway_display;
gboolean size_changed;
2010-11-23 11:52:10 +00:00
size_changed = FALSE;
2010-11-15 19:08:18 +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)
width = 1;
2010-11-12 12:18:58 +00:00
2010-11-21 19:46:50 +00:00
if (height < 1)
height = 1;
2010-11-12 12:18:58 +00:00
if (width != surface->width ||
height != surface->height)
{
size_changed = TRUE;
/* Resize clears the content */
impl->dirty = TRUE;
impl->last_synced = FALSE;
surface->width = width;
surface->height = height;
}
2010-11-23 11:52:10 +00:00
}
if (surface->parent)
{
impl->offset_x = x - surface->parent->x;
impl->offset_y = y - surface->parent->y;
}
_gdk_broadway_server_surface_move_resize (broadway_display->server,
impl->id,
with_move,
x, y,
surface->width, surface->height);
queue_flush (surface);
if (size_changed)
{
surface->resize_count++;
_gdk_surface_update_size (surface);
}
2010-11-12 12:18:58 +00:00
}
void
gdk_broadway_surface_move_resize (GdkSurface *surface,
gint x,
gint y,
gint width,
gint height)
{
gdk_broadway_surface_move_resize_internal (surface, TRUE,
x, y,
width, height);
}
static void
gdk_broadway_surface_toplevel_resize (GdkSurface *surface,
gint width,
gint height)
{
gdk_broadway_surface_move_resize_internal (surface, FALSE,
0, 0,
width, height);
}
static void
gdk_broadway_surface_move (GdkSurface *surface,
gint x,
gint y)
{
gdk_broadway_surface_move_resize_internal (surface, TRUE, x, y, -1, -1);
}
static void
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
gdk_broadway_surface_layout_popup (GdkSurface *surface,
int width,
int height,
GdkPopupLayout *layout)
{
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
GdkRectangle final_rect;
int x, y;
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
gdk_surface_layout_popup_helper (surface,
width,
height,
layout,
&final_rect);
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
gdk_surface_get_origin (surface->parent, &x, &y);
x += final_rect.x;
y += final_rect.y;
if (final_rect.width != surface->width ||
final_rect.height != surface->height)
{
gdk_broadway_surface_move_resize (surface,
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
x,
y,
final_rect.width,
final_rect.height);
}
else
{
gdk_broadway_surface_move (surface, x, y);
}
}
static void
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
show_popup (GdkSurface *surface)
{
gdk_surface_raise (surface);
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
_gdk_surface_update_viewable (surface);
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);
}
2010-11-12 12:18:58 +00:00
static void
gdk_broadway_surface_raise (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
}
static void
gdk_broadway_surface_restack_toplevel (GdkSurface *surface,
GdkSurface *sibling,
gboolean above)
2010-11-12 12:18:58 +00:00
{
}
static void
gdk_broadway_surface_lower (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
}
static void
gdk_broadway_surface_focus (GdkSurface *surface,
guint32 timestamp)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_SURFACE_DESTROYED (surface) ||
!surface->accept_focus)
return;
impl = GDK_BROADWAY_SURFACE (surface);
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
_gdk_broadway_server_surface_focus (broadway_display->server,
impl->id);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_set_type_hint (GdkSurface *surface,
GdkSurfaceTypeHint hint)
2010-11-12 12:18:58 +00:00
{
}
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
static GdkSurfaceTypeHint
gdk_broadway_surface_get_type_hint (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
return GDK_SURFACE_TYPE_HINT_NORMAL;
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_set_modal_hint (GdkSurface *surface,
gboolean modal)
2010-11-12 12:18:58 +00:00
{
}
static void
gdk_broadway_surface_set_geometry_hints (GdkSurface *surface,
const GdkGeometry *geometry,
GdkSurfaceHints geom_mask)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
impl = GDK_BROADWAY_SURFACE (surface);
impl->geometry_hints = *geometry;
impl->geometry_hints_mask = geom_mask;
2010-11-12 12:18:58 +00:00
}
static void
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
static void
gdk_broadway_surface_set_startup_id (GdkSurface *surface,
const gchar *startup_id)
2010-11-12 12:18:58 +00:00
{
}
static void
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;
GdkBroadwaySurface *impl;
2011-04-05 10:02:46 +00:00
int parent_id;
impl = GDK_BROADWAY_SURFACE (surface);
2011-04-05 10:02:46 +00:00
parent_id = 0;
if (parent)
parent_id = GDK_BROADWAY_SURFACE (parent)->id;
2011-04-05 10:02:46 +00:00
impl->transient_for = parent_id;
display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
_gdk_broadway_server_surface_set_transient_for (display->server, impl->id, impl->transient_for);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_get_geometry (GdkSurface *surface,
gint *x,
gint *y,
gint *width,
gint *height)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_SURFACE (surface));
/* TODO: These should really roundtrip to the client to get the current data */
if (x)
*x = surface->x;
if (y)
*y = surface->y;
if (width)
*width = surface->width;
if (height)
*height = surface->height;
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_get_root_coords (GdkSurface *surface,
gint x,
gint y,
gint *root_x,
gint *root_y)
2010-11-12 12:18:58 +00:00
{
if (root_x)
*root_x = x + surface->x;
2010-11-12 12:18:58 +00:00
if (root_y)
*root_y = y + surface->y;
2010-11-12 12:18:58 +00:00
}
static gboolean
gdk_broadway_surface_get_device_state (GdkSurface *surface,
GdkDevice *device,
gdouble *x,
gdouble *y,
GdkModifierType *mask)
{
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
GdkSurface *child;
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
GDK_DEVICE_GET_CLASS (device)->query_state (device, surface,
&child,
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
gdk_broadway_surface_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
{
}
static void
gdk_broadway_surface_set_accept_focus (GdkSurface *surface,
gboolean accept_focus)
2010-11-12 12:18:58 +00:00
{
accept_focus = accept_focus != FALSE;
if (surface->accept_focus != accept_focus)
2010-11-12 12:18:58 +00:00
{
surface->accept_focus = accept_focus;
2010-11-12 12:18:58 +00:00
}
}
static void
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;
if (surface->focus_on_map != focus_on_map)
2010-11-12 12:18:58 +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
static void
gdk_broadway_surface_set_icon_list (GdkSurface *surface,
GList *surfaces)
2010-11-15 19:08:18 +00:00
{
}
static void
gdk_broadway_surface_set_icon_name (GdkSurface *surface,
const gchar *name)
2010-11-12 12:18:58 +00:00
{
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
2010-11-12 12:18:58 +00:00
return;
g_object_set_qdata (G_OBJECT (surface), g_quark_from_static_string ("gdk-icon-name-set"),
GUINT_TO_POINTER (name != NULL));
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_minimize (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
2010-11-12 12:18:58 +00:00
return;
}
static void
gdk_broadway_surface_unminimize (GdkSurface *surface)
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_stick (GdkSurface *surface)
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_unstick (GdkSurface *surface)
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_maximize (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle geom;
2015-06-26 11:49:23 +00:00
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
2010-11-12 12:18:58 +00:00
return;
impl = GDK_BROADWAY_SURFACE (surface);
2015-06-26 11:49:23 +00:00
if (impl->maximized)
return;
impl->maximized = TRUE;
gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_MAXIMIZED);
2015-06-26 11:49:23 +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
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_monitor (display, 0);
gdk_monitor_get_geometry (monitor, &geom);
2015-06-26 11:49:23 +00:00
gdk_broadway_surface_move_resize (surface,
geom.x, geom.y,
geom.width, geom.height);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_unmaximize (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
GdkBroadwaySurface *impl;
2015-06-26 11:49:23 +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
impl = GDK_BROADWAY_SURFACE (surface);
2015-06-26 11:49:23 +00:00
if (!impl->maximized)
return;
impl->maximized = FALSE;
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MAXIMIZED, 0);
2015-06-26 11:49:23 +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
}
static void
gdk_broadway_surface_fullscreen (GdkSurface *surface)
2010-11-12 12:18:58 +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
static void
gdk_broadway_surface_unfullscreen (GdkSurface *surface)
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_set_keep_above (GdkSurface *surface,
gboolean setting)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_SURFACE (surface));
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_set_keep_below (GdkSurface *surface, gboolean setting)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_SURFACE (surface));
2010-11-12 12:18:58 +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
}
static void
gdk_broadway_surface_set_decorations (GdkSurface *surface,
GdkWMDecoration decorations)
2010-11-12 12:18:58 +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
static gboolean
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
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
}
static void
gdk_broadway_surface_set_functions (GdkSurface *surface,
GdkWMFunction functions)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_SURFACE (surface));
2010-11-12 12:18:58 +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
}
void
gdk_broadway_surface_update_popups (GdkSurface *parent)
{
GList *l;
for (l = parent ->children; l; l = l->next)
{
GdkBroadwaySurface *popup_impl = l->data;
GdkSurface *popup = GDK_SURFACE (popup_impl);
int new_x = parent->x + popup_impl->offset_x;
int new_y = parent->y + popup_impl->offset_y;
if (new_x != popup->x || new_y != popup->y)
gdk_broadway_surface_move_resize (popup,
new_x, new_y,
popup->width, popup->height);
gdk_broadway_surface_restack_toplevel (popup, parent, TRUE);
}
}
typedef struct _MoveResizeData MoveResizeData;
struct _MoveResizeData
{
GdkDisplay *display;
GdkSurface *moveresize_surface;
GdkSurface *moveresize_emulation_surface;
gboolean is_resize;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
GdkSurfaceEdge resize_edge;
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;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
GdkSurfaceHints moveresize_geom_mask;
GdkGeometry moveresize_geometry;
BroadwayInputMsg *moveresize_pending_event;
};
static MoveResizeData *
get_move_resize_data (GdkDisplay *display,
gboolean create)
{
2013-03-28 16:38:44 +00:00
GdkBroadwayDisplay *broadway_display;
MoveResizeData *mv_resize;
2013-03-28 16:38:44 +00:00
broadway_display = GDK_BROADWAY_DISPLAY (display);
2013-03-28 16:38:44 +00:00
mv_resize = broadway_display->move_resize_data;
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;
}
return mv_resize;
}
static void
update_pos (MoveResizeData *mv_resize,
gint new_root_x,
gint new_root_y)
{
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)
{
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_NORTH_WEST:
x += dx;
y += dy;
w -= dx;
h -= dy;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_NORTH:
y += dy;
h -= dy;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_NORTH_EAST:
y += dy;
h -= dy;
w += dx;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_SOUTH_WEST:
h += dy;
x += dx;
w -= dx;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_SOUTH_EAST:
w += dx;
h += dy;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_SOUTH:
h += dy;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_EAST:
w += dx;
break;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
case GDK_SURFACE_EDGE_WEST:
x += dx;
w -= dx;
break;
default:
break;
}
x = MAX (x, 0);
y = MAX (y, 0);
w = MAX (w, 1);
h = MAX (h, 1);
if (mv_resize->moveresize_geom_mask)
{
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
gdk_surface_constrain_size (&mv_resize->moveresize_geometry,
mv_resize->moveresize_geom_mask,
w, h, &w, &h);
}
gdk_broadway_surface_move_resize (mv_resize->moveresize_surface,
x, y, w, h);
}
else
{
gint x, y;
x = mv_resize->moveresize_orig_x + dx;
y = mv_resize->moveresize_orig_y + dy;
gdk_broadway_surface_move (mv_resize->moveresize_surface, x, y);
}
}
static void
finish_drag (MoveResizeData *mv_resize)
{
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;
g_clear_pointer (&mv_resize->moveresize_pending_event, g_free);
}
static gboolean
moveresize_lookahead (GdkDisplay *display,
MoveResizeData *mv_resize,
BroadwayInputMsg *event)
{
GdkBroadwayDisplay *broadway_display;
broadway_display = GDK_BROADWAY_DISPLAY (display);
return !_gdk_broadway_server_lookahead_event (broadway_display->server, "mb");
}
gboolean
_gdk_broadway_moveresize_handle_event (GdkDisplay *display,
BroadwayInputMsg *event)
{
guint button_mask = 0;
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
if (!mv_resize || !mv_resize->moveresize_surface)
return FALSE;
button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
switch (event->base.type)
{
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 */
{
if (mv_resize->moveresize_surface->resize_count > 0)
{
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:
if (mv_resize->moveresize_surface->resize_count > 0)
{
if (mv_resize->moveresize_pending_event)
*mv_resize->moveresize_pending_event = *event;
else
mv_resize->moveresize_pending_event =
g_memdup (event, sizeof (BroadwayInputMsg));
break;
}
if (!moveresize_lookahead (display, mv_resize, event))
break;
update_pos (mv_resize,
event->pointer.root_x,
event->pointer.root_y);
/* 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)
finish_drag (mv_resize);
break;
2013-03-28 16:38:44 +00:00
case BROADWAY_EVENT_BUTTON_RELEASE:
update_pos (mv_resize,
event->pointer.root_x,
event->pointer.root_y);
if (event->button.button == mv_resize->moveresize_button)
finish_drag (mv_resize);
break;
default:
break;
}
return TRUE;
}
gboolean
_gdk_broadway_moveresize_configure_done (GdkDisplay *display,
GdkSurface *surface)
{
BroadwayInputMsg *tmp_event;
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
if (!mv_resize || surface != mv_resize->moveresize_surface)
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
create_moveresize_surface (MoveResizeData *mv_resize,
guint32 timestamp)
{
GdkGrabStatus status;
GdkSeat *seat;
GdkDevice *pointer;
GdkRectangle rect = { -100, -100, 1, 1 };
g_assert (mv_resize->moveresize_emulation_surface == NULL);
mv_resize->moveresize_emulation_surface = gdk_surface_new_temp (mv_resize->display, &rect);
gdk_surface_show (mv_resize->moveresize_emulation_surface);
seat = gdk_display_get_default_seat (mv_resize->display);
pointer = gdk_seat_get_pointer (seat);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
status = gdk_device_grab (pointer,
mv_resize->moveresize_emulation_surface,
GDK_OWNERSHIP_APPLICATION,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL,
timestamp);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (status != GDK_GRAB_SUCCESS)
{
/* If this fails, some other client has grabbed the surface
* already.
*/
finish_drag (mv_resize);
}
mv_resize->moveresize_process_time = 0;
}
static void
calculate_unmoving_origin (MoveResizeData *mv_resize)
{
gint x, y, width, height;
if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
{
gdk_surface_get_origin (mv_resize->moveresize_surface,
&mv_resize->moveresize_orig_x,
&mv_resize->moveresize_orig_y);
}
else
{
gdk_surface_get_geometry (mv_resize->moveresize_surface,
&x, &y, &width, &height);
switch (mv_resize->moveresize_geometry.win_gravity)
{
case GDK_GRAVITY_NORTH_WEST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_NORTH:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_NORTH_EAST:
mv_resize->moveresize_orig_x = x = width;
mv_resize->moveresize_orig_y = y;
break;
case GDK_GRAVITY_WEST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_CENTER:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_EAST:
mv_resize->moveresize_orig_x = x + width;
mv_resize->moveresize_orig_y = y + height / 2;
break;
case GDK_GRAVITY_SOUTH_WEST:
mv_resize->moveresize_orig_x = x + width;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_SOUTH:
mv_resize->moveresize_orig_x = x + width / 2;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_SOUTH_EAST:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y + height;
break;
case GDK_GRAVITY_STATIC:
default:
mv_resize->moveresize_orig_x = x;
mv_resize->moveresize_orig_y = y;
break;
}
}
}
static void
gdk_broadway_surface_begin_resize_drag (GdkSurface *surface,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
guint32 timestamp)
2010-11-12 12:18:58 +00:00
{
MoveResizeData *mv_resize;
GdkBroadwaySurface *impl;
impl = GDK_BROADWAY_SURFACE (surface);
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;
mv_resize = get_move_resize_data (gdk_surface_get_display (surface), TRUE);
if (mv_resize->moveresize_surface != NULL)
return; /* already a drag operation in progress */
mv_resize->is_resize = TRUE;
mv_resize->moveresize_button = button;
mv_resize->resize_edge = edge;
mv_resize->moveresize_x = x + surface->x;
mv_resize->moveresize_y = y + surface->y;
mv_resize->moveresize_surface = g_object_ref (surface);
mv_resize->moveresize_orig_width = gdk_surface_get_width (surface);
mv_resize->moveresize_orig_height = gdk_surface_get_height (surface);
mv_resize->moveresize_geom_mask = impl->geometry_hints_mask;
mv_resize->moveresize_geometry = impl->geometry_hints;
calculate_unmoving_origin (mv_resize);
create_moveresize_surface (mv_resize, timestamp);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_begin_move_drag (GdkSurface *surface,
GdkDevice *device,
gint button,
gint x,
gint y,
guint32 timestamp)
2010-11-12 12:18:58 +00:00
{
MoveResizeData *mv_resize;
GdkBroadwaySurface *impl;
impl = GDK_BROADWAY_SURFACE (surface);
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;
mv_resize = get_move_resize_data (gdk_surface_get_display (surface), TRUE);
if (mv_resize->moveresize_surface != NULL)
return; /* already a drag operation in progress */
mv_resize->is_resize = FALSE;
mv_resize->moveresize_button = button;
mv_resize->moveresize_x = x + surface->x;
mv_resize->moveresize_y = y + surface->y;
mv_resize->moveresize_surface = g_object_ref (surface);
mv_resize->moveresize_orig_width = gdk_surface_get_width (surface);
mv_resize->moveresize_orig_height = gdk_surface_get_height (surface);
mv_resize->moveresize_geom_mask = impl->geometry_hints_mask;
mv_resize->moveresize_geometry = impl->geometry_hints;
calculate_unmoving_origin (mv_resize);
create_moveresize_surface (mv_resize, timestamp);
2010-11-12 12:18:58 +00:00
}
static gboolean
gdk_broadway_surface_beep (GdkSurface *surface)
2010-11-12 12:18:58 +00:00
{
return FALSE;
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_surface_set_opacity (GdkSurface *surface,
gdouble opacity)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_SURFACE (surface));
2010-11-12 12:18:58 +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;
}
guint32
gdk_broadway_get_last_seen_time (GdkSurface *surface)
{
GdkDisplay *display;
display = gdk_surface_get_display (surface);
return _gdk_broadway_server_get_last_seen_time (GDK_BROADWAY_DISPLAY (display)->server);
}
2010-11-12 12:18:58 +00:00
static void
gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
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->show = gdk_broadway_surface_show;
impl_class->hide = gdk_broadway_surface_hide;
impl_class->withdraw = gdk_broadway_surface_withdraw;
impl_class->raise = gdk_broadway_surface_raise;
impl_class->lower = gdk_broadway_surface_lower;
impl_class->restack_toplevel = gdk_broadway_surface_restack_toplevel;
impl_class->toplevel_resize = gdk_broadway_surface_toplevel_resize;
gdk/surface: Replace move_to_rect() with GdkPopupLayout based API Replace the gdk_surface_move_to_rect() API with a new GdkSurface method called gdk_surface_present_popup() taking a new GdkPopupLayout object describing how they should be laid out on screen. The layout properties provided are the same as the ones used with gdk_surface_move_to_rect(), except they are now set up using GdkPopupLayout. Calling gdk_surface_present_popup() will either show the popup at the position described using the popup layout object and a new unconstrained size, or reposition it accordingly. In some situations, such as when a popup is set to autohide, presenting may immediately fail, in case the grab was not granted by the display server. After a successful present, the result of the layout can be queried using the following methods: * gdk_surface_get_position() - to get the position relative to its parent * gdk_surface_get_width() - to get the current width * gdk_surface_get_height() - to get the current height * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor rectangle the popup was effectively positioned against given constraints defined by the environment and the layout rules provided via GdkPopupLayout. * gdk_surface_get_surface_anchor() - the same as the one above but for the surface anchor. A new signal replaces the old "moved-to-rect" one - "popup-layout-changed". However, it is only intended to be emitted when the layout changes implicitly by the windowing system, for example if the monitor resolution changed, or the parent window moved.
2020-02-16 11:59:24 +00:00
impl_class->present_popup = gdk_broadway_surface_present_popup;
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;
impl_class->input_shape_combine_region = gdk_broadway_surface_input_shape_combine_region;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
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_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->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->minimize = gdk_broadway_surface_minimize;
impl_class->unminimize = gdk_broadway_surface_unminimize;
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
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->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
}