2010-11-12 12:18:58 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
2010-11-16 11:33:02 +00:00
|
|
|
* 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"
|
|
|
|
|
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"
|
2017-11-29 17:11:45 +00:00
|
|
|
#include "gdkseatdefaultprivate.h"
|
|
|
|
#include "gdkdevice-broadway.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
2017-11-18 19:36:57 +00:00
|
|
|
#include <gdk/gdktextureprivate.h>
|
2022-09-24 03:23:27 +00:00
|
|
|
#include "gdkprivate.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>
|
2013-07-01 12:51:03 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2010-11-12 12:18:58 +00:00
|
|
|
#include <unistd.h>
|
2013-07-01 12:51:03 +00:00
|
|
|
#endif
|
2011-04-18 17:52:05 +00:00
|
|
|
#include <sys/types.h>
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +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
|
|
|
|
2011-11-10 09:12:28 +00:00
|
|
|
#if 0
|
|
|
|
#define DEBUG_WEBSOCKETS 1
|
|
|
|
#endif
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY)
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_display_init (GdkBroadwayDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-05-18 02:05:24 +00:00
|
|
|
gdk_display_set_input_shapes (GDK_DISPLAY (display), FALSE);
|
|
|
|
|
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");
|
2020-03-12 10:12:01 +00:00
|
|
|
display->scale_factor = 1;
|
2020-05-17 03:23:16 +00:00
|
|
|
gdk_monitor_set_geometry (display->monitor, &(GdkRectangle) { 0, 0, 1024, 768 });
|
2020-03-12 10:12:01 +00:00
|
|
|
gdk_monitor_set_physical_size (display->monitor, 1024 * 25.4 / 96, 768 * 25.4 / 96);
|
|
|
|
gdk_monitor_set_scale_factor (display->monitor, 1);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_event_init (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +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
|
|
|
}
|
|
|
|
|
2017-11-01 18:46:26 +00:00
|
|
|
void
|
|
|
|
_gdk_broadway_display_size_changed (GdkDisplay *display,
|
|
|
|
BroadwayInputScreenResizeNotify *msg)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
GdkMonitor *monitor;
|
2020-03-12 10:12:01 +00:00
|
|
|
GdkRectangle current_size;
|
2017-11-01 18:46:26 +00:00
|
|
|
GList *toplevels, *l;
|
|
|
|
|
|
|
|
monitor = broadway_display->monitor;
|
2020-03-12 10:12:01 +00:00
|
|
|
gdk_monitor_get_geometry (monitor, ¤t_size);
|
2017-11-01 18:46:26 +00:00
|
|
|
|
2020-03-12 10:12:01 +00:00
|
|
|
if (msg->width == current_size.width &&
|
|
|
|
msg->height == current_size.height &&
|
2021-05-09 23:42:42 +00:00
|
|
|
(msg->scale == broadway_display->scale_factor ||
|
|
|
|
broadway_display->fixed_scale))
|
2017-11-01 18:46:26 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-09 23:42:42 +00:00
|
|
|
if (!broadway_display->fixed_scale)
|
|
|
|
broadway_display->scale_factor = msg->scale;
|
2020-03-12 10:12:01 +00:00
|
|
|
|
2020-05-17 03:23:16 +00:00
|
|
|
gdk_monitor_set_geometry (monitor, &(GdkRectangle) { 0, 0, msg->width, msg->height });
|
2020-03-12 10:12:01 +00:00
|
|
|
gdk_monitor_set_scale_factor (monitor, msg->scale);
|
2017-11-01 18:46:26 +00:00
|
|
|
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
|
|
|
|
|
2017-11-05 23:19:04 +00:00
|
|
|
toplevels = broadway_display->toplevels;
|
2017-11-01 18:46:26 +00:00
|
|
|
for (l = toplevels; l != NULL; l = l->next)
|
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkBroadwaySurface *toplevel = l->data;
|
2017-11-01 18:46:26 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
if (toplevel->maximized)
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_broadway_surface_move_resize (GDK_SURFACE (toplevel),
|
|
|
|
0, 0,
|
|
|
|
msg->width, msg->height);
|
2021-05-09 23:32:36 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-01 18:46:26 +00:00
|
|
|
|
2017-11-29 17:11:45 +00:00
|
|
|
static GdkDevice *
|
2020-05-16 16:27:22 +00:00
|
|
|
create_core_pointer (GdkDisplay *display)
|
2017-11-29 17:11:45 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Core Pointer",
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_MOUSE,
|
2017-11-29 17:11:45 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
2020-05-16 16:27:22 +00:00
|
|
|
create_core_keyboard (GdkDisplay *display)
|
2017-11-29 17:11:45 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Core Keyboard",
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_KEYBOARD,
|
2017-11-29 17:11:45 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
2020-05-16 16:27:22 +00:00
|
|
|
create_pointer (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Pointer",
|
|
|
|
"source", GDK_SOURCE_MOUSE,
|
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
|
|
|
create_keyboard (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Keyboard",
|
|
|
|
"source", GDK_SOURCE_KEYBOARD,
|
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
|
|
|
create_touchscreen (GdkDisplay *display)
|
2017-11-29 17:11:45 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Touchscreen",
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_TOUCHSCREEN,
|
2017-11-29 17:11:45 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
2017-11-01 18:46:26 +00:00
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
GdkDisplay *
|
2020-07-24 18:40:36 +00:00
|
|
|
_gdk_broadway_display_open (const char *display_name)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
2014-03-02 16:59:34 +00:00
|
|
|
GError *error = NULL;
|
2017-11-29 17:11:45 +00:00
|
|
|
GdkSeat *seat;
|
2010-11-16 21:11:53 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2017-11-29 17:11:45 +00:00
|
|
|
broadway_display->core_pointer = create_core_pointer (display);
|
|
|
|
broadway_display->core_keyboard = create_core_keyboard (display);
|
2020-05-16 16:27:22 +00:00
|
|
|
broadway_display->pointer = create_pointer (display);
|
|
|
|
broadway_display->keyboard = create_keyboard (display);
|
2017-11-29 17:11:45 +00:00
|
|
|
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);
|
2020-05-16 16:27:22 +00:00
|
|
|
_gdk_device_set_associated_device (broadway_display->pointer, broadway_display->core_pointer);
|
|
|
|
_gdk_device_set_associated_device (broadway_display->keyboard, broadway_display->core_keyboard);
|
2017-11-29 17:11:45 +00:00
|
|
|
_gdk_device_set_associated_device (broadway_display->touchscreen, broadway_display->core_pointer);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_add_physical_device (broadway_display->core_pointer, broadway_display->touchscreen);
|
2017-11-29 17:11:45 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
seat = gdk_seat_default_new_for_logical_pair (broadway_display->core_pointer,
|
|
|
|
broadway_display->core_keyboard);
|
2020-05-16 16:27:22 +00:00
|
|
|
|
2017-11-29 17:11:45 +00:00
|
|
|
gdk_display_add_seat (display, seat);
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->pointer);
|
|
|
|
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->keyboard);
|
|
|
|
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
|
2017-11-29 17:11:45 +00:00
|
|
|
g_object_unref (seat);
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_event_init (display);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-03-14 14:58:55 +00:00
|
|
|
if (display_name == NULL)
|
|
|
|
display_name = g_getenv ("BROADWAY_DISPLAY");
|
|
|
|
|
2019-03-29 10:03:38 +00:00
|
|
|
broadway_display->server = _gdk_broadway_server_new (display, display_name, &error);
|
2012-12-19 11:37:02 +00:00
|
|
|
if (broadway_display->server == NULL)
|
2010-11-18 12:17:23 +00:00
|
|
|
{
|
2022-09-23 00:49:16 +00:00
|
|
|
GDK_DEBUG (MISC, "Unable to init Broadway server: %s", error->message);
|
2014-03-02 16:59:34 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static const char *
|
2011-01-06 22:36:44 +00:00
|
|
|
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
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
return (char *) "Broadway";
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_display_beep (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_display_sync (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2012-12-19 11:37:02 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
2011-01-06 22:36:44 +00:00
|
|
|
|
2012-12-19 11:37:02 +00:00
|
|
|
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
|
|
|
|
|
|
|
|
_gdk_broadway_server_sync (broadway_display->server);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +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);
|
|
|
|
|
2012-12-19 11:37:02 +00:00
|
|
|
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
|
2010-11-15 19:08:18 +00:00
|
|
|
|
2012-12-19 11:37:02 +00:00
|
|
|
_gdk_broadway_server_flush (broadway_display->server);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_broadway_display_has_pending (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
return FALSE;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_display_dispose (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-05-13 05:00:35 +00:00
|
|
|
GdkBroadwayDisplay *self = GDK_BROADWAY_DISPLAY (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2020-05-13 05:00:35 +00:00
|
|
|
if (self->event_source)
|
|
|
|
{
|
|
|
|
g_source_destroy (self->event_source);
|
|
|
|
g_source_unref (self->event_source);
|
|
|
|
self->event_source = NULL;
|
|
|
|
}
|
|
|
|
if (self->monitors)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2020-05-13 05:00:35 +00:00
|
|
|
g_list_store_remove_all (self->monitors);
|
|
|
|
g_clear_object (&self->monitors);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
G_OBJECT_CLASS (gdk_broadway_display_parent_class)->dispose (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_display_finalize (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
/* Keymap */
|
2011-01-06 22:36:44 +00:00
|
|
|
if (broadway_display->keymap)
|
|
|
|
g_object_unref (broadway_display->keymap);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2016-10-25 20:01:50 +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);
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_display_notify_startup_complete (GdkDisplay *display,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *startup_id)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static gulong
|
|
|
|
gdk_broadway_display_get_next_serial (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-03-10 13:58:47 +00:00
|
|
|
GdkBroadwayDisplay *broadway_display;
|
|
|
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2012-12-19 11:37:02 +00:00
|
|
|
return _gdk_broadway_server_get_next_serial (broadway_display->server);
|
|
|
|
}
|
2011-01-06 22:36:44 +00:00
|
|
|
|
2013-11-13 11:20:07 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-05-09 23:42:42 +00:00
|
|
|
/**
|
|
|
|
* gdk_broadway_display_set_surface_scale:
|
|
|
|
* @display: (type GdkBroadwayDisplay): the display
|
|
|
|
* @scale: The new scale value, as an integer >= 1
|
|
|
|
*
|
|
|
|
* Forces a specific window scale for all windows on this display,
|
|
|
|
* instead of using the default or user configured scale. This
|
|
|
|
* is can be used to disable scaling support by setting @scale to
|
|
|
|
* 1, or to programmatically set the window scale.
|
|
|
|
*
|
|
|
|
* Once the scale is set by this call it will not change in
|
|
|
|
* response to later user configuration changes.
|
|
|
|
*
|
|
|
|
* Since: 4.4
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_broadway_display_set_surface_scale (GdkDisplay *display,
|
|
|
|
int scale)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *self;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
|
|
|
|
g_return_if_fail (scale > 0);
|
|
|
|
|
|
|
|
self = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
|
|
|
self->scale_factor = scale;
|
|
|
|
self->fixed_scale = TRUE;
|
|
|
|
gdk_monitor_set_scale_factor (self->monitor, scale);
|
|
|
|
}
|
|
|
|
|
2021-06-17 18:40:10 +00:00
|
|
|
/**
|
|
|
|
* gdk_broadway_display_get_surface_scale:
|
|
|
|
* @display: (type GdkBroadwayDisplay): the display
|
|
|
|
*
|
|
|
|
* Gets the surface scale that was previously set by the client or
|
|
|
|
* gdk_broadway_display_set_surface_scale().
|
|
|
|
*
|
|
|
|
* Returns: the scale for surfaces
|
|
|
|
*
|
|
|
|
* Since: 4.4
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
gdk_broadway_display_get_surface_scale (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *self;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_BROADWAY_DISPLAY (display), 1);
|
|
|
|
|
|
|
|
self = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
|
|
|
return self->scale_factor;
|
|
|
|
}
|
|
|
|
|
2020-05-13 05:00:35 +00:00
|
|
|
static GListModel *
|
|
|
|
gdk_broadway_display_get_monitors (GdkDisplay *display)
|
2016-04-03 03:42:40 +00:00
|
|
|
{
|
2020-05-13 05:00:35 +00:00
|
|
|
GdkBroadwayDisplay *self = GDK_BROADWAY_DISPLAY (display);
|
2016-04-03 03:42:40 +00:00
|
|
|
|
2020-05-13 05:00:35 +00:00
|
|
|
if (self->monitors == NULL)
|
|
|
|
{
|
|
|
|
self->monitors = g_list_store_new (GDK_TYPE_MONITOR);
|
|
|
|
g_list_store_append (self->monitors, self->monitor);
|
|
|
|
}
|
2016-04-03 03:42:40 +00:00
|
|
|
|
2020-05-13 05:00:35 +00:00
|
|
|
return G_LIST_MODEL (self->monitors);
|
2016-04-03 03:42:40 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 20:43:13 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_broadway_display_get_setting (GdkDisplay *display,
|
|
|
|
const char *name,
|
|
|
|
GValue *value)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-11-21 18:33:12 +00:00
|
|
|
typedef struct {
|
|
|
|
int id;
|
|
|
|
GdkDisplay *display;
|
2017-11-29 17:16:24 +00:00
|
|
|
GList *textures;
|
2017-11-21 18:33:12 +00:00
|
|
|
} BroadwayTextureData;
|
|
|
|
|
|
|
|
static void
|
2018-04-24 13:39:53 +00:00
|
|
|
broadway_texture_data_free (BroadwayTextureData *data)
|
2017-11-21 18:33:12 +00:00
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (data->display);
|
|
|
|
|
2018-04-24 13:39:53 +00:00
|
|
|
gdk_broadway_server_release_texture (broadway_display->server, data->id);
|
|
|
|
g_object_unref (data->display);
|
|
|
|
g_free (data);
|
2017-11-21 18:33:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guint32
|
|
|
|
gdk_broadway_display_ensure_texture (GdkDisplay *display,
|
|
|
|
GdkTexture *texture)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
BroadwayTextureData *data;
|
|
|
|
|
2017-11-29 17:16:24 +00:00
|
|
|
data = g_object_get_data (G_OBJECT (texture), "broadway-data");
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
2018-04-24 13:39:53 +00:00
|
|
|
guint32 id = gdk_broadway_server_upload_texture (broadway_display->server, texture);
|
2017-11-29 17:16:24 +00:00
|
|
|
|
|
|
|
data = g_new0 (BroadwayTextureData, 1);
|
|
|
|
data->id = id;
|
|
|
|
data->display = g_object_ref (display);
|
2019-03-25 13:15:49 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (texture), "broadway-data", data, (GDestroyNotify)broadway_texture_data_free);
|
2017-11-29 17:16:24 +00:00
|
|
|
}
|
2017-11-21 18:33:12 +00:00
|
|
|
|
2017-11-29 17:16:24 +00:00
|
|
|
return data->id;
|
2017-11-21 18:33:12 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 10:13:24 +00:00
|
|
|
static gboolean
|
|
|
|
flush_idle (gpointer data)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = data;
|
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
|
|
|
broadway_display->idle_flush_id = 0;
|
|
|
|
gdk_display_flush (display);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_broadway_display_flush_in_idle (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
|
|
|
|
|
|
|
if (broadway_display->idle_flush_id == 0)
|
|
|
|
{
|
|
|
|
broadway_display->idle_flush_id = g_idle_add (flush_idle, g_object_ref (display));
|
2021-07-26 21:03:15 +00:00
|
|
|
gdk_source_set_static_name_by_id (broadway_display->idle_flush_id, "[gtk] flush_idle");
|
2019-03-29 10:13:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void
|
|
|
|
gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +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;
|
|
|
|
|
2023-04-21 03:41:48 +00:00
|
|
|
display_class->toplevel_type = GDK_TYPE_BROADWAY_TOPLEVEL;
|
|
|
|
display_class->popup_type = GDK_TYPE_BROADWAY_POPUP;
|
2018-04-12 14:48:31 +00:00
|
|
|
display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
|
2011-01-06 22:36:44 +00:00
|
|
|
|
|
|
|
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_next_serial = gdk_broadway_display_get_next_serial;
|
|
|
|
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
|
|
|
|
display_class->get_keymap = _gdk_broadway_display_get_keymap;
|
2016-04-03 03:42:40 +00:00
|
|
|
|
2020-05-13 05:00:35 +00:00
|
|
|
display_class->get_monitors = gdk_broadway_display_get_monitors;
|
2017-10-30 20:43:13 +00:00
|
|
|
display_class->get_setting = gdk_broadway_display_get_setting;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|