1 /* GDK - The GIMP Drawing Kit
2 * gdkdisplay-broadway.c
4 * Copyright 2001 Sun Microsystems Inc.
5 * Copyright (C) 2004 Nokia Corporation
7 * Erwann Chenede <erwann.chenede@sun.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
27 #include "gdkdisplay-broadway.h"
29 #include "gdkdisplay.h"
30 #include "gdkeventsource.h"
31 #include "gdkscreen.h"
32 #include "gdkscreen-broadway.h"
33 #include "gdkinternals.h"
34 #include "gdkdeviceprivate.h"
35 #include "gdkdevicemanager-broadway.h"
38 #include <glib/gprintf.h>
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <netinet/in.h>
46 #include <netinet/tcp.h>
48 static void gdk_broadway_display_dispose (GObject *object);
49 static void gdk_broadway_display_finalize (GObject *object);
51 G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY)
54 gdk_broadway_display_init (GdkBroadwayDisplay *display)
56 _gdk_broadway_display_manager_add_display (gdk_display_manager_get (),
57 GDK_DISPLAY_OBJECT (display));
58 display->id_ht = g_hash_table_new (NULL, NULL);
62 gdk_event_init (GdkDisplay *display)
64 GdkBroadwayDisplay *broadway_display;
66 broadway_display = GDK_BROADWAY_DISPLAY (display);
67 broadway_display->event_source = _gdk_broadway_event_source_new (display);
68 broadway_display->saved_serial = 1;
69 broadway_display->last_seen_time = 1;
73 gdk_broadway_display_init_input (GdkDisplay *display)
75 GdkBroadwayDisplay *broadway_display;
76 GdkDeviceManager *device_manager;
80 broadway_display = GDK_BROADWAY_DISPLAY (display);
81 device_manager = gdk_display_get_device_manager (display);
83 /* For backwards compatibility, just add
84 * floating devices that are not keyboards.
86 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
88 for (l = list; l; l = l->next)
92 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
95 broadway_display->input_devices = g_list_prepend (broadway_display->input_devices,
96 g_object_ref (l->data));
101 /* Now set "core" pointer to the first
102 * master device that is a pointer.
104 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
106 for (l = list; l; l = l->next)
110 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
113 display->core_pointer = device;
117 /* Add the core pointer to the devices list */
118 broadway_display->input_devices = g_list_prepend (broadway_display->input_devices,
119 g_object_ref (display->core_pointer));
124 typedef struct HttpRequest {
126 GSocketConnection *connection;
127 GDataInputStream *data;
131 static void start_output (HttpRequest *request);
134 http_request_free (HttpRequest *request)
136 g_object_unref (request->connection);
137 g_object_unref (request->data);
138 g_string_free (request->request, TRUE);
142 struct BroadwayInput {
144 GSocketConnection *connection;
152 broadway_input_free (BroadwayInput *input)
154 g_object_unref (input->connection);
155 g_byte_array_free (input->buffer, FALSE);
156 g_source_destroy (input->source);
161 process_input_messages (GdkBroadwayDisplay *broadway_display)
163 BroadwayInputMsg *message;
165 while (broadway_display->input_messages)
167 message = broadway_display->input_messages->data;
168 broadway_display->input_messages =
169 g_list_delete_link (broadway_display->input_messages,
170 broadway_display->input_messages);
172 _gdk_broadway_events_got_input (GDK_DISPLAY (broadway_display), message);
178 parse_pointer_data (char *p, BroadwayInputPointerMsg *data)
180 data->mouse_window_id = strtol (p, &p, 10);
182 data->event_window_id = strtol (p, &p, 10);
184 data->root_x = strtol (p, &p, 10);
186 data->root_y = strtol (p, &p, 10);
188 data->win_x = strtol (p, &p, 10);
190 data->win_y = strtol (p, &p, 10);
192 data->state = strtol (p, &p, 10);
198 update_future_pointer_info (GdkBroadwayDisplay *broadway_display, BroadwayInputPointerMsg *data)
200 broadway_display->future_root_x = data->root_x;
201 broadway_display->future_root_y = data->root_y;
202 broadway_display->future_state = data->state;
203 broadway_display->future_mouse_in_toplevel = data->mouse_window_id;
207 parse_input_message (BroadwayInput *input, const char *message)
209 GdkBroadwayDisplay *broadway_display;
210 BroadwayInputMsg msg;
214 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
217 msg.base.type = *p++;
218 msg.base.serial = (guint32)strtol (p, &p, 10);
220 time_ = strtol(p, &p, 10);
224 time_ = broadway_display->last_seen_time;
226 if (!input->seen_time) {
227 input->seen_time = TRUE;
228 /* Calculate time base so that any following times are normalized to start
229 5 seconds after last_seen_time, to avoid issues that could appear when
230 a long hiatus due to a reconnect seems to be instant */
231 input->time_base = time_ - (broadway_display->last_seen_time + 5000);
233 time_ = time_ - input->time_base;
236 broadway_display->last_seen_time = time_;
238 msg.base.time = time_;
240 switch (msg.base.type) {
241 case 'e': /* Enter */
242 case 'l': /* Leave */
243 p = parse_pointer_data (p, &msg.pointer);
244 update_future_pointer_info (broadway_display, &msg.pointer);
246 msg.crossing.mode = strtol(p, &p, 10);
249 case 'm': /* Mouse move */
250 p = parse_pointer_data (p, &msg.pointer);
251 update_future_pointer_info (broadway_display, &msg.pointer);
256 p = parse_pointer_data (p, &msg.pointer);
257 update_future_pointer_info (broadway_display, &msg.pointer);
259 msg.button.button = strtol(p, &p, 10);
263 p = parse_pointer_data (p, &msg.pointer);
264 update_future_pointer_info (broadway_display, &msg.pointer);
266 msg.scroll.dir = strtol(p, &p, 10);
271 msg.key.key = strtol(p, &p, 10);
273 msg.key.state = strtol(p, &p, 10);
278 msg.grab_reply.res = strtol(p, &p, 10);
282 msg.configure_notify.id = strtol(p, &p, 10);
284 msg.configure_notify.x = strtol (p, &p, 10);
286 msg.configure_notify.y = strtol (p, &p, 10);
288 msg.configure_notify.width = strtol (p, &p, 10);
290 msg.configure_notify.height = strtol (p, &p, 10);
294 msg.delete_notify.id = strtol(p, &p, 10);
298 msg.screen_resize_notify.width = strtol (p, &p, 10);
300 msg.screen_resize_notify.height = strtol (p, &p, 10);
304 g_printerr ("Unknown input command %s\n", message);
308 broadway_display->input_messages = g_list_append (broadway_display->input_messages, g_memdup (&msg, sizeof (msg)));
313 parse_input (BroadwayInput *input)
315 GdkBroadwayDisplay *broadway_display;
319 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
321 buf = (char *)input->buffer->data;
322 len = input->buffer->len;
329 broadway_display->input = NULL;
330 broadway_input_free (input);
334 while ((ptr = memchr (buf, 0xff, len)) != NULL)
339 parse_input_message (input, buf + 1);
344 if (len > 0 && buf[0] != 0)
346 broadway_display->input = NULL;
347 broadway_input_free (input);
352 g_byte_array_remove_range (input->buffer, 0, buf - (char *)input->buffer->data);
357 process_input_idle_cb (GdkBroadwayDisplay *display)
359 display->process_input_idle = 0;
360 process_input_messages (display);
365 queue_process_input_at_idle (GdkBroadwayDisplay *broadway_display)
367 if (broadway_display->process_input_idle == 0)
368 broadway_display->process_input_idle =
369 g_idle_add_full (GDK_PRIORITY_EVENTS, (GSourceFunc)process_input_idle_cb, broadway_display, NULL);
373 _gdk_broadway_display_read_all_input_nonblocking (GdkDisplay *display)
375 GdkBroadwayDisplay *broadway_display;
380 BroadwayInput *input;
382 broadway_display = GDK_BROADWAY_DISPLAY (display);
383 if (broadway_display->input == NULL)
386 input = broadway_display->input;
388 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
391 res = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM (in),
392 buffer, sizeof (buffer), NULL, &error);
397 g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
399 g_error_free (error);
403 broadway_display->input = NULL;
404 broadway_input_free (input);
407 g_print ("input error %s", error->message);
408 g_error_free (error);
413 g_byte_array_append (input->buffer, buffer, res);
419 _gdk_broadway_display_consume_all_input (GdkDisplay *display)
421 GdkBroadwayDisplay *broadway_display;
423 broadway_display = GDK_BROADWAY_DISPLAY (display);
424 _gdk_broadway_display_read_all_input_nonblocking (display);
426 /* Since we're parsing input but not processing the resulting messages
427 we might not get a readable callback on the stream, so queue an idle to
428 process the messages */
429 queue_process_input_at_idle (broadway_display);
434 input_data_cb (GObject *stream,
435 BroadwayInput *input)
437 GdkBroadwayDisplay *broadway_display;
439 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
440 _gdk_broadway_display_read_all_input_nonblocking (input->display);
442 process_input_messages (broadway_display);
447 /* Note: This may be called while handling a message (i.e. sorta recursively) */
449 _gdk_broadway_display_block_for_input (GdkDisplay *display, char op,
450 guint32 serial, gboolean remove_message)
452 GdkBroadwayDisplay *broadway_display;
453 BroadwayInputMsg *message;
456 BroadwayInput *input;
460 gdk_display_flush (display);
462 broadway_display = GDK_BROADWAY_DISPLAY (display);
463 if (broadway_display->input == NULL)
466 input = broadway_display->input;
469 /* Check for existing reply in queue */
471 for (l = broadway_display->input_messages; l != NULL; l = l->next)
475 if (message->base.type == op)
477 if (message->base.serial == serial)
480 broadway_display->input_messages =
481 g_list_delete_link (broadway_display->input_messages, l);
487 /* Not found, read more, blocking */
489 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
490 res = g_input_stream_read (in, buffer, sizeof (buffer), NULL, NULL);
493 g_byte_array_append (input->buffer, buffer, res);
497 /* Since we're parsing input but not processing the resulting messages
498 we might not get a readable callback on the stream, so queue an idle to
499 process the messages */
500 queue_process_input_at_idle (broadway_display);
505 parse_line (char *line, char *key)
509 if (!g_str_has_prefix (line, key))
511 p = line + strlen (key);
515 /* Skip optional initial space */
521 send_error (HttpRequest *request,
527 res = g_strdup_printf ("HTTP/1.0 %d %s\r\n\r\n"
528 "<html><head><title>%d %s</title></head>"
529 "<body>%s</body></html>",
533 /* TODO: This should really be async */
534 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
535 res, strlen (res), NULL, NULL, NULL);
537 http_request_free (request);
541 start_input (HttpRequest *request)
545 int num_key1, num_key2;
549 guint8 challenge[16];
554 GdkBroadwayDisplay *broadway_display;
555 BroadwayInput *input;
556 const void *data_buffer;
557 gsize data_buffer_size;
560 broadway_display = GDK_BROADWAY_DISPLAY (request->display);
562 if (broadway_display->input != NULL)
564 send_error (request, 409, "Input already handled");
568 lines = g_strsplit (request->request->str, "\n", 0);
576 for (i = 0; lines[i] != NULL; i++)
578 if ((p = parse_line (lines[i], "Sec-WebSocket-Key1")))
583 if (g_ascii_isdigit (*p))
584 key1 = key1 * 10 + g_ascii_digit_value (*p);
593 else if ((p = parse_line (lines[i], "Sec-WebSocket-Key2")))
598 if (g_ascii_isdigit (*p))
599 key2 = key2 * 10 + g_ascii_digit_value (*p);
608 else if ((p = parse_line (lines[i], "Origin")))
612 else if ((p = parse_line (lines[i], "Host")))
618 if (num_key1 != 1 || num_key2 != 1 || origin == NULL || host == NULL)
621 send_error (request, 400, "Bad websocket request");
625 challenge[0] = (key1 >> 24) & 0xff;
626 challenge[1] = (key1 >> 16) & 0xff;
627 challenge[2] = (key1 >> 8) & 0xff;
628 challenge[3] = (key1 >> 0) & 0xff;
629 challenge[4] = (key2 >> 24) & 0xff;
630 challenge[5] = (key2 >> 16) & 0xff;
631 challenge[6] = (key2 >> 8) & 0xff;
632 challenge[7] = (key2 >> 0) & 0xff;
634 if (!g_input_stream_read_all (G_INPUT_STREAM (request->data), challenge+8, 8, NULL, NULL, NULL))
637 send_error (request, 400, "Bad websocket request");
641 checksum = g_checksum_new (G_CHECKSUM_MD5);
642 g_checksum_update (checksum, challenge, 16);
644 g_checksum_get_digest (checksum, challenge, &len);
645 g_checksum_free (checksum);
647 res = g_strdup_printf ("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
648 "Upgrade: WebSocket\r\n"
649 "Connection: Upgrade\r\n"
650 "Sec-WebSocket-Origin: %s\r\n"
651 "Sec-WebSocket-Location: ws://%s/socket\r\n"
652 "Sec-WebSocket-Protocol: broadway\r\n"
656 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
657 res, strlen (res), NULL, NULL, NULL);
659 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
660 challenge, 16, NULL, NULL, NULL);
662 input = g_new0 (BroadwayInput, 1);
664 input->display = request->display;
665 input->connection = g_object_ref (request->connection);
667 data_buffer = g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (request->data), &data_buffer_size);
668 input->buffer = g_byte_array_sized_new (data_buffer_size);
669 g_byte_array_append (input->buffer, data_buffer, data_buffer_size);
671 broadway_display->input = input;
673 start_output (request);
675 /* This will free and close the data input stream, but we got all the buffered content already */
676 http_request_free (request);
678 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
679 input->source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (in), NULL);
680 g_source_set_callback (input->source, (GSourceFunc)input_data_cb, input, NULL);
681 g_source_attach (input->source, NULL);
683 /* Process any data in the pipe already */
685 process_input_messages (broadway_display);
691 start_output (HttpRequest *request)
694 GdkBroadwayDisplay *broadway_display;
697 socket = g_socket_connection_get_socket (request->connection);
698 setsockopt(g_socket_get_fd (socket), IPPROTO_TCP,
699 TCP_NODELAY, (char *) &flag, sizeof(int));
701 broadway_display = GDK_BROADWAY_DISPLAY (request->display);
703 if (broadway_display->output)
705 broadway_display->saved_serial = broadway_output_get_next_serial (broadway_display->output);
706 broadway_output_free (broadway_display->output);
709 broadway_display->output =
710 broadway_output_new (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
711 broadway_display->saved_serial);
713 _gdk_broadway_resync_windows ();
715 if (broadway_display->pointer_grab_window)
716 broadway_output_grab_pointer (broadway_display->output,
717 GDK_WINDOW_IMPL_BROADWAY (broadway_display->pointer_grab_window->impl)->id,
718 broadway_display->pointer_grab_owner_events);
722 send_data (HttpRequest *request,
723 const char *mimetype,
724 const char *data, gsize len)
728 res = g_strdup_printf ("HTTP/1.0 200 OK\r\n"
729 "Content-Type: %s\r\n"
730 "Content-Length: %"G_GSIZE_FORMAT"\r\n"
733 /* TODO: This should really be async */
734 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
735 res, strlen (res), NULL, NULL, NULL);
737 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
738 data, len, NULL, NULL, NULL);
739 http_request_free (request);
742 #include "clienthtml.h"
743 #include "broadwayjs.h"
746 got_request (HttpRequest *request)
748 char *start, *escaped, *tmp, *version, *query;
750 if (!g_str_has_prefix (request->request->str, "GET "))
752 send_error (request, 501, "Only GET implemented");
756 start = request->request->str + 4; /* Skip "GET " */
758 while (*start == ' ')
761 for (tmp = start; *tmp != 0 && *tmp != ' ' && *tmp != '\n'; tmp++)
763 escaped = g_strndup (start, tmp - start);
768 while (*start == ' ')
770 for (tmp = start; *tmp != 0 && *tmp != ' ' && *tmp != '\n'; tmp++)
772 version = g_strndup (start, tmp - start);
775 query = strchr (escaped, '?');
779 if (strcmp (escaped, "/client.html") == 0 || strcmp (escaped, "/") == 0)
780 send_data (request, "text/html", client_html, G_N_ELEMENTS(client_html) - 1);
781 else if (strcmp (escaped, "/broadway.js") == 0)
782 send_data (request, "text/javascript", broadway_js, G_N_ELEMENTS(broadway_js) - 1);
783 else if (strcmp (escaped, "/socket") == 0)
784 start_input (request);
786 send_error (request, 404, "File not found");
793 got_http_request_line (GInputStream *stream,
794 GAsyncResult *result,
795 HttpRequest *request)
799 line = g_data_input_stream_read_line_finish (G_DATA_INPUT_STREAM (stream), result, NULL, NULL);
802 http_request_free (request);
803 g_printerr ("Error reading request lines\n");
806 if (strlen (line) == 0)
807 got_request (request);
810 /* Protect against overflow in request length */
811 if (request->request->len > 1024 * 5)
813 send_error (request, 400, "Request to long");
817 g_string_append_printf (request->request, "%s\n", line);
818 g_data_input_stream_read_line_async (request->data, 0, NULL,
819 (GAsyncReadyCallback)got_http_request_line, request);
826 handle_incoming_connection (GSocketService *service,
827 GSocketConnection *connection,
828 GObject *source_object)
830 HttpRequest *request;
833 request = g_new0 (HttpRequest, 1);
834 request->connection = g_object_ref (connection);
835 request->display = (GdkDisplay *) source_object;
836 request->request = g_string_new ("");
838 in = g_io_stream_get_input_stream (G_IO_STREAM (connection));
840 request->data = g_data_input_stream_new (in);
841 g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (request->data), FALSE);
842 /* Be tolerant of input */
843 g_data_input_stream_set_newline_type (request->data, G_DATA_STREAM_NEWLINE_TYPE_ANY);
845 g_data_input_stream_read_line_async (request->data, 0, NULL,
846 (GAsyncReadyCallback)got_http_request_line, request);
851 _gdk_broadway_display_open (const gchar *display_name)
854 GdkBroadwayDisplay *broadway_display;
858 display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
859 broadway_display = GDK_BROADWAY_DISPLAY (display);
861 broadway_display->output = NULL;
863 /* initialize the display's screens */
864 broadway_display->screens = g_new (GdkScreen *, 1);
865 broadway_display->screens[0] = _gdk_broadway_screen_new (display, 0);
867 /* We need to initialize events after we have the screen
868 * structures in places
870 _gdk_broadway_screen_events_init (broadway_display->screens[0]);
872 /*set the default screen */
873 broadway_display->default_screen = broadway_display->screens[0];
875 display->device_manager = _gdk_broadway_device_manager_new (display);
877 gdk_event_init (display);
879 gdk_broadway_display_init_input (display);
880 _gdk_broadway_display_init_dnd (display);
882 _gdk_broadway_screen_setup (broadway_display->screens[0]);
884 if (display_name == NULL)
885 display_name = g_getenv ("BROADWAY_DISPLAY");
888 if (display_name != NULL)
889 port = strtol(display_name, NULL, 10);
893 broadway_display->service = g_socket_service_new ();
894 if (!g_socket_listener_add_inet_port (G_SOCKET_LISTENER (broadway_display->service),
899 g_printerr ("Unable to listen to port %d: %s\n", 8080, error->message);
900 g_error_free (error);
903 g_signal_connect (broadway_display->service, "incoming", G_CALLBACK (handle_incoming_connection), NULL);
905 g_signal_emit_by_name (display, "opened");
906 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
913 gdk_broadway_display_get_name (GdkDisplay *display)
915 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
917 return (gchar *) "Broadway";
921 gdk_broadway_display_get_n_screens (GdkDisplay *display)
923 g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
929 gdk_broadway_display_get_screen (GdkDisplay *display,
932 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
933 g_return_val_if_fail (screen_num == 0, NULL);
935 return GDK_BROADWAY_DISPLAY (display)->screens[screen_num];
939 gdk_broadway_display_get_default_screen (GdkDisplay *display)
941 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
943 return GDK_BROADWAY_DISPLAY (display)->default_screen;
947 gdk_broadway_display_beep (GdkDisplay *display)
949 g_return_if_fail (GDK_IS_DISPLAY (display));
953 gdk_broadway_display_sync (GdkDisplay *display)
955 g_return_if_fail (GDK_IS_DISPLAY (display));
960 gdk_broadway_display_flush (GdkDisplay *display)
962 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
964 g_return_if_fail (GDK_IS_DISPLAY (display));
966 if (broadway_display->output &&
967 !broadway_output_flush (broadway_display->output))
969 broadway_display->saved_serial = broadway_output_get_next_serial (broadway_display->output);
970 broadway_output_free (broadway_display->output);
971 broadway_display->output = NULL;
976 gdk_broadway_display_has_pending (GdkDisplay *display)
982 gdk_broadway_display_get_default_group (GdkDisplay *display)
984 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
990 gdk_broadway_display_dispose (GObject *object)
992 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
994 _gdk_broadway_display_manager_remove_display (gdk_display_manager_get (),
995 GDK_DISPLAY_OBJECT (object));
997 g_list_foreach (broadway_display->input_devices, (GFunc) g_object_run_dispose, NULL);
999 _gdk_screen_close (broadway_display->screens[0]);
1001 if (broadway_display->event_source)
1003 g_source_destroy (broadway_display->event_source);
1004 g_source_unref (broadway_display->event_source);
1005 broadway_display->event_source = NULL;
1008 G_OBJECT_CLASS (gdk_broadway_display_parent_class)->dispose (object);
1012 gdk_broadway_display_finalize (GObject *object)
1014 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
1017 if (broadway_display->keymap)
1018 g_object_unref (broadway_display->keymap);
1020 _gdk_broadway_cursor_display_finalize (GDK_DISPLAY_OBJECT(broadway_display));
1022 /* input GdkDevice list */
1023 g_list_foreach (broadway_display->input_devices, (GFunc) g_object_unref, NULL);
1024 g_list_free (broadway_display->input_devices);
1025 /* Free all GdkScreens */
1026 g_object_unref (broadway_display->screens[0]);
1027 g_free (broadway_display->screens);
1029 G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
1033 _gdk_broadway_display_make_default (GdkDisplay *display)
1038 gdk_broadway_display_notify_startup_complete (GdkDisplay *display,
1039 const gchar *startup_id)
1044 gdk_broadway_display_supports_selection_notification (GdkDisplay *display)
1050 gdk_broadway_display_request_selection_notification (GdkDisplay *display,
1058 gdk_broadway_display_supports_clipboard_persistence (GdkDisplay *display)
1064 gdk_broadway_display_store_clipboard (GdkDisplay *display,
1065 GdkWindow *clipboard_window,
1067 const GdkAtom *targets,
1073 gdk_broadway_display_supports_shapes (GdkDisplay *display)
1079 gdk_broadway_display_supports_input_shapes (GdkDisplay *display)
1085 gdk_broadway_display_supports_composite (GdkDisplay *display)
1091 gdk_broadway_display_list_devices (GdkDisplay *display)
1093 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1095 return GDK_BROADWAY_DISPLAY (display)->input_devices;
1099 gdk_broadway_display_get_next_serial (GdkDisplay *display)
1101 GdkBroadwayDisplay *broadway_display;
1102 broadway_display = GDK_BROADWAY_DISPLAY (display);
1103 if (broadway_display->output)
1104 return broadway_output_get_next_serial (broadway_display->output);
1105 return broadway_display->saved_serial;
1110 gdk_broadway_display_event_data_copy (GdkDisplay *display,
1111 const GdkEvent *src,
1117 gdk_broadway_display_event_data_free (GdkDisplay *display,
1123 gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
1125 GObjectClass *object_class = G_OBJECT_CLASS (class);
1126 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
1128 object_class->dispose = gdk_broadway_display_dispose;
1129 object_class->finalize = gdk_broadway_display_finalize;
1131 display_class->window_type = GDK_TYPE_BROADWAY_WINDOW;
1133 display_class->get_name = gdk_broadway_display_get_name;
1134 display_class->get_n_screens = gdk_broadway_display_get_n_screens;
1135 display_class->get_screen = gdk_broadway_display_get_screen;
1136 display_class->get_default_screen = gdk_broadway_display_get_default_screen;
1137 display_class->beep = gdk_broadway_display_beep;
1138 display_class->sync = gdk_broadway_display_sync;
1139 display_class->flush = gdk_broadway_display_flush;
1140 display_class->has_pending = gdk_broadway_display_has_pending;
1141 display_class->queue_events = _gdk_broadway_display_queue_events;
1142 display_class->get_default_group = gdk_broadway_display_get_default_group;
1143 display_class->supports_selection_notification = gdk_broadway_display_supports_selection_notification;
1144 display_class->request_selection_notification = gdk_broadway_display_request_selection_notification;
1145 display_class->supports_clipboard_persistence = gdk_broadway_display_supports_clipboard_persistence;
1146 display_class->store_clipboard = gdk_broadway_display_store_clipboard;
1147 display_class->supports_shapes = gdk_broadway_display_supports_shapes;
1148 display_class->supports_input_shapes = gdk_broadway_display_supports_input_shapes;
1149 display_class->supports_composite = gdk_broadway_display_supports_composite;
1150 display_class->list_devices = gdk_broadway_display_list_devices;
1151 display_class->get_cursor_for_type = _gdk_broadway_display_get_cursor_for_type;
1152 display_class->get_cursor_for_name = _gdk_broadway_display_get_cursor_for_name;
1153 display_class->get_cursor_for_pixbuf = _gdk_broadway_display_get_cursor_for_pixbuf;
1154 display_class->get_default_cursor_size = _gdk_broadway_display_get_default_cursor_size;
1155 display_class->get_maximal_cursor_size = _gdk_broadway_display_get_maximal_cursor_size;
1156 display_class->supports_cursor_alpha = _gdk_broadway_display_supports_cursor_alpha;
1157 display_class->supports_cursor_color = _gdk_broadway_display_supports_cursor_color;
1159 display_class->before_process_all_updates = _gdk_broadway_display_before_process_all_updates;
1160 display_class->after_process_all_updates = _gdk_broadway_display_after_process_all_updates;
1161 display_class->get_next_serial = gdk_broadway_display_get_next_serial;
1162 display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
1163 display_class->event_data_copy = gdk_broadway_display_event_data_copy;
1164 display_class->event_data_free = gdk_broadway_display_event_data_free;
1165 display_class->create_window_impl = _gdk_broadway_display_create_window_impl;
1166 display_class->get_keymap = _gdk_broadway_display_get_keymap;
1167 display_class->get_selection_owner = _gdk_broadway_display_get_selection_owner;
1168 display_class->set_selection_owner = _gdk_broadway_display_set_selection_owner;
1169 display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify;
1170 display_class->get_selection_property = _gdk_broadway_display_get_selection_property;
1171 display_class->convert_selection = _gdk_broadway_display_convert_selection;
1172 display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
1173 display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;