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>
44 static void gdk_broadway_display_dispose (GObject *object);
45 static void gdk_broadway_display_finalize (GObject *object);
47 G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY)
50 gdk_broadway_display_init (GdkBroadwayDisplay *display)
52 _gdk_broadway_display_manager_add_display (gdk_display_manager_get (),
53 GDK_DISPLAY_OBJECT (display));
54 display->id_ht = g_hash_table_new (NULL, NULL);
58 gdk_event_init (GdkDisplay *display)
60 GdkBroadwayDisplay *broadway_display;
62 broadway_display = GDK_BROADWAY_DISPLAY (display);
63 broadway_display->event_source = _gdk_broadway_event_source_new (display);
64 broadway_display->saved_serial = 1;
68 gdk_broadway_display_init_input (GdkDisplay *display)
70 GdkBroadwayDisplay *broadway_display;
71 GdkDeviceManager *device_manager;
75 broadway_display = GDK_BROADWAY_DISPLAY (display);
76 device_manager = gdk_display_get_device_manager (display);
78 /* For backwards compatibility, just add
79 * floating devices that are not keyboards.
81 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
83 for (l = list; l; l = l->next)
87 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
90 broadway_display->input_devices = g_list_prepend (broadway_display->input_devices,
91 g_object_ref (l->data));
96 /* Now set "core" pointer to the first
97 * master device that is a pointer.
99 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
101 for (l = list; l; l = l->next)
105 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
108 display->core_pointer = device;
112 /* Add the core pointer to the devices list */
113 broadway_display->input_devices = g_list_prepend (broadway_display->input_devices,
114 g_object_ref (display->core_pointer));
119 typedef struct HttpRequest {
121 GSocketConnection *connection;
122 GDataInputStream *data;
127 http_request_free (HttpRequest *request)
129 g_object_unref (request->connection);
130 g_object_unref (request->data);
131 g_string_free (request->request, TRUE);
135 struct BroadwayInput {
137 GSocketConnection *connection;
143 broadway_input_free (BroadwayInput *input)
145 g_object_unref (input->connection);
146 g_byte_array_free (input->buffer, FALSE);
147 g_source_destroy (input->source);
152 process_input_messages (GdkBroadwayDisplay *broadway_display)
154 BroadwayInputMsg *message;
156 while (broadway_display->input_messages)
158 message = broadway_display->input_messages->data;
159 broadway_display->input_messages =
160 g_list_delete_link (broadway_display->input_messages,
161 broadway_display->input_messages);
163 _gdk_broadway_events_got_input (GDK_DISPLAY (broadway_display), message);
169 parse_pointer_data (char *p, BroadwayInputPointerMsg *data)
171 data->mouse_window_id = strtol (p, &p, 10);
173 data->event_window_id = strtol (p, &p, 10);
175 data->root_x = strtol (p, &p, 10);
177 data->root_y = strtol (p, &p, 10);
179 data->win_x = strtol (p, &p, 10);
181 data->win_y = strtol (p, &p, 10);
183 data->state = strtol (p, &p, 10);
189 update_future_pointer_info (GdkBroadwayDisplay *broadway_display, BroadwayInputPointerMsg *data)
191 broadway_display->future_root_x = data->root_x;
192 broadway_display->future_root_y = data->root_y;
193 broadway_display->future_mouse_in_toplevel = data->mouse_window_id;
197 parse_input_message (BroadwayInput *input, const char *message)
199 GdkBroadwayDisplay *broadway_display;
200 BroadwayInputMsg msg;
203 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
206 msg.base.type = *p++;
207 msg.base.serial = (guint32)strtol (p, &p, 10);
209 msg.base.time = strtol(p, &p, 10);
212 switch (msg.base.type) {
213 case 'e': /* Enter */
214 case 'l': /* Leave */
215 p = parse_pointer_data (p, &msg.pointer);
216 update_future_pointer_info (broadway_display, &msg.pointer);
218 msg.crossing.mode = strtol(p, &p, 10);
221 case 'm': /* Mouse move */
222 p = parse_pointer_data (p, &msg.pointer);
223 update_future_pointer_info (broadway_display, &msg.pointer);
228 p = parse_pointer_data (p, &msg.pointer);
229 update_future_pointer_info (broadway_display, &msg.pointer);
231 msg.button.button = strtol(p, &p, 10);
235 p = parse_pointer_data (p, &msg.pointer);
236 update_future_pointer_info (broadway_display, &msg.pointer);
238 msg.scroll.dir = strtol(p, &p, 10);
243 msg.key.key = strtol(p, &p, 10);
248 msg.grab_reply.res = strtol(p, &p, 10);
252 msg.configure_notify.id = strtol(p, &p, 10);
254 msg.configure_notify.x = strtol (p, &p, 10);
256 msg.configure_notify.y = strtol (p, &p, 10);
258 msg.configure_notify.width = strtol (p, &p, 10);
260 msg.configure_notify.height = strtol (p, &p, 10);
264 msg.delete_notify.id = strtol(p, &p, 10);
268 g_printerr ("Unknown input command %s\n", message);
272 broadway_display->input_messages = g_list_append (broadway_display->input_messages, g_memdup (&msg, sizeof (msg)));
277 parse_input (BroadwayInput *input)
279 GdkBroadwayDisplay *broadway_display;
283 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
285 buf = (char *)input->buffer->data;
286 len = input->buffer->len;
293 broadway_display->input = NULL;
294 broadway_input_free (input);
298 while ((ptr = memchr (buf, 0xff, len)) != NULL)
303 parse_input_message (input, buf + 1);
308 if (len > 0 && buf[0] != 0)
310 broadway_display->input = NULL;
311 broadway_input_free (input);
316 g_byte_array_remove_range (input->buffer, 0, buf - (char *)input->buffer->data);
321 process_input_idle_cb (GdkBroadwayDisplay *display)
323 display->process_input_idle = 0;
324 process_input_messages (display);
329 queue_process_input_at_idle (GdkBroadwayDisplay *broadway_display)
331 if (broadway_display->process_input_idle == 0)
332 broadway_display->process_input_idle =
333 g_idle_add_full (GDK_PRIORITY_EVENTS, (GSourceFunc)process_input_idle_cb, broadway_display, NULL);
337 _gdk_broadway_display_read_all_input_nonblocking (GdkDisplay *display)
339 GdkBroadwayDisplay *broadway_display;
344 BroadwayInput *input;
346 broadway_display = GDK_BROADWAY_DISPLAY (display);
347 if (broadway_display->input == NULL)
350 input = broadway_display->input;
352 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
355 res = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM (in),
356 buffer, sizeof (buffer), NULL, &error);
361 g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
363 g_error_free (error);
367 broadway_display->input = NULL;
368 broadway_input_free (input);
371 g_print ("input error %s", error->message);
372 g_error_free (error);
377 g_byte_array_append (input->buffer, buffer, res);
383 _gdk_broadway_display_consume_all_input (GdkDisplay *display)
385 GdkBroadwayDisplay *broadway_display;
387 broadway_display = GDK_BROADWAY_DISPLAY (display);
388 _gdk_broadway_display_read_all_input_nonblocking (display);
390 /* Since we're parsing input but not processing the resulting messages
391 we might not get a readable callback on the stream, so queue an idle to
392 process the messages */
393 queue_process_input_at_idle (broadway_display);
398 input_data_cb (GObject *stream,
399 BroadwayInput *input)
401 GdkBroadwayDisplay *broadway_display;
403 broadway_display = GDK_BROADWAY_DISPLAY (input->display);
404 _gdk_broadway_display_read_all_input_nonblocking (input->display);
406 process_input_messages (broadway_display);
411 /* Note: This may be called while handling a message (i.e. sorta recursively) */
413 _gdk_broadway_display_block_for_input (GdkDisplay *display, char op,
414 guint32 serial, gboolean remove_message)
416 GdkBroadwayDisplay *broadway_display;
417 BroadwayInputMsg *message;
420 BroadwayInput *input;
424 gdk_display_flush (display);
426 broadway_display = GDK_BROADWAY_DISPLAY (display);
427 if (broadway_display->input == NULL)
430 input = broadway_display->input;
433 /* Check for existing reply in queue */
435 for (l = broadway_display->input_messages; l != NULL; l = l->next)
439 if (message->base.type == op)
441 if (message->base.serial == serial)
444 broadway_display->input_messages =
445 g_list_delete_link (broadway_display->input_messages, l);
451 /* Not found, read more, blocking */
453 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
454 res = g_input_stream_read (in, buffer, sizeof (buffer), NULL, NULL);
457 g_byte_array_append (input->buffer, buffer, res);
461 /* Since we're parsing input but not processing the resulting messages
462 we might not get a readable callback on the stream, so queue an idle to
463 process the messages */
464 queue_process_input_at_idle (broadway_display);
471 set_fd_blocking (int fd)
475 if ((arg = fcntl (fd, F_GETFL, NULL)) < 0)
478 arg = arg & ~O_NONBLOCK;
480 fcntl (fd, F_SETFL, arg);
484 parse_line (char *line, char *key)
488 if (!g_str_has_prefix (line, key))
490 p = line + strlen (key);
494 /* Skip optional initial space */
500 send_error (HttpRequest *request,
506 res = g_strdup_printf ("HTTP/1.0 %d %s\r\n\r\n"
507 "<html><head><title>%d %s</title></head>"
508 "<body>%s</body></html>",
512 /* TODO: This should really be async */
513 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
514 res, strlen (res), NULL, NULL, NULL);
516 http_request_free (request);
520 start_input (HttpRequest *request)
524 int num_key1, num_key2;
528 guint8 challenge[16];
533 GdkBroadwayDisplay *broadway_display;
534 BroadwayInput *input;
535 const void *data_buffer;
536 gsize data_buffer_size;
539 broadway_display = GDK_BROADWAY_DISPLAY (request->display);
541 if (broadway_display->input != NULL)
543 send_error (request, 409, "Input already handled");
547 lines = g_strsplit (request->request->str, "\n", 0);
555 for (i = 0; lines[i] != NULL; i++)
557 if ((p = parse_line (lines[i], "Sec-WebSocket-Key1")))
562 if (g_ascii_isdigit (*p))
563 key1 = key1 * 10 + g_ascii_digit_value (*p);
572 else if ((p = parse_line (lines[i], "Sec-WebSocket-Key2")))
577 if (g_ascii_isdigit (*p))
578 key2 = key2 * 10 + g_ascii_digit_value (*p);
587 else if ((p = parse_line (lines[i], "Origin")))
591 else if ((p = parse_line (lines[i], "Host")))
597 if (num_key1 != 1 || num_key2 != 1 || origin == NULL || host == NULL)
600 send_error (request, 400, "Bad websocket request");
604 challenge[0] = (key1 >> 24) & 0xff;
605 challenge[1] = (key1 >> 16) & 0xff;
606 challenge[2] = (key1 >> 8) & 0xff;
607 challenge[3] = (key1 >> 0) & 0xff;
608 challenge[4] = (key2 >> 24) & 0xff;
609 challenge[5] = (key2 >> 16) & 0xff;
610 challenge[6] = (key2 >> 8) & 0xff;
611 challenge[7] = (key2 >> 0) & 0xff;
613 if (!g_input_stream_read_all (G_INPUT_STREAM (request->data), challenge+8, 8, NULL, NULL, NULL))
616 send_error (request, 400, "Bad websocket request");
620 checksum = g_checksum_new (G_CHECKSUM_MD5);
621 g_checksum_update (checksum, challenge, 16);
623 g_checksum_get_digest (checksum, challenge, &len);
624 g_checksum_free (checksum);
626 res = g_strdup_printf ("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
627 "Upgrade: WebSocket\r\n"
628 "Connection: Upgrade\r\n"
629 "Sec-WebSocket-Origin: %s\r\n"
630 "Sec-WebSocket-Location: ws://%s/input\r\n"
631 "Sec-WebSocket-Protocol: broadway\r\n"
635 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
636 res, strlen (res), NULL, NULL, NULL);
638 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
639 challenge, 16, NULL, NULL, NULL);
641 input = g_new0 (BroadwayInput, 1);
643 input->display = request->display;
644 input->connection = g_object_ref (request->connection);
646 data_buffer = g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (request->data), &data_buffer_size);
647 input->buffer = g_byte_array_sized_new (data_buffer_size);
648 g_byte_array_append (input->buffer, data_buffer, data_buffer_size);
650 broadway_display->input = input;
652 /* This will free and close the data input stream, but we got all the buffered content already */
653 http_request_free (request);
655 in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
656 input->source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (in), NULL);
657 g_source_set_callback (input->source, (GSourceFunc)input_data_cb, input, NULL);
658 g_source_attach (input->source, NULL);
660 /* Process any data in the pipe already */
662 process_input_messages (broadway_display);
668 start_output (HttpRequest *request)
671 GdkBroadwayDisplay *broadway_display;
674 socket = g_socket_connection_get_socket (request->connection);
676 broadway_display = GDK_BROADWAY_DISPLAY (request->display);
677 fd = g_socket_get_fd (socket);
678 set_fd_blocking (fd);
679 /* We dup this because otherwise it'll be closed with the request SocketConnection */
681 if (broadway_display->output)
683 broadway_display->saved_serial = broadway_output_get_next_serial (broadway_display->output);
684 broadway_output_free (broadway_display->output);
687 broadway_display->output = broadway_output_new (dup(fd), broadway_display->saved_serial);
688 _gdk_broadway_resync_windows ();
690 if (broadway_display->pointer_grab_window)
691 broadway_output_grab_pointer (broadway_display->output,
692 GDK_WINDOW_IMPL_BROADWAY (broadway_display->pointer_grab_window->impl)->id,
693 broadway_display->pointer_grab_owner_events);
695 http_request_free (request);
699 send_data (HttpRequest *request,
700 const char *mimetype,
701 const char *data, gsize len)
705 res = g_strdup_printf ("HTTP/1.0 200 OK\r\n"
706 "Content-Type: %s\r\n"
707 "Content-Length: %"G_GSIZE_FORMAT"\r\n"
710 /* TODO: This should really be async */
711 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
712 res, strlen (res), NULL, NULL, NULL);
714 g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
715 data, len, NULL, NULL, NULL);
716 http_request_free (request);
719 #include "clienthtml.h"
720 #include "broadwayjs.h"
723 got_request (HttpRequest *request)
725 char *start, *escaped, *tmp, *version;
727 if (!g_str_has_prefix (request->request->str, "GET "))
729 send_error (request, 501, "Only GET implemented");
733 start = request->request->str + 4; /* Skip "GET " */
735 while (*start == ' ')
738 for (tmp = start; *tmp != 0 && *tmp != ' ' && *tmp != '\n'; tmp++)
740 escaped = g_strndup (start, tmp - start);
745 while (*start == ' ')
747 for (tmp = start; *tmp != 0 && *tmp != ' ' && *tmp != '\n'; tmp++)
749 version = g_strndup (start, tmp - start);
752 if (strcmp (escaped, "/client.html") == 0 || strcmp (escaped, "/") == 0)
753 send_data (request, "text/html", client_html, G_N_ELEMENTS(client_html) - 1);
754 else if (strcmp (escaped, "/broadway.js") == 0)
755 send_data (request, "text/javascript", broadway_js, G_N_ELEMENTS(broadway_js) - 1);
756 else if (strcmp (escaped, "/output") == 0)
757 start_output (request);
758 else if (strcmp (escaped, "/input") == 0)
759 start_input (request);
761 send_error (request, 404, "File not found");
765 got_http_request_line (GInputStream *stream,
766 GAsyncResult *result,
767 HttpRequest *request)
771 line = g_data_input_stream_read_line_finish (G_DATA_INPUT_STREAM (stream), result, NULL, NULL);
774 http_request_free (request);
775 g_printerr ("Error reading request lines\n");
778 if (strlen (line) == 0)
779 got_request (request);
782 /* Protect against overflow in request length */
783 if (request->request->len > 1024 * 5)
785 send_error (request, 400, "Request to long");
789 g_string_append_printf (request->request, "%s\n", line);
790 g_data_input_stream_read_line_async (request->data, 0, NULL,
791 (GAsyncReadyCallback)got_http_request_line, request);
798 handle_incoming_connection (GSocketService *service,
799 GSocketConnection *connection,
800 GObject *source_object)
802 HttpRequest *request;
805 request = g_new0 (HttpRequest, 1);
806 request->connection = g_object_ref (connection);
807 request->display = (GdkDisplay *) source_object;
808 request->request = g_string_new ("");
810 in = g_io_stream_get_input_stream (G_IO_STREAM (connection));
812 request->data = g_data_input_stream_new (in);
813 g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (request->data), FALSE);
814 /* Be tolerant of input */
815 g_data_input_stream_set_newline_type (request->data, G_DATA_STREAM_NEWLINE_TYPE_ANY);
817 g_data_input_stream_read_line_async (request->data, 0, NULL,
818 (GAsyncReadyCallback)got_http_request_line, request);
823 _gdk_broadway_display_open (const gchar *display_name)
826 GdkBroadwayDisplay *broadway_display;
830 display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
831 broadway_display = GDK_BROADWAY_DISPLAY (display);
833 broadway_display->output = NULL;
835 /* initialize the display's screens */
836 broadway_display->screens = g_new (GdkScreen *, 1);
837 broadway_display->screens[0] = _gdk_broadway_screen_new (display, 0);
839 /* We need to initialize events after we have the screen
840 * structures in places
842 _gdk_broadway_screen_events_init (broadway_display->screens[0]);
844 /*set the default screen */
845 broadway_display->default_screen = broadway_display->screens[0];
847 display->device_manager = _gdk_broadway_device_manager_new (display);
849 gdk_event_init (display);
851 gdk_broadway_display_init_input (display);
852 _gdk_broadway_display_init_dnd (display);
854 _gdk_broadway_screen_setup (broadway_display->screens[0]);
856 if (display_name == NULL)
857 display_name = g_getenv ("BROADWAY_DISPLAY");
860 if (display_name != NULL)
861 port = strtol(display_name, NULL, 10);
865 broadway_display->service = g_socket_service_new ();
866 if (!g_socket_listener_add_inet_port (G_SOCKET_LISTENER (broadway_display->service),
871 g_printerr ("Unable to listen to port %d: %s\n", 8080, error->message);
872 g_error_free (error);
875 g_signal_connect (broadway_display->service, "incoming", G_CALLBACK (handle_incoming_connection), NULL);
877 g_signal_emit_by_name (display, "opened");
878 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
884 static G_CONST_RETURN gchar *
885 gdk_broadway_display_get_name (GdkDisplay *display)
887 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
889 return (gchar *) "Broadway";
893 gdk_broadway_display_get_n_screens (GdkDisplay *display)
895 g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
901 gdk_broadway_display_get_screen (GdkDisplay *display,
904 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
905 g_return_val_if_fail (screen_num == 0, NULL);
907 return GDK_BROADWAY_DISPLAY (display)->screens[screen_num];
911 gdk_broadway_display_get_default_screen (GdkDisplay *display)
913 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
915 return GDK_BROADWAY_DISPLAY (display)->default_screen;
919 gdk_broadway_display_beep (GdkDisplay *display)
921 g_return_if_fail (GDK_IS_DISPLAY (display));
925 gdk_broadway_display_sync (GdkDisplay *display)
927 g_return_if_fail (GDK_IS_DISPLAY (display));
932 gdk_broadway_display_flush (GdkDisplay *display)
934 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
936 g_return_if_fail (GDK_IS_DISPLAY (display));
938 if (broadway_display->output &&
939 !broadway_output_flush (broadway_display->output))
941 broadway_display->saved_serial = broadway_output_get_next_serial (broadway_display->output);
942 broadway_output_free (broadway_display->output);
943 broadway_display->output = NULL;
948 gdk_broadway_display_has_pending (GdkDisplay *display)
954 gdk_broadway_display_get_default_group (GdkDisplay *display)
956 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
962 gdk_broadway_display_dispose (GObject *object)
964 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
966 _gdk_broadway_display_manager_remove_display (gdk_display_manager_get (),
967 GDK_DISPLAY_OBJECT (object));
969 g_list_foreach (broadway_display->input_devices, (GFunc) g_object_run_dispose, NULL);
971 _gdk_screen_close (broadway_display->screens[0]);
973 if (broadway_display->event_source)
975 g_source_destroy (broadway_display->event_source);
976 g_source_unref (broadway_display->event_source);
977 broadway_display->event_source = NULL;
980 G_OBJECT_CLASS (gdk_broadway_display_parent_class)->dispose (object);
984 gdk_broadway_display_finalize (GObject *object)
986 GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
989 if (broadway_display->keymap)
990 g_object_unref (broadway_display->keymap);
992 _gdk_broadway_cursor_display_finalize (GDK_DISPLAY_OBJECT(broadway_display));
995 g_hash_table_destroy (broadway_display->atom_from_virtual);
996 g_hash_table_destroy (broadway_display->atom_to_virtual);
998 /* input GdkDevice list */
999 g_list_foreach (broadway_display->input_devices, (GFunc) g_object_unref, NULL);
1000 g_list_free (broadway_display->input_devices);
1001 /* Free all GdkScreens */
1002 g_object_unref (broadway_display->screens[0]);
1003 g_free (broadway_display->screens);
1005 G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
1009 _gdk_broadway_display_make_default (GdkDisplay *display)
1014 gdk_broadway_display_notify_startup_complete (GdkDisplay *display,
1015 const gchar *startup_id)
1020 gdk_broadway_display_supports_selection_notification (GdkDisplay *display)
1026 gdk_broadway_display_request_selection_notification (GdkDisplay *display,
1034 gdk_broadway_display_supports_clipboard_persistence (GdkDisplay *display)
1040 gdk_broadway_display_store_clipboard (GdkDisplay *display,
1041 GdkWindow *clipboard_window,
1043 const GdkAtom *targets,
1049 gdk_broadway_display_supports_shapes (GdkDisplay *display)
1055 gdk_broadway_display_supports_input_shapes (GdkDisplay *display)
1061 gdk_broadway_display_supports_composite (GdkDisplay *display)
1067 gdk_broadway_display_list_devices (GdkDisplay *display)
1069 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1071 return GDK_BROADWAY_DISPLAY (display)->input_devices;
1075 gdk_broadway_display_get_next_serial (GdkDisplay *display)
1077 GdkBroadwayDisplay *broadway_display;
1078 broadway_display = GDK_BROADWAY_DISPLAY (display);
1079 if (broadway_display->output)
1080 return broadway_output_get_next_serial (broadway_display->output);
1081 return broadway_display->saved_serial;
1086 gdk_broadway_display_event_data_copy (GdkDisplay *display,
1087 const GdkEvent *src,
1093 gdk_broadway_display_event_data_free (GdkDisplay *display,
1099 gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
1101 GObjectClass *object_class = G_OBJECT_CLASS (class);
1102 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
1104 object_class->dispose = gdk_broadway_display_dispose;
1105 object_class->finalize = gdk_broadway_display_finalize;
1107 display_class->window_type = GDK_TYPE_BROADWAY_WINDOW;
1109 display_class->get_name = gdk_broadway_display_get_name;
1110 display_class->get_n_screens = gdk_broadway_display_get_n_screens;
1111 display_class->get_screen = gdk_broadway_display_get_screen;
1112 display_class->get_default_screen = gdk_broadway_display_get_default_screen;
1113 display_class->beep = gdk_broadway_display_beep;
1114 display_class->sync = gdk_broadway_display_sync;
1115 display_class->flush = gdk_broadway_display_flush;
1116 display_class->has_pending = gdk_broadway_display_has_pending;
1117 display_class->queue_events = _gdk_broadway_display_queue_events;
1118 display_class->get_default_group = gdk_broadway_display_get_default_group;
1119 display_class->supports_selection_notification = gdk_broadway_display_supports_selection_notification;
1120 display_class->request_selection_notification = gdk_broadway_display_request_selection_notification;
1121 display_class->supports_clipboard_persistence = gdk_broadway_display_supports_clipboard_persistence;
1122 display_class->store_clipboard = gdk_broadway_display_store_clipboard;
1123 display_class->supports_shapes = gdk_broadway_display_supports_shapes;
1124 display_class->supports_input_shapes = gdk_broadway_display_supports_input_shapes;
1125 display_class->supports_composite = gdk_broadway_display_supports_composite;
1126 display_class->list_devices = gdk_broadway_display_list_devices;
1127 display_class->get_cursor_for_type = _gdk_broadway_display_get_cursor_for_type;
1128 display_class->get_cursor_for_name = _gdk_broadway_display_get_cursor_for_name;
1129 display_class->get_cursor_for_pixbuf = _gdk_broadway_display_get_cursor_for_pixbuf;
1130 display_class->get_default_cursor_size = _gdk_broadway_display_get_default_cursor_size;
1131 display_class->get_maximal_cursor_size = _gdk_broadway_display_get_maximal_cursor_size;
1132 display_class->supports_cursor_alpha = _gdk_broadway_display_supports_cursor_alpha;
1133 display_class->supports_cursor_color = _gdk_broadway_display_supports_cursor_color;
1135 display_class->before_process_all_updates = _gdk_broadway_display_before_process_all_updates;
1136 display_class->after_process_all_updates = _gdk_broadway_display_after_process_all_updates;
1137 display_class->get_next_serial = gdk_broadway_display_get_next_serial;
1138 display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
1139 display_class->event_data_copy = gdk_broadway_display_event_data_copy;
1140 display_class->event_data_free = gdk_broadway_display_event_data_free;
1141 display_class->create_window_impl = _gdk_broadway_display_create_window_impl;
1142 display_class->get_keymap = _gdk_broadway_display_get_keymap;
1143 display_class->get_selection_owner = _gdk_broadway_display_get_selection_owner;
1144 display_class->set_selection_owner = _gdk_broadway_display_set_selection_owner;
1145 display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify;
1146 display_class->get_selection_property = _gdk_broadway_display_get_selection_property;
1147 display_class->convert_selection = _gdk_broadway_display_convert_selection;
1148 display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
1149 display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;