[gtk+/xcb] beginings of an xcb gdk backend



commit d8ceffab5a96c552c7dd735cbf7fb539cc2bf57d
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Nov 9 13:30:25 2010 -0500

    beginings of an xcb gdk backend

 gdk/xcb/Makefile.am   |   27 +++++++++
 gdk/xcb/display.c     |   62 ++++++++++++++++++++
 gdk/xcb/dragcontext.c |   13 ++++
 gdk/xcb/init.c        |   11 ++++
 gdk/xcb/nothing.c     |  154 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdk/xcb/screen.c      |   93 +++++++++++++++++++++++++++++
 gdk/xcb/screen.h      |    6 ++
 gdk/xcb/visual.c      |   43 ++++++++++++++
 gdk/xcb/visual.h      |    4 +
 gdk/xcb/window.c      |   48 +++++++++++++++
 10 files changed, 461 insertions(+), 0 deletions(-)
---
diff --git a/gdk/xcb/Makefile.am b/gdk/xcb/Makefile.am
new file mode 100644
index 0000000..201a0f9
--- /dev/null
+++ b/gdk/xcb/Makefile.am
@@ -0,0 +1,27 @@
+include $(top_srcdir)/Makefile.decl
+
+libgdkincludedir = $(includedir)/gtk-3.0/gdk
+
+INCLUDES = 				\
+	-DG_LOG_DOMAIN=\"Gdk\"		\
+	-DGDK_COMPILATION		\
+	-I$(top_srcdir)			\
+	-I$(top_srcdir)/gdk		\
+	-I$(top_builddir)/gdk		\
+	$(GTK_DEBUG_FLAGS) 		\
+	$(GDK_DEP_CFLAGS)
+
+LDADDS = $(GDK_DEP_LIBS)
+
+noinst_LTLIBRARIES = libgdk-xcb.la
+
+libgdk_xcb_la_SOURCES =    	\
+	dragcontext.c		\
+	visual.c		\
+	screen.c		\
+	display.c		\
+	init.c			\
+	window.c		\
+	nothing.c
+
+-include $(top_srcdir)/git.mk
diff --git a/gdk/xcb/display.c b/gdk/xcb/display.c
new file mode 100644
index 0000000..48fa92e
--- /dev/null
+++ b/gdk/xcb/display.c
@@ -0,0 +1,62 @@
+#include "gdk.h"
+
+#include "screen.h"
+
+#include <xcb/xcb.h>
+
+typedef GdkDisplayClass GdkDisplayXcbClass;
+
+typedef struct
+{
+  GdkDisplay parent_instance;
+
+  GdkScreen *default_screen;
+  xcb_connection_t *cn;
+} GdkDisplayXcb;
+
+GType gdk_screen_xcb_get_type (void);
+static GType gdk_display_xcb_get_type (void);
+G_DEFINE_TYPE (GdkDisplayXcb, gdk_display_xcb, GDK_TYPE_DISPLAY)
+
+static void
+gdk_display_xcb_init (GdkDisplayXcb *dispxcb)
+{
+}
+
+static void
+gdk_display_xcb_class_init (GdkDisplayXcbClass *class)
+{
+}
+
+GdkDisplay *
+gdk_display_open (const gchar *display_name)
+{
+  GdkDisplayXcb *dispxcb;
+  xcb_connection_t *cn;
+  xcb_screen_t *scr;
+
+  /* XXX how does this work? */
+  g_assert (display_name == NULL);
+
+  cn = xcb_connect (NULL, NULL);
+  const xcb_setup_t *setup = xcb_get_setup (cn);
+  xcb_screen_iterator_t iter = xcb_setup_roots_iterator (setup);
+  scr = iter.data;
+
+  if (cn == NULL)
+    return NULL;
+
+  dispxcb = g_object_new (gdk_display_xcb_get_type (), NULL);
+  dispxcb->default_screen = gdk_screen_xcb_new ((GdkDisplay *) dispxcb, 0, scr);
+  dispxcb->cn = cn;
+
+  return (GdkDisplay *) dispxcb;
+}
+
+GdkScreen *
+gdk_display_get_default_screen (GdkDisplay *display)
+{
+  GdkDisplayXcb *dispxcb = (GdkDisplayXcb *) display;
+
+  return dispxcb->default_screen;
+}
diff --git a/gdk/xcb/dragcontext.c b/gdk/xcb/dragcontext.c
new file mode 100644
index 0000000..2b72fb7
--- /dev/null
+++ b/gdk/xcb/dragcontext.c
@@ -0,0 +1,13 @@
+#include "gdk.h"
+
+G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
+
+static void
+gdk_drag_context_init (GdkDragContext *context)
+{
+}
+
+static void
+gdk_drag_context_class_init (GdkDragContextClass *class)
+{
+}
diff --git a/gdk/xcb/init.c b/gdk/xcb/init.c
new file mode 100644
index 0000000..379d311
--- /dev/null
+++ b/gdk/xcb/init.c
@@ -0,0 +1,11 @@
+#include "gdk.h"
+
+void
+_gdk_windowing_init (void)
+{
+}
+
+void
+_gdk_windowing_set_default_display (GdkDisplay *disp)
+{
+}
diff --git a/gdk/xcb/nothing.c b/gdk/xcb/nothing.c
new file mode 100644
index 0000000..88334a0
--- /dev/null
+++ b/gdk/xcb/nothing.c
@@ -0,0 +1,154 @@
+#include <glib.h>
+
+/* from gdk */
+void _gdk_windowing_after_process_all_updates (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_get_input_shape (void) { g_assert_not_reached (); }
+void gdk_keymap_get_for_display (void) { g_assert_not_reached (); }
+void gdk_device_ungrab (void) { g_assert_not_reached (); }
+void gdk_display_get_name (void) { g_assert_not_reached (); }
+void _gdk_windowing_launch_failed (void) { g_assert_not_reached (); }
+void gdk_screen_get_height_mm (void) { g_assert_not_reached (); }
+void gdk_window_foreign_new_for_display (void) { g_assert_not_reached (); }
+void _gdk_windowing_substitute_screen_number (void) { g_assert_not_reached (); }
+void gdk_screen_get_n_monitors (void) { g_assert_not_reached (); }
+void gdk_screen_get_width_mm (void) { g_assert_not_reached (); }
+void gdk_cursor_new_for_display (void) { g_assert_not_reached (); }
+void _gdk_windowing_get_device_state (void) { g_assert_not_reached (); }
+void gdk_string_to_compound_text_for_display (void) { g_assert_not_reached (); }
+void gdk_text_property_to_text_list_for_display (void) { g_assert_not_reached (); }
+void gdk_drag_find_window_for_screen (void) { g_assert_not_reached (); }
+void gdk_display_supports_composite (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_destroy_foreign (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_get_next_serial (void) { g_assert_not_reached (); }
+void _gdk_events_queue (void) { g_assert_not_reached (); }
+void gdk_utf8_to_compound_text_for_display (void) { g_assert_not_reached (); }
+void gdk_display_beep (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_at_device_position (void) { g_assert_not_reached (); }
+void gdk_drag_get_protocol_for_display (void) { g_assert_not_reached (); }
+void gdk_input_set_extension_events (void) { g_assert_not_reached (); }
+void gdk_selection_send_notify_for_display (void) { g_assert_not_reached (); }
+void gdk_display_sync (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_process_updates_recurse (void) { g_assert_not_reached (); }
+void _gdk_cursor_destroy (void) { g_assert_not_reached (); }
+void gdk_screen_get_monitor_geometry (void) { g_assert_not_reached (); }
+void gdk_display_flush (void) { g_assert_not_reached (); }
+void gdk_screen_list_visuals (void) { g_assert_not_reached (); }
+void _gdk_windowing_get_startup_notify_id (void) { g_assert_not_reached (); }
+void _gdk_windowing_before_process_all_updates (void) { g_assert_not_reached (); }
+void gdk_screen_get_width (void) { g_assert_not_reached (); }
+void _gdk_windowing_event_data_free (void) { g_assert_not_reached (); }
+void gdk_selection_owner_set_for_display (void) { g_assert_not_reached (); }
+void _gdk_input_check_extension_events (void) { g_assert_not_reached (); }
+void _gdk_windowing_event_data_copy (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_set_composited (void) { g_assert_not_reached (); }
+void gdk_screen_make_display_name (void) { g_assert_not_reached (); }
+void _gdk_windowing_device_grab (void) { g_assert_not_reached (); }
+void *_gdk_windowing_args = NULL;
+void _gdk_windowing_window_beep (void) { g_assert_not_reached (); }
+void _gdk_windowing_display_set_sm_client_id (void) { g_assert_not_reached (); }
+void gdk_screen_get_height (void) { g_assert_not_reached (); }
+void gdk_screen_broadcast_client_message (void) { g_assert_not_reached (); }
+void gdk_selection_owner_get_for_display (void) { g_assert_not_reached (); }
+void gdk_screen_get_rgba_visual (void) { g_assert_not_reached (); }
+void _gdk_windowing_window_get_shape (void) { g_assert_not_reached (); }
+void gdk_event_send_client_message_for_display (void) { g_assert_not_reached (); }
+void gdk_text_property_to_utf8_list_for_display (void) { g_assert_not_reached (); }
+
+/* from gtk */
+void gdk_display_supports_selection_notification (void) { g_assert_not_reached (); }
+void gdk_keymap_get_entries_for_keycode (void) { g_assert_not_reached (); }
+void gdk_spawn_on_screen (void) { g_assert_not_reached (); }
+void gdk_keyval_name (void) { g_assert_not_reached (); }
+void gdk_drop_reply (void) { g_assert_not_reached (); }
+void gdk_window_lookup_for_display (void) { g_assert_not_reached (); }
+void gdk_keymap_get_entries_for_keyval (void) { g_assert_not_reached (); }
+void gdk_display_get_n_screens (void) { g_assert_not_reached (); }
+void gdk_display_request_selection_notification (void) { g_assert_not_reached (); }
+void gdk_keymap_get_caps_lock_state (void) { g_assert_not_reached (); }
+void gdk_window_begin_move_drag (void) { g_assert_not_reached (); }
+void gdk_drag_status (void) { g_assert_not_reached (); }
+void gdk_window_set_icon_list (void) { g_assert_not_reached (); }
+void gdk_window_set_keep_above (void) { g_assert_not_reached (); }
+void gdk_window_set_type_hint (void) { g_assert_not_reached (); }
+void gdk_keymap_get_num_lock_state (void) { g_assert_not_reached (); }
+void gdk_display_get_maximal_cursor_size (void) { g_assert_not_reached (); }
+void gdk_drag_context_get_device (void) { g_assert_not_reached (); }
+void gdk_notify_startup_complete (void) { g_assert_not_reached (); }
+void gdk_window_set_title (void) { g_assert_not_reached (); }
+void gdk_keymap_get_direction (void) { g_assert_not_reached (); }
+void gdk_flush (void) { g_assert_not_reached (); }
+void gdk_selection_property_get (void) { g_assert_not_reached (); }
+void gdk_drag_context_set_device (void) { g_assert_not_reached (); }
+void gdk_window_set_skip_taskbar_hint (void) { g_assert_not_reached (); }
+void gdk_window_unfullscreen (void) { g_assert_not_reached (); }
+void gdk_window_set_focus_on_map (void) { g_assert_not_reached (); }
+void gdk_window_enable_synchronized_configure (void) { g_assert_not_reached (); }
+void gdk_window_begin_resize_drag (void) { g_assert_not_reached (); }
+void gdk_property_change (void) { g_assert_not_reached (); }
+void gdk_window_set_decorations (void) { g_assert_not_reached (); }
+void gdk_window_set_role (void) { g_assert_not_reached (); }
+void gdk_cursor_get_display (void) { g_assert_not_reached (); }
+void gdk_window_set_transient_for (void) { g_assert_not_reached (); }
+void gdk_window_get_frame_extents (void) { g_assert_not_reached (); }
+void gdk_test_simulate_button (void) { g_assert_not_reached (); }
+void gdk_keyval_from_name (void) { g_assert_not_reached (); }
+void gdk_window_set_modal_hint (void) { g_assert_not_reached (); }
+void gdk_error_trap_pop_ignored (void) { g_assert_not_reached (); }
+void gdk_error_trap_pop (void) { g_assert_not_reached (); }
+void gdk_display_get_screen (void) { g_assert_not_reached (); }
+void gdk_display_store_clipboard (void) { g_assert_not_reached (); }
+void gdk_cursor_get_image (void) { g_assert_not_reached (); }
+void gdk_drag_motion (void) { g_assert_not_reached (); }
+void gdk_window_set_geometry_hints (void) { g_assert_not_reached (); }
+void gdk_atom_intern_static_string (void) { g_assert_not_reached (); }
+void gdk_error_trap_push (void) { g_assert_not_reached (); }
+void gdk_window_iconify (void) { g_assert_not_reached (); }
+void gdk_screen_is_composited (void) { g_assert_not_reached (); }
+void gdk_display_supports_cursor_color (void) { g_assert_not_reached (); }
+void gdk_window_unstick (void) { g_assert_not_reached (); }
+void gdk_window_set_opacity (void) { g_assert_not_reached (); }
+void gdk_window_fullscreen (void) { g_assert_not_reached (); }
+void gdk_window_set_startup_id (void) { g_assert_not_reached (); }
+void gdk_selection_convert (void) { g_assert_not_reached (); }
+void gdk_window_set_keep_below (void) { g_assert_not_reached (); }
+void gdk_window_register_dnd (void) { g_assert_not_reached (); }
+void gdk_window_deiconify (void) { g_assert_not_reached (); }
+void gdk_property_delete (void) { g_assert_not_reached (); }
+void gdk_window_set_accept_focus (void) { g_assert_not_reached (); }
+void gdk_window_set_urgency_hint (void) { g_assert_not_reached (); }
+void gdk_free_compound_text (void) { g_assert_not_reached (); }
+void gdk_window_maximize (void) { g_assert_not_reached (); }
+void gdk_drag_begin (void) { g_assert_not_reached (); }
+void gdk_drag_get_selection (void) { g_assert_not_reached (); }
+void gdk_window_set_functions (void) { g_assert_not_reached (); }
+void gdk_drag_drop (void) { g_assert_not_reached (); }
+void gdk_cursor_new_from_pixbuf (void) { g_assert_not_reached (); }
+void gdk_test_simulate_key (void) { g_assert_not_reached (); }
+void gdk_utf8_to_string_target (void) { g_assert_not_reached (); }
+void gdk_display_supports_clipboard_persistence (void) { g_assert_not_reached (); }
+void gdk_keymap_map_virtual_modifiers (void) { g_assert_not_reached (); }
+void gdk_window_stick (void) { g_assert_not_reached (); }
+void gdk_display_warp_device (void) { g_assert_not_reached (); }
+void gdk_drag_abort (void) { g_assert_not_reached (); }
+void gdk_window_unmaximize (void) { g_assert_not_reached (); }
+void gdk_cursor_new_from_name (void) { g_assert_not_reached (); }
+void gdk_display_get_default_cursor_size (void) { g_assert_not_reached (); }
+void gdk_set_locale (void) { g_assert_not_reached (); }
+void gdk_window_set_skip_pager_hint (void) { g_assert_not_reached (); }
+void gdk_keymap_add_virtual_modifiers (void) { g_assert_not_reached (); }
+void gdk_window_configure_finished (void) { g_assert_not_reached (); }
+void gdk_atom_name (void) { g_assert_not_reached (); }
+void gdk_property_get (void) { g_assert_not_reached (); }
+void gdk_window_focus (void) { g_assert_not_reached (); }
+void gdk_keymap_translate_keyboard_state (void) { g_assert_not_reached (); }
+void gdk_drop_finish (void) { g_assert_not_reached (); }
+void gdk_atom_intern (void) { g_assert_not_reached (); }
+void gdk_display_supports_cursor_alpha (void) { g_assert_not_reached (); }
+void gdk_notify_startup_complete_with_id (void) { g_assert_not_reached (); }
+
+/* other stuff */
+void gdk_test_render_sync (void) { g_assert_not_reached (); }
+void gdk_display_add_client_message_filter (void) { g_assert_not_reached (); }
+void gdk_screen_get_primary_monitor (void) { g_assert_not_reached (); }
+void gdk_window_get_root_origin (void) { g_assert_not_reached (); }
+void gdk_window_set_icon_name (void) { g_assert_not_reached (); }
diff --git a/gdk/xcb/screen.c b/gdk/xcb/screen.c
new file mode 100644
index 0000000..5ff2bfa
--- /dev/null
+++ b/gdk/xcb/screen.c
@@ -0,0 +1,93 @@
+#include "gdk.h"
+#include "gdkinternals.h"
+#include "visual.h"
+
+#include <xcb/xcb.h>
+
+typedef GdkScreenClass GdkScreenXcbClass;
+
+typedef struct
+{
+  GdkScreen parent_instance;
+
+  GdkVisual *system_visual;
+  GdkWindow *root_window;
+  GdkDisplay *display;
+
+  xcb_screen_t *scr;
+  gint number;
+} GdkScreenXcb;
+
+static GType gdk_screen_xcb_get_type (void);
+G_DEFINE_TYPE (GdkScreenXcb, gdk_screen_xcb, GDK_TYPE_SCREEN)
+
+static void
+gdk_screen_xcb_init (GdkScreenXcb *scrxcb)
+{
+}
+
+static void
+gdk_screen_xcb_class_init (GdkScreenXcbClass *class)
+{
+}
+
+gboolean
+gdk_screen_get_setting (GdkScreen   *screen,
+                        const gchar *name,
+                        GValue      *value)
+{
+  return FALSE;
+}
+
+GdkDisplay *
+gdk_screen_get_display (GdkScreen *screen)
+{
+  GdkScreenXcb *scrxcb = (GdkScreenXcb *) screen;
+
+  return scrxcb->display;
+}
+
+int
+gdk_screen_get_number (GdkScreen *screen)
+{
+  GdkScreenXcb *scrxcb = (GdkScreenXcb *) screen;
+
+  return scrxcb->number;
+}
+
+GdkVisual *
+gdk_screen_get_system_visual (GdkScreen *screen)
+{
+  GdkScreenXcb *scrxcb = (GdkScreenXcb *) screen;
+
+  return scrxcb->system_visual;
+}
+
+GdkWindow *
+gdk_screen_get_root_window (GdkScreen *screen)
+{
+  GdkScreenXcb *scrxcb = (GdkScreenXcb *) screen;
+
+  return scrxcb->root_window;
+}
+
+GdkScreenXcb *
+gdk_screen_xcb_new (GdkDisplay   *display,
+                    gint          number,
+                    xcb_screen_t *scr)
+{
+  GdkWindowObject *private;
+  GdkScreenXcb *scrxcb;
+
+  scrxcb = g_object_new (gdk_screen_xcb_get_type (), NULL);
+  scrxcb->system_visual = gdk_visual_xcb_new (GDK_SCREEN (scrxcb));
+  scrxcb->root_window = g_object_new (GDK_TYPE_WINDOW, NULL);
+  private = (GdkWindowObject *) scrxcb->root_window;
+  private->visual = scrxcb->system_visual;
+  private->window_type = GDK_WINDOW_ROOT;
+  scrxcb->display = display;
+  scrxcb->number = number;
+  scrxcb->scr = scr;
+
+  return scrxcb;
+}
diff --git a/gdk/xcb/screen.h b/gdk/xcb/screen.h
new file mode 100644
index 0000000..7e2f405
--- /dev/null
+++ b/gdk/xcb/screen.h
@@ -0,0 +1,6 @@
+#include <xcb/xcb.h>
+
+GdkScreen *
+gdk_screen_xcb_new (GdkDisplay   *display,
+                    gint          number,
+                    xcb_screen_t *scr);
diff --git a/gdk/xcb/visual.c b/gdk/xcb/visual.c
new file mode 100644
index 0000000..c59d482
--- /dev/null
+++ b/gdk/xcb/visual.c
@@ -0,0 +1,43 @@
+#include "visual.h"
+#include "gdk.h"
+
+struct _GdkVisualClass {
+  GObjectClass parent_class;
+};
+
+struct _GdkVisualPrivate {
+  GdkScreen *screen;
+};
+
+G_DEFINE_TYPE (GdkVisual, gdk_visual, G_TYPE_OBJECT)
+
+static void
+gdk_visual_init (GdkVisual *visual)
+{
+  visual->priv = G_TYPE_INSTANCE_GET_PRIVATE (visual,
+                                              GDK_TYPE_VISUAL,
+                                              GdkVisualPrivate);
+}
+
+static void
+gdk_visual_class_init (GdkVisualClass *class)
+{
+  g_type_class_add_private (class, sizeof (GdkVisualPrivate));
+}
+
+GdkScreen *
+gdk_visual_get_screen (GdkVisual *visual)
+{
+  return visual->priv->screen;
+}
+
+GdkVisual *
+gdk_visual_xcb_new (GdkScreen *screen)
+{
+  GdkVisual *visual;
+
+  visual = g_object_new (gdk_visual_get_type (), NULL);
+  visual->priv->screen = screen;
+
+  return visual;
+}
diff --git a/gdk/xcb/visual.h b/gdk/xcb/visual.h
new file mode 100644
index 0000000..2e257b2
--- /dev/null
+++ b/gdk/xcb/visual.h
@@ -0,0 +1,4 @@
+#include "gdk.h"
+
+GdkVisual *
+gdk_visual_xcb_new (GdkScreen *screen);
diff --git a/gdk/xcb/window.c b/gdk/xcb/window.c
new file mode 100644
index 0000000..c09fc92
--- /dev/null
+++ b/gdk/xcb/window.c
@@ -0,0 +1,48 @@
+#include "gdkwindowimpl.h"
+#include "gdkinternals.h"
+
+typedef struct
+{
+  GObject parent_instance;
+} GdkWindowImplXcb;
+
+typedef struct
+{
+  GObjectClass parent_class;
+} GdkWindowImplXcbClass;
+
+static void gdk_window_impl_iface_init (GdkWindowImplIface *iface);
+static GType gdk_window_impl_xcb_get_type (void);
+G_DEFINE_TYPE_WITH_CODE (GdkWindowImplXcb,
+                         gdk_window_impl_xcb,
+                         G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (GDK_TYPE_WINDOW_IMPL,
+                                                gdk_window_impl_iface_init))
+
+static void
+gdk_window_impl_xcb_init (GdkWindowImplXcb *implxcb)
+{
+}
+
+static void
+gdk_window_impl_xcb_class_init (GdkWindowImplXcbClass *class)
+{
+}
+
+static void
+gdk_window_impl_iface_init (GdkWindowImplIface *iface)
+{
+}
+
+void
+_gdk_window_impl_new (GdkWindow *window,
+                      GdkWindow *real_parent,
+                      GdkScreen *screen,
+                      GdkEventMask event_mask,
+                      GdkWindowAttr *attributes,
+                      gint attributes_mask)
+{
+  GdkWindowObject *private = (GdkWindowObject *) window;
+
+  private->impl = g_object_new (gdk_window_impl_xcb_get_type (), NULL);
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]