gtk2/gdk/broadway/gdkdisplay-broadway.c

424 lines
13 KiB
C
Raw Normal View History

2010-11-12 12:18:58 +00:00
/* GDK - The GIMP Drawing Kit
* gdkdisplay-broadway.c
2010-11-12 12:18:58 +00:00
*
* Copyright 2001 Sun Microsystems Inc.
* Copyright (C) 2004 Nokia Corporation
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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
*/
#include "config.h"
#include "gdkdisplay-broadway.h"
gdk: Add Cairo context implementations for all backends And make the GdkCairoContext as abstract. The idea of this and thje following commits is to get rid of all Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c) by moving that code into the Cairo context files. In particular, the GdkSurfaceClass.begin_frame/end_frame() functions (which are currently exclusively used by the Cairo code should end up being moved to GdkDrawContextClass.begin/end_frame(). This has multiple benefits: 1. It unifies code between the different drawing contexts. GL lives in GLContext, Vulkan in VulkanContext and Cairo in CairoContext. In turn, this makes it way easier to reason about what's going on in surface-specific code. Currently pretty much all backends do things wrong when they want to sync to drawing or to the frame clock. 2. It makes the API of GdkSurface smaller. No drawing code (apart from creating the contexts) needs to remain. 3. It confines Cairo to the Drawcontext, thereby making it way more obvious when backends are still using it in situations where it may now conflict with OpenGL (like when doing the dnd failed animation or in the APIs that I'm removing in this branch). 4. We have 2 very different types of Cairo contexts: The X/win32 model, where we have a natively supported Cairo backend but do double buffering ourselves and use similar surfaces and the Wayland/Broadway model where we use image surfaces without any Cairo backend support and have to submit the buffers manually. By not sharing code between those 2 versions, we can make the actual code way smaller. We also get around the need to create 1x1 image surfaces in the Wayland backend where we pretend there's a native Cairo surface.
2018-04-12 14:48:31 +00:00
#include "gdkcairocontext-broadway.h"
2010-11-12 12:18:58 +00:00
#include "gdkdisplay.h"
#include "gdkeventsource.h"
2016-04-03 03:42:40 +00:00
#include "gdkmonitor-broadway.h"
#include "gdkseatdefaultprivate.h"
#include "gdkdevice-broadway.h"
2010-11-12 12:18:58 +00:00
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
#include <gdk/gdktextureprivate.h>
2010-11-12 12:18:58 +00:00
#include <glib.h>
#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
2010-11-12 12:18:58 +00:00
#include <unistd.h>
#endif
#include <sys/types.h>
2010-11-12 12:18:58 +00:00
static void gdk_broadway_display_dispose (GObject *object);
static void gdk_broadway_display_finalize (GObject *object);
2010-11-12 12:18:58 +00:00
#if 0
#define DEBUG_WEBSOCKETS 1
#endif
G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY)
2010-11-12 12:18:58 +00:00
static void
gdk_broadway_display_init (GdkBroadwayDisplay *display)
2010-11-12 12:18:58 +00:00
{
2010-11-20 21:38:34 +00:00
display->id_ht = g_hash_table_new (NULL, NULL);
2016-04-03 03:42:40 +00:00
display->monitor = g_object_new (GDK_TYPE_BROADWAY_MONITOR,
"display", display,
NULL);
gdk_monitor_set_manufacturer (display->monitor, "browser");
gdk_monitor_set_model (display->monitor, "0");
2010-11-12 12:18:58 +00:00
}
static void
gdk_event_init (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
GdkBroadwayDisplay *broadway_display;
2010-11-12 12:18:58 +00:00
broadway_display = GDK_BROADWAY_DISPLAY (display);
broadway_display->event_source = _gdk_broadway_event_source_new (display);
2010-11-12 12:18:58 +00:00
}
void
_gdk_broadway_display_size_changed (GdkDisplay *display,
BroadwayInputScreenResizeNotify *msg)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
GdkMonitor *monitor;
GdkRectangle size;
GList *toplevels, *l;
monitor = broadway_display->monitor;
gdk_monitor_get_geometry (monitor, &size);
if (msg->width == size.width && msg->height == size.height)
return;
gdk_monitor_set_size (monitor, msg->width, msg->height);
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
toplevels = broadway_display->toplevels;
for (l = toplevels; l != NULL; l = l->next)
{
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
GdkSurfaceImplBroadway *toplevel_impl = l->data;
if (toplevel_impl->maximized)
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_move_resize (toplevel_impl->wrapper, 0, 0, msg->width, msg->height);
}
}
static GdkDevice *
create_core_pointer (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Pointer",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_MOUSE,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", TRUE,
"display", display,
NULL);
}
static GdkDevice *
create_core_keyboard (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Keyboard",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_KEYBOARD,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", FALSE,
"display", display,
NULL);
}
static GdkDevice *
create_touchscreen (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Touchscreen",
"type", GDK_DEVICE_TYPE_SLAVE,
"input-source", GDK_SOURCE_TOUCHSCREEN,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", FALSE,
"display", display,
NULL);
}
2010-11-12 12:18:58 +00:00
GdkDisplay *
_gdk_broadway_display_open (const gchar *display_name)
2010-11-12 12:18:58 +00:00
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GError *error = NULL;
GdkSeat *seat;
display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
broadway_display = GDK_BROADWAY_DISPLAY (display);
2010-11-12 12:18:58 +00:00
broadway_display->core_pointer = create_core_pointer (display);
broadway_display->core_keyboard = create_core_keyboard (display);
broadway_display->touchscreen = create_touchscreen (display);
_gdk_device_set_associated_device (broadway_display->core_pointer, broadway_display->core_keyboard);
_gdk_device_set_associated_device (broadway_display->core_keyboard, broadway_display->core_pointer);
_gdk_device_set_associated_device (broadway_display->touchscreen, broadway_display->core_pointer);
_gdk_device_add_slave (broadway_display->core_pointer, broadway_display->touchscreen);
seat = gdk_seat_default_new_for_master_pair (broadway_display->core_pointer,
broadway_display->core_keyboard);
gdk_display_add_seat (display, seat);
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
g_object_unref (seat);
gdk_event_init (display);
2010-11-12 12:18:58 +00:00
_gdk_broadway_display_init_dnd (display);
2010-11-12 12:18:58 +00:00
if (display_name == NULL)
display_name = g_getenv ("BROADWAY_DISPLAY");
broadway_display->server = _gdk_broadway_server_new (display_name, &error);
if (broadway_display->server == NULL)
2010-11-18 12:17:23 +00:00
{
g_printerr ("Unable to init Broadway server: %s\n", error->message);
g_error_free (error);
2010-11-18 12:17:23 +00:00
return NULL;
}
2010-11-12 12:18:58 +00:00
g_signal_emit_by_name (display, "opened");
return display;
}
2011-06-06 18:05:18 +00:00
static const gchar *
gdk_broadway_display_get_name (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2010-11-15 19:08:18 +00:00
return (gchar *) "Broadway";
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_beep (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
g_return_if_fail (GDK_IS_DISPLAY (display));
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_sync (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
_gdk_broadway_server_sync (broadway_display->server);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_flush (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
2011-03-11 13:37:39 +00:00
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
2010-11-15 19:08:18 +00:00
_gdk_broadway_server_flush (broadway_display->server);
2010-11-12 12:18:58 +00:00
}
static gboolean
gdk_broadway_display_has_pending (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
return FALSE;
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 GdkSurface *
gdk_broadway_display_get_default_group (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2010-11-15 19:08:18 +00:00
return NULL;
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_dispose (GObject *object)
2010-11-12 12:18:58 +00:00
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
2010-11-12 12:18:58 +00:00
if (broadway_display->event_source)
2010-11-12 12:18:58 +00:00
{
g_source_destroy (broadway_display->event_source);
g_source_unref (broadway_display->event_source);
broadway_display->event_source = NULL;
2010-11-12 12:18:58 +00:00
}
G_OBJECT_CLASS (gdk_broadway_display_parent_class)->dispose (object);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_finalize (GObject *object)
2010-11-12 12:18:58 +00:00
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
2010-11-12 12:18:58 +00:00
/* Keymap */
if (broadway_display->keymap)
g_object_unref (broadway_display->keymap);
2010-11-12 12:18:58 +00:00
_gdk_broadway_cursor_display_finalize (GDK_DISPLAY(broadway_display));
2010-11-12 12:18:58 +00:00
2016-04-03 03:42:40 +00:00
g_object_unref (broadway_display->monitor);
G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
2010-11-12 12:18:58 +00:00
}
static void
gdk_broadway_display_notify_startup_complete (GdkDisplay *display,
const gchar *startup_id)
2010-11-12 12:18:58 +00:00
{
}
static gboolean
gdk_broadway_display_supports_shapes (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
2010-11-15 19:08:18 +00:00
return FALSE;
2010-11-12 12:18:58 +00:00
}
static gboolean
gdk_broadway_display_supports_input_shapes (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
2010-11-15 19:08:18 +00:00
return FALSE;
2010-11-12 12:18:58 +00:00
}
static gulong
gdk_broadway_display_get_next_serial (GdkDisplay *display)
2010-11-12 12:18:58 +00:00
{
GdkBroadwayDisplay *broadway_display;
broadway_display = GDK_BROADWAY_DISPLAY (display);
2010-11-12 12:18:58 +00:00
return _gdk_broadway_server_get_next_serial (broadway_display->server);
}
void
gdk_broadway_display_show_keyboard (GdkBroadwayDisplay *display)
{
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
_gdk_broadway_server_set_show_keyboard (display->server, TRUE);
}
void
gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display)
{
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
_gdk_broadway_server_set_show_keyboard (display->server, FALSE);
}
2016-04-03 03:42:40 +00:00
static int
gdk_broadway_display_get_n_monitors (GdkDisplay *display)
{
return 1;
}
static GdkMonitor *
gdk_broadway_display_get_monitor (GdkDisplay *display,
int monitor_num)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
if (monitor_num == 0)
return broadway_display->monitor;
return NULL;
}
static GdkMonitor *
gdk_broadway_display_get_primary_monitor (GdkDisplay *display)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
return broadway_display->monitor;
}
static gboolean
gdk_broadway_display_get_setting (GdkDisplay *display,
const char *name,
GValue *value)
{
return FALSE;
}
static guint32
gdk_broadway_display_get_last_seen_time (GdkDisplay *display)
{
return _gdk_broadway_server_get_last_seen_time (GDK_BROADWAY_DISPLAY (display)->server);
}
typedef struct {
int id;
GdkDisplay *display;
GList *textures;
} BroadwayTextureData;
static void
broadway_texture_data_free (BroadwayTextureData *data)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (data->display);
gdk_broadway_server_release_texture (broadway_display->server, data->id);
g_object_unref (data->display);
g_free (data);
}
guint32
gdk_broadway_display_ensure_texture (GdkDisplay *display,
GdkTexture *texture)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
BroadwayTextureData *data;
data = g_object_get_data (G_OBJECT (texture), "broadway-data");
if (data == NULL)
{
guint32 id = gdk_broadway_server_upload_texture (broadway_display->server, texture);
data = g_new0 (BroadwayTextureData, 1);
data->id = id;
data->display = g_object_ref (display);
g_object_set_data_full (G_OBJECT (texture), "broadway-data", data, (GDestroyNotify)broadway_texture_data_free);
}
return data->id;
}
static void
gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
2010-11-12 12:18:58 +00:00
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
object_class->dispose = gdk_broadway_display_dispose;
object_class->finalize = gdk_broadway_display_finalize;
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
display_class->surface_type = GDK_TYPE_BROADWAY_SURFACE;
gdk: Add Cairo context implementations for all backends And make the GdkCairoContext as abstract. The idea of this and thje following commits is to get rid of all Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c) by moving that code into the Cairo context files. In particular, the GdkSurfaceClass.begin_frame/end_frame() functions (which are currently exclusively used by the Cairo code should end up being moved to GdkDrawContextClass.begin/end_frame(). This has multiple benefits: 1. It unifies code between the different drawing contexts. GL lives in GLContext, Vulkan in VulkanContext and Cairo in CairoContext. In turn, this makes it way easier to reason about what's going on in surface-specific code. Currently pretty much all backends do things wrong when they want to sync to drawing or to the frame clock. 2. It makes the API of GdkSurface smaller. No drawing code (apart from creating the contexts) needs to remain. 3. It confines Cairo to the Drawcontext, thereby making it way more obvious when backends are still using it in situations where it may now conflict with OpenGL (like when doing the dnd failed animation or in the APIs that I'm removing in this branch). 4. We have 2 very different types of Cairo contexts: The X/win32 model, where we have a natively supported Cairo backend but do double buffering ourselves and use similar surfaces and the Wayland/Broadway model where we use image surfaces without any Cairo backend support and have to submit the buffers manually. By not sharing code between those 2 versions, we can make the actual code way smaller. We also get around the need to create 1x1 image surfaces in the Wayland backend where we pretend there's a native Cairo surface.
2018-04-12 14:48:31 +00:00
display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
display_class->get_name = gdk_broadway_display_get_name;
display_class->beep = gdk_broadway_display_beep;
display_class->sync = gdk_broadway_display_sync;
display_class->flush = gdk_broadway_display_flush;
display_class->has_pending = gdk_broadway_display_has_pending;
display_class->queue_events = _gdk_broadway_display_queue_events;
display_class->get_default_group = gdk_broadway_display_get_default_group;
display_class->supports_shapes = gdk_broadway_display_supports_shapes;
display_class->supports_input_shapes = gdk_broadway_display_supports_input_shapes;
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
display_class->create_surface_impl = _gdk_broadway_display_create_surface_impl;
display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
2016-04-03 03:42:40 +00:00
display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
display_class->get_monitor = gdk_broadway_display_get_monitor;
display_class->get_primary_monitor = gdk_broadway_display_get_primary_monitor;
display_class->get_setting = gdk_broadway_display_get_setting;
display_class->get_last_seen_time = gdk_broadway_display_get_last_seen_time;
2010-11-12 12:18:58 +00:00
}