Add Wayland backend

This commit is contained in:
Kristian Høgsberg
2010-12-18 15:38:49 -05:00
parent bfaf472e70
commit 590f3dfa1f
26 changed files with 5444 additions and 7 deletions

View File

@ -55,11 +55,11 @@ MAINTAINERCLEANFILES = \
## Copy .pc files to target-specific names
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc: gtk+-3.0.pc
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-wayland-3.0.pc: gtk+-3.0.pc
rm -f $@ && \
cp gtk+-3.0.pc $@
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc: gdk-3.0.pc
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-wayland-3.0.pc: gdk-3.0.pc
rm -f $@ && \
cp gdk-3.0.pc $@

View File

@ -290,6 +290,10 @@ AC_ARG_ENABLE(quartz-backend,
[AC_HELP_STRING([--enable-quartz-backend],
[enable the quartz gdk backend])],
[backend_set=yes])
AC_ARG_ENABLE(wayland-backend,
[AC_HELP_STRING([--enable-wayland-backend],
[enable the wayland gdk backend])],
[backend_set=yes])
if test -z "$backend_set"; then
if test "$platform_win32" = yes; then
@ -345,6 +349,19 @@ else
AM_CONDITIONAL(USE_QUARTZ, false)
fi
if test "x$enable_wayland_backend" == "xyes"; then
# Wayland uses cairo-gl
cairo_backends="$cairo_backends cairo-gl"
GDK_BACKENDS="$GDK_BACKENDS wayland"
GIO_PACKAGE=gio-unix-2.0
GDK_WINDOWING="$GDK_WINDOWING
#define GDK_WINDOWING_WAYLAND"
WAYLAND_PACKAGES="wayland-client xkbcommon"
AM_CONDITIONAL(USE_WAYLAND, true)
else
AM_CONDITIONAL(USE_WAYLAND, false)
fi
# strip leading space
GDK_BACKENDS=${GDK_BACKENDS/# }
@ -1244,7 +1261,7 @@ fi
CFLAGS="$saved_cflags"
LDFLAGS="$saved_ldflags"
GDK_PACKAGES="$PANGO_PACKAGES $GIO_PACKAGE $X_PACKAGES gdk-pixbuf-2.0 $cairo_backends cairo-gobject"
GDK_PACKAGES="$PANGO_PACKAGES $GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES gdk-pixbuf-2.0 $cairo_backends cairo-gobject"
GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PACKAGES`"
GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PACKAGES` $GDK_EXTRA_CFLAGS"
@ -1668,6 +1685,7 @@ gdk/win32/Makefile
gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/quartz/Makefile
gdk/wayland/Makefile
gdk/tests/Makefile
gtk/Makefile
gtk/makefile.msc

View File

@ -11,7 +11,7 @@ INTROSPECTION_COMPILER_ARGS = \
SUBDIRS = $(GDK_BACKENDS) . tests
DIST_SUBDIRS = win32 x11 quartz tests
DIST_SUBDIRS = win32 x11 quartz wayland tests
CLEANFILES =
@ -176,6 +176,10 @@ libgdk_3_0_la_DEPENDENCIES = win32/libgdk-win32.la win32/rc/gdk-win32-res.o gdk.
libgdk_3_0_la_LDFLAGS += -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def
endif # USE_WIN32
if USE_WAYLAND
libgdk_3_0_la_LIBADD += wayland/libgdk-wayland.la
endif
if HAVE_INTROSPECTION
introspection_files = \

View File

@ -48,6 +48,10 @@
#include "win32/gdkwin32.h"
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
#endif
/**
* SECTION:gdkdisplaymanager
* @Short_description: Maintains a list of all open GdkDisplays
@ -202,6 +206,11 @@ gdk_display_manager_get (void)
if (backend == NULL || strcmp (backend, "win32") == 0)
manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (backend == NULL || strcmp (backend, "wayland") == 0)
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
else
#endif
if (backend != NULL)
g_error ("Unsupported GDK backend: %s", backend);

45
gdk/wayland/Makefile.am Normal file
View File

@ -0,0 +1,45 @@
## Process this file with automake to produce Makefile.in
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-wayland.la
libgdk_wayland_la_SOURCES = \
gdkapplaunchcontext-wayland.c \
gdkcursor-wayland.c \
gdkdevice-wayland.h \
gdkdevice-wayland.c \
gdkdevicemanager-wayland.h \
gdkdevicemanager-wayland.c \
gdkdisplay-wayland.c \
gdkdisplay-wayland.h \
gdkdisplaymanager-wayland.c \
gdkdnd-wayland.c \
gdkeventsource.c \
gdkeventsource.h \
gdkkeys-wayland.c \
gdkscreen-wayland.c \
gdkscreen-wayland.h \
gdkselection-wayland.c \
gdkwindow-wayland.c \
gdkwindow-wayland.h \
gdkwayland.h \
gdkprivate-wayland.h
libgdkinclude_HEADERS = \
gdkwayland.h
-include $(top_srcdir)/git.mk

View File

@ -0,0 +1,90 @@
/*
* Copyright © 2010 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <gio/gdesktopappinfo.h>
#include "gdkwayland.h"
#include "gdkprivate-wayland.h"
#include "gdkapplaunchcontextprivate.h"
#include "gdkscreen.h"
#include "gdkinternals.h"
#include "gdkintl.h"
static char *
gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
GAppInfo *info,
GList *files)
{
return NULL;
}
static void
gdk_wayland_app_launch_context_launch_failed (GAppLaunchContext *context,
const char *startup_notify_id)
{
}
typedef struct _GdkWaylandAppLaunchContext GdkWaylandAppLaunchContext;
typedef struct _GdkWaylandAppLaunchContextClass GdkWaylandAppLaunchContextClass;
struct _GdkWaylandAppLaunchContext
{
GdkAppLaunchContext base;
gchar *name;
guint serial;
};
struct _GdkWaylandAppLaunchContextClass
{
GdkAppLaunchContextClass base_class;
};
G_DEFINE_TYPE (GdkWaylandAppLaunchContext, gdk_wayland_app_launch_context, GDK_TYPE_APP_LAUNCH_CONTEXT)
static void
gdk_wayland_app_launch_context_class_init (GdkWaylandAppLaunchContextClass *klass)
{
GAppLaunchContextClass *ctx_class = G_APP_LAUNCH_CONTEXT_CLASS (klass);
ctx_class->get_startup_notify_id = gdk_wayland_app_launch_context_get_startup_notify_id;
ctx_class->launch_failed = gdk_wayland_app_launch_context_launch_failed;
}
static void
gdk_wayland_app_launch_context_init (GdkWaylandAppLaunchContext *ctx)
{
}
GdkAppLaunchContext *
_gdk_wayland_display_get_app_launch_context (GdkDisplay *display)
{
GdkAppLaunchContext *ctx;
ctx = g_object_new (gdk_wayland_app_launch_context_get_type (),
"display", display,
NULL);
return ctx;
}

View File

@ -0,0 +1,184 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#define GDK_PIXBUF_ENABLE_BACKEND
#include <string.h>
#include "gdkprivate-wayland.h"
#include "gdkcursorprivate.h"
#include "gdkdisplay-wayland.h"
#include "gdkwayland.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#define GDK_TYPE_WAYLAND_CURSOR (_gdk_wayland_cursor_get_type ())
#define GDK_WAYLAND_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_CURSOR, GdkWaylandCursor))
#define GDK_WAYLAND_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_CURSOR, GdkWaylandCursorClass))
#define GDK_IS_WAYLAND_CURSOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_CURSOR))
#define GDK_IS_WAYLAND_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_CURSOR))
#define GDK_WAYLAND_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_CURSOR, GdkWaylandCursorClass))
typedef struct _GdkWaylandCursor GdkWaylandCursor;
typedef struct _GdkWaylandCursorClass GdkWaylandCursorClass;
struct _GdkWaylandCursor
{
GdkCursor cursor;
gchar *name;
guint serial;
};
struct _GdkWaylandCursorClass
{
GdkCursorClass cursor_class;
};
G_DEFINE_TYPE (GdkWaylandCursor, _gdk_wayland_cursor, GDK_TYPE_CURSOR)
static guint theme_serial = 0;
static void
gdk_wayland_cursor_finalize (GObject *object)
{
GdkWaylandCursor *cursor = GDK_WAYLAND_CURSOR (object);
g_free (cursor->name);
G_OBJECT_CLASS (_gdk_wayland_cursor_parent_class)->finalize (object);
}
static GdkPixbuf*
gdk_wayland_cursor_get_image (GdkCursor *cursor)
{
return NULL;
}
static void
_gdk_wayland_cursor_class_init (GdkWaylandCursorClass *wayland_cursor_class)
{
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (wayland_cursor_class);
GObjectClass *object_class = G_OBJECT_CLASS (wayland_cursor_class);
object_class->finalize = gdk_wayland_cursor_finalize;
cursor_class->get_image = gdk_wayland_cursor_get_image;
}
static void
_gdk_wayland_cursor_init (GdkWaylandCursor *cursor)
{
}
GdkCursor*
_gdk_wayland_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type)
{
GdkWaylandCursor *private;
private = g_object_new (GDK_TYPE_WAYLAND_CURSOR,
"cursor-type", GDK_CURSOR_IS_PIXMAP,
"display", display,
NULL);
private->name = NULL;
private->serial = theme_serial;
return GDK_CURSOR (private);
}
GdkCursor*
_gdk_wayland_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name)
{
GdkWaylandCursor *private;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
private = g_object_new (GDK_TYPE_WAYLAND_CURSOR,
"cursor-type", GDK_CURSOR_IS_PIXMAP,
"display", display,
NULL);
private->name = g_strdup (name);
private->serial = theme_serial;
return GDK_CURSOR (private);
}
GdkCursor *
_gdk_wayland_display_get_cursor_for_pixbuf (GdkDisplay *display,
GdkPixbuf *pixbuf,
gint x,
gint y)
{
GdkWaylandCursor *private;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
private = g_object_new (GDK_TYPE_WAYLAND_CURSOR,
"cursor-type", GDK_CURSOR_IS_PIXMAP,
"display", display,
NULL);
private->name = NULL;
private->serial = theme_serial;
return GDK_CURSOR (private);
}
void
_gdk_wayland_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
/* FIXME: wayland settings? */
*width = 64;
*height = 64;
}
void
_gdk_wayland_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
*width = 256;
*height = 256;
}
gboolean
_gdk_wayland_display_supports_cursor_alpha (GdkDisplay *display)
{
return TRUE;
}
gboolean
_gdk_wayland_display_supports_cursor_color (GdkDisplay *display)
{
return TRUE;
}

View File

@ -0,0 +1,216 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gdk/gdkwindow.h>
#include "gdkdevice-wayland.h"
#include "gdkprivate-wayland.h"
#include "gdkwayland.h"
static gboolean gdk_device_core_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
static void gdk_device_core_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask);
static void gdk_device_core_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor);
static void gdk_device_core_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y);
static gboolean gdk_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_core_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_);
static void gdk_device_core_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_core_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_core_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask);
G_DEFINE_TYPE (GdkDeviceCore, gdk_device_core, GDK_TYPE_DEVICE)
static void
gdk_device_core_class_init (GdkDeviceCoreClass *klass)
{
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->get_history = gdk_device_core_get_history;
device_class->get_state = gdk_device_core_get_state;
device_class->set_window_cursor = gdk_device_core_set_window_cursor;
device_class->warp = gdk_device_core_warp;
device_class->query_state = gdk_device_core_query_state;
device_class->grab = gdk_device_core_grab;
device_class->ungrab = gdk_device_core_ungrab;
device_class->window_at_position = gdk_device_core_window_at_position;
device_class->select_window_events = gdk_device_core_select_window_events;
}
static void
gdk_device_core_init (GdkDeviceCore *device_core)
{
GdkDevice *device;
device = GDK_DEVICE (device_core);
_gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_X, 0, 0, 1);
_gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_Y, 0, 0, 1);
}
static gboolean
gdk_device_core_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
return FALSE;
}
static void
gdk_device_core_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
gint x_int, y_int;
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (axes)
{
axes[0] = x_int;
axes[1] = y_int;
}
}
static void
gdk_device_core_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor)
{
}
static void
gdk_device_core_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y)
{
}
static gboolean
gdk_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask)
{
GdkWaylandDevice *wd;
GdkScreen *default_screen;
wd = GDK_DEVICE_CORE(device)->device;
default_screen = gdk_display_get_default_screen (wd->display);
if (root_window)
*root_window = gdk_screen_get_root_window (default_screen);
if (child_window)
*child_window = wd->pointer_focus;
if (root_x)
*root_x = wd->x;
if (root_y)
*root_y = wd->y;
if (win_x)
*win_x = wd->surface_x;
if (win_y)
*win_y = wd->surface_y;
if (mask)
*mask = wd->modifiers;
return TRUE;
}
static GdkGrabStatus
gdk_device_core_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_)
{
return GDK_GRAB_SUCCESS;
}
static void
gdk_device_core_ungrab (GdkDevice *device,
guint32 time_)
{
}
static GdkWindow *
gdk_device_core_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
GdkWaylandDevice *wd;
wd = GDK_DEVICE_CORE(device)->device;
return wd->pointer_focus;
}
static void
gdk_device_core_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask)
{
}

View File

@ -0,0 +1,68 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_CORE_H__
#define __GDK_DEVICE_CORE_H__
#include <gdk/gdkdeviceprivate.h>
#include <X11/extensions/XKBcommon.h>
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_CORE (gdk_device_core_get_type ())
#define GDK_DEVICE_CORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_CORE, GdkDeviceCore))
#define GDK_DEVICE_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_CORE, GdkDeviceCoreClass))
#define GDK_IS_DEVICE_CORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_CORE))
#define GDK_IS_DEVICE_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_CORE))
#define GDK_DEVICE_CORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_CORE, GdkDeviceCoreClass))
typedef struct _GdkDeviceCore GdkDeviceCore;
typedef struct _GdkDeviceCoreClass GdkDeviceCoreClass;
typedef struct _GdkWaylandDevice GdkWaylandDevice;
struct _GdkWaylandDevice
{
GdkDisplay *display;
GdkDevice *pointer;
GdkDevice *keyboard;
GdkModifierType modifiers;
GdkWindow *pointer_focus;
GdkWindow *keyboard_focus;
struct wl_input_device *device;
struct xkb_desc *xkb;
int32_t x, y, surface_x, surface_y;
};
struct _GdkDeviceCore
{
GdkDevice parent_instance;
GdkWaylandDevice *device;
};
struct _GdkDeviceCoreClass
{
GdkDeviceClass parent_class;
};
G_GNUC_INTERNAL
GType gdk_device_core_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_DEVICE_CORE_H__ */

View File

@ -0,0 +1,443 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkdevicemanager.h>
#include "gdkdevicemanager-wayland.h"
#include "gdkdevice-wayland.h"
#include "gdkkeysyms.h"
#include "gdkprivate-wayland.h"
#include "gdkeventsource.h"
static void gdk_device_manager_core_finalize (GObject *object);
static GList * gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager);
G_DEFINE_TYPE (GdkDeviceManagerCore, gdk_device_manager_core, GDK_TYPE_DEVICE_MANAGER)
static void
gdk_device_manager_core_class_init (GdkDeviceManagerCoreClass *klass)
{
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gdk_device_manager_core_finalize;
device_manager_class->list_devices = gdk_device_manager_core_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_core_get_client_pointer;
}
static void
input_handle_motion(void *data, struct wl_input_device *input_device,
uint32_t time,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
event = gdk_event_new (GDK_NOTHING);
device->x = x;
device->y = y;
device->surface_x = sx;
device->surface_y = sy;
event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = g_object_ref (device->pointer_focus);
gdk_event_set_device (event, device->pointer);
event->motion.time = time;
event->motion.x = (gdouble) sx;
event->motion.y = (gdouble) sy;
event->motion.x_root = (gdouble) x;
event->motion.y_root = (gdouble) y;
event->motion.axes = NULL;
event->motion.state = device->modifiers;
event->motion.is_hint = 0;
_gdk_wayland_display_deliver_event (device->display, event);
}
static void
input_handle_button(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t button, uint32_t state)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
uint32_t modifier;
fprintf (stderr, "button event %d, state %d\n", button, state);
event = gdk_event_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
event->button.window = g_object_ref (device->pointer_focus);
gdk_event_set_device (event, device->pointer);
event->button.time = time;
event->button.x = (gdouble) device->surface_x;
event->button.y = (gdouble) device->surface_y;
event->button.x_root = (gdouble) device->x;
event->button.y_root = (gdouble) device->y;
event->button.axes = NULL;
event->button.state = device->modifiers;
event->button.button = button - 271;
modifier = 1 << (8 + button - 272);
if (state)
device->modifiers |= modifier;
else
device->modifiers &= ~modifier;
_gdk_wayland_display_deliver_event (device->display, event);
}
static void
input_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
uint32_t code, modifier, level;
event = gdk_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
event->key.window = g_object_ref (device->keyboard_focus);
gdk_event_set_device (event, device->keyboard);
event->button.time = time;
event->key.state = device->modifiers;
event->key.group = 0;
event->key.hardware_keycode = key;
code = key + device->xkb->min_key_code;
level = 0;
if (device->modifiers & ShiftMask &&
XkbKeyGroupWidth(device->xkb, code, 0) > 1)
level = 1;
event->key.keyval = XkbKeySymEntry(device->xkb, code, level, 0);
modifier = device->xkb->map->modmap[code];
if (state)
device->modifiers |= modifier;
else
device->modifiers &= ~modifier;
event->key.is_modifier = modifier > 0;
if (event->key.keyval == GDK_KEY_Escape)
{
event->key.length = 1;
event->key.string = g_strdup ("\033");
}
else if (event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_KP_Enter)
{
event->key.length = 1;
event->key.string = g_strdup ("\r");
}
else if (event->key.state & GDK_CONTROL_MASK)
{
gsize bytes_written;
gint len;
gchar buf[7];
int c = event->key.keyval;
/* Apply the control key - Taken from Xlib */
if ((c >= XK_at && c < '\177') || c == ' ')
c &= 0x1F;
else if (c == XK_2)
{
event->key.string = g_memdup ("\0\0", 2);
event->key.length = 1;
buf[0] = '\0';
goto out;
}
else if (c >= XK_3 && c <= XK_7)
c -= (XK_3 - '\033');
else if (c == XK_8)
c = '\177';
else if (c == XK_slash)
c = '_' & 0x1F;
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->key.string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->key.string)
event->key.length = bytes_written;
}
else
{
char buffer[128];
xkb_keysym_to_string(event->key.keyval, buffer, sizeof buffer);
event->key.string = g_strdup (buffer);
event->key.length = strlen(event->key.string);
}
out:
_gdk_wayland_display_deliver_event (device->display, event);
fprintf (stderr, "keyboard event, code %d, sym %d, string %s, mods 0x%x\n",
code, event->key.keyval, event->key.string, event->key.state);
}
static void
input_handle_pointer_focus(void *data,
struct wl_input_device *input_device,
uint32_t time, struct wl_surface *surface,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
if (device->pointer_focus)
{
event = gdk_event_new (GDK_LEAVE_NOTIFY);
event->crossing.window = g_object_ref (device->pointer_focus);
gdk_event_set_device (event, device->pointer);
event->crossing.subwindow = NULL;
event->crossing.time = time;
event->crossing.x = (gdouble) device->surface_x;
event->crossing.y = (gdouble) device->surface_y;
event->crossing.x_root = (gdouble) device->x;
event->crossing.y_root = (gdouble) device->y;
event->crossing.mode = GDK_CROSSING_NORMAL;
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
event->crossing.focus = TRUE;
event->crossing.state = 0;
_gdk_wayland_display_deliver_event (device->display, event);
g_object_unref(device->pointer_focus);
device->pointer_focus = NULL;
}
if (surface)
{
device->pointer_focus = wl_surface_get_user_data(surface);
g_object_ref(device->pointer_focus);
event = gdk_event_new (GDK_ENTER_NOTIFY);
event->crossing.window = g_object_ref (device->pointer_focus);
gdk_event_set_device (event, device->pointer);
event->crossing.subwindow = NULL;
event->crossing.time = time;
event->crossing.x = (gdouble) sx;
event->crossing.y = (gdouble) sy;
event->crossing.x_root = (gdouble) x;
event->crossing.y_root = (gdouble) y;
event->crossing.mode = GDK_CROSSING_NORMAL;
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
event->crossing.focus = TRUE;
event->crossing.state = 0;
device->surface_x = sx;
device->surface_y = sy;
device->x = x;
device->y = y;
_gdk_wayland_display_deliver_event (device->display, event);
}
fprintf (stderr, "pointer focus surface %p, window %p\n",
surface, device->pointer_focus);
}
static void
update_modifiers(GdkWaylandDevice *device, struct wl_array *keys)
{
uint32_t *k, *end;
end = keys->data + keys->size;
for (k = keys->data; k < end; k++)
device->modifiers |= device->xkb->map->modmap[*k];
fprintf (stderr, "modifiers: 0x%x\n", device->modifiers);
}
static void
input_handle_keyboard_focus(void *data,
struct wl_input_device *input_device,
uint32_t time,
struct wl_surface *surface,
struct wl_array *keys)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
fprintf (stderr, "keyboard focus surface %p\n", surface);
if (device->keyboard_focus)
{
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (device->keyboard_focus);
event->focus_change.send_event = FALSE;
event->focus_change.in = FALSE;
gdk_event_set_device (event, device->keyboard);
g_object_unref(device->pointer_focus);
device->keyboard_focus = NULL;
_gdk_wayland_display_deliver_event (device->display, event);
}
if (surface)
{
device->keyboard_focus = wl_surface_get_user_data(surface);
g_object_ref(device->keyboard_focus);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (device->keyboard_focus);
event->focus_change.send_event = FALSE;
event->focus_change.in = TRUE;
gdk_event_set_device (event, device->keyboard);
update_modifiers (device, keys);
_gdk_wayland_display_deliver_event (device->display, event);
}
}
static const struct wl_input_device_listener input_device_listener = {
input_handle_motion,
input_handle_button,
input_handle_key,
input_handle_pointer_focus,
input_handle_keyboard_focus,
};
void
gdk_device_manager_core_add_device (GdkDeviceManager *device_manager,
struct wl_input_device *wl_device)
{
GdkDisplay *display;
GdkDeviceManagerCore *device_manager_core =
GDK_DEVICE_MANAGER_CORE(device_manager);
struct xkb_rule_names names;
GdkWaylandDevice *device;
device = g_new0 (GdkWaylandDevice, 1);
display = gdk_device_manager_get_display (device_manager);
device->display = display;
device->pointer = g_object_new (GDK_TYPE_DEVICE_CORE,
"name", "Core Pointer",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_MOUSE,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", TRUE,
"display", display,
"device-manager", device_manager,
NULL);
device->keyboard = g_object_new (GDK_TYPE_DEVICE_CORE,
"name", "Core Keyboard",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_KEYBOARD,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", FALSE,
"display", display,
"device-manager", device_manager,
NULL);
GDK_DEVICE_CORE (device->pointer)->device = device;
GDK_DEVICE_CORE (device->keyboard)->device = device;
device->device = wl_device;
names.rules = "evdev";
names.model = "pc105";
names.layout = "us";
names.variant = "";
names.options = "";
device->xkb = xkb_compile_keymap_from_rules(&names);
wl_input_device_add_listener(device->device,
&input_device_listener, device);
device_manager_core->devices =
g_list_prepend (device_manager_core->devices, device->keyboard);
device_manager_core->devices =
g_list_prepend (device_manager_core->devices, device->pointer);
_gdk_device_set_associated_device (device->pointer, device->keyboard);
_gdk_device_set_associated_device (device->keyboard, device->pointer);
}
static void
gdk_device_manager_core_init (GdkDeviceManagerCore *device_manager)
{
}
static void
free_device (void *data, void *user_data)
{
g_object_unref (data);
}
static void
gdk_device_manager_core_finalize (GObject *object)
{
GdkDeviceManagerCore *device_manager_core;
device_manager_core = GDK_DEVICE_MANAGER_CORE (object);
g_list_foreach (device_manager_core->devices, free_device, NULL);
g_list_free (device_manager_core->devices);
G_OBJECT_CLASS (gdk_device_manager_core_parent_class)->finalize (object);
}
static GList *
gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type)
{
GdkDeviceManagerCore *device_manager_core;
GList *devices = NULL;
if (type == GDK_DEVICE_TYPE_MASTER)
{
device_manager_core = (GdkDeviceManagerCore *) device_manager;
devices = g_list_copy(device_manager_core->devices);
}
return devices;
}
static GdkDevice *
gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkDeviceManagerCore *device_manager_core;
device_manager_core = (GdkDeviceManagerCore *) device_manager;
return device_manager_core->devices->data;
}
GdkDeviceManager *
_gdk_device_manager_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_DEVICE_MANAGER_CORE,
"display", display,
NULL);
}

View File

@ -0,0 +1,59 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_MANAGER_CORE_H__
#define __GDK_DEVICE_MANAGER_CORE_H__
#include <gdk/gdkdevicemanagerprivate.h>
#include <wayland-client.h>
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_MANAGER_CORE (gdk_device_manager_core_get_type ())
#define GDK_DEVICE_MANAGER_CORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_MANAGER_CORE, GdkDeviceManagerCore))
#define GDK_DEVICE_MANAGER_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_MANAGER_CORE, GdkDeviceManagerCoreClass))
#define GDK_IS_DEVICE_MANAGER_CORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_MANAGER_CORE))
#define GDK_IS_DEVICE_MANAGER_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_MANAGER_CORE))
#define GDK_DEVICE_MANAGER_CORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_MANAGER_CORE, GdkDeviceManagerCoreClass))
typedef struct _GdkDeviceManagerCore GdkDeviceManagerCore;
typedef struct _GdkDeviceManagerCoreClass GdkDeviceManagerCoreClass;
struct _GdkDeviceManagerCore
{
GdkDeviceManager parent_object;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
GList *devices;
};
struct _GdkDeviceManagerCoreClass
{
GdkDeviceManagerClass parent_class;
};
GType gdk_device_manager_core_get_type (void) G_GNUC_CONST;
void
gdk_device_manager_core_add_device (GdkDeviceManager *device_manager,
struct wl_input_device *device);
G_END_DECLS
#endif /* __GDK_DEVICE_MANAGER_CORE_H__ */

View File

@ -0,0 +1,795 @@
/*
* Copyright © 2010 Intel Corporation
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#define EGL_EGLEXT_PROTOTYPES 1
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <glib.h>
#include "gdkwayland.h"
#include "gdkdisplay.h"
#include "gdkdisplay-wayland.h"
#include "gdkeventsource.h"
#include "gdkscreen.h"
#include "gdkscreen-wayland.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
#include "gdkdevicemanager.h"
#include "gdkdevicemanager-wayland.h"
#include "gdkkeysprivate.h"
#include <xf86drm.h>
typedef struct _GdkEventTypeWayland GdkEventTypeWayland;
struct _GdkEventTypeWayland
{
gint base;
gint n_events;
};
G_DEFINE_TYPE (GdkDisplayWayland, _gdk_display_wayland, GDK_TYPE_DISPLAY)
/* GDK_VISIBILITY,
* GDK_MAP,
* GDK_UNMAP,
* GDK_PROPERTY_NOTIFY
* GDK_SELECTION_CLEAR
* GDK_SELECTION_ REQUEST
* GDK_SELECTION_NOTIFY
* GDK_CLIENT_EVENT,
*
* new keyboard mapping: _gdk_keymap_keys_changed (display);
*
* Selection owner change: GDK_OWNER_CHANGE;
*
* Screen size changes: _gdk_wayland_screen_size_changed (screen, xevent);
*
* XkbStateNotify: _gdk_keymap_state_changed (display, xevent);
*/
static void
gdk_input_init (GdkDisplay *display)
{
GdkDisplayWayland *display_wayland;
GdkDeviceManager *device_manager;
GdkDevice *device;
GList *list, *l;
display_wayland = GDK_DISPLAY_WAYLAND (display);
device_manager = gdk_display_get_device_manager (display);
/* For backwards compatibility, just add
* floating devices that are not keyboards.
*/
list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
for (l = list; l; l = l->next)
{
device = l->data;
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
continue;
display_wayland->input_devices = g_list_prepend (display_wayland->input_devices, l->data);
}
g_list_free (list);
/* Now set "core" pointer to the first
* master device that is a pointer.
*/
list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
for (l = list; l; l = l->next)
{
device = list->data;
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
continue;
display->core_pointer = device;
break;
}
/* Add the core pointer to the devices list */
display_wayland->input_devices = g_list_prepend (display_wayland->input_devices, display->core_pointer);
g_list_free (list);
}
static void
drm_handle_device(void *data, struct wl_drm *compositor, const char *device)
{
GdkDisplayWayland *display_wayland = data;
fprintf(stderr, "display name: %s\n", device);
display_wayland->device_name = g_strdup (device);
}
static void drm_handle_authenticated(void *data, struct wl_drm *drm)
{
GdkDisplayWayland *display_wayland = data;
display_wayland->authenticated = TRUE;
}
static const struct wl_drm_listener drm_listener = {
drm_handle_device,
drm_handle_authenticated
};
static void
shell_handle_configure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges,
struct wl_surface *surface,
int32_t width, int32_t height)
{
GdkWindow *window;
GdkDisplay *display;
GdkEvent *event;
window = wl_surface_get_user_data(surface);
printf("got configure: window %p, %dx%d, edges %d\n",
window, width, height, edges);
display = gdk_window_get_display (window);
event = gdk_event_new (GDK_CONFIGURE);
event->configure.window = window;
event->configure.send_event = FALSE;
event->configure.width = width;
event->configure.height = height;
window->width = width;
window->height = height;
_gdk_window_update_size (window);
_gdk_wayland_window_update_size (GDK_WINDOW_IMPL_WAYLAND (window->impl));
g_object_ref(window);
_gdk_wayland_display_deliver_event (display, event);
}
static const struct wl_shell_listener shell_listener = {
shell_handle_configure,
};
static void
output_handle_geometry(void *data,
struct wl_output *output,
int32_t x, int32_t y, int32_t width, int32_t height)
{
/*
g_signal_emit_by_name (screen, "monitors-changed");
g_signal_emit_by_name (screen, "size-changed");
*/
}
static const struct wl_output_listener output_listener = {
output_handle_geometry,
};
static void
gdk_display_handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
GdkDisplayWayland *display_wayland = data;
GdkDisplay *gdk_display = GDK_DISPLAY_OBJECT (data);
struct wl_input_device *input;
if (strcmp(interface, "compositor") == 0) {
display_wayland->compositor = wl_compositor_create(display, id);
} else if (strcmp(interface, "drm") == 0) {
display_wayland->drm = wl_drm_create(display, id);
wl_drm_add_listener(display_wayland->drm,
&drm_listener, display_wayland);
} else if (strcmp(interface, "shell") == 0) {
display_wayland->shell = wl_shell_create(display, id);
wl_shell_add_listener(display_wayland->shell,
&shell_listener, display_wayland);
} else if (strcmp(interface, "output") == 0) {
display_wayland->output = wl_output_create(display, id);
wl_output_add_listener(display_wayland->output,
&output_listener, display_wayland);
} else if (strcmp(interface, "input_device") == 0) {
input = wl_input_device_create(display, id);
gdk_device_manager_core_add_device (gdk_display->device_manager, input);
}
}
static gboolean
gdk_display_init_egl(GdkDisplay *display)
{
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (display);
EGLint major, minor, i;
drm_magic_t magic;
void *p;
static const struct { const char *f; unsigned int offset; }
extension_functions[] = {
{ "eglCreateDRMImageMESA", offsetof(GdkDisplayWayland, create_drm_image) },
{ "glEGLImageTargetTexture2DOES", offsetof(GdkDisplayWayland, image_target_texture_2d) },
{ "eglExportDRMImageMESA", offsetof(GdkDisplayWayland, export_drm_image) },
{ "eglDestroyImageKHR", offsetof(GdkDisplayWayland, destroy_image) }
};
display_wayland->fd = open(display_wayland->device_name, O_RDWR);
if (display_wayland->fd < 0) {
fprintf(stderr, "drm open failed: %m\n");
return FALSE;
}
if (drmGetMagic(display_wayland->fd, &magic))
{
fprintf(stderr, "DRI2: failed to get drm magic");
return FALSE;
}
/* Authenticate and wait for authenticated event */
wl_drm_authenticate(display_wayland->drm, magic);
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_WRITABLE);
while (!display_wayland->authenticated)
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
display_wayland->egl_display = eglGetDRMDisplayMESA(display_wayland->fd);
if (!eglInitialize(display_wayland->egl_display, &major, &minor)) {
fprintf(stderr, "failed to initialize display\n");
return FALSE;
}
eglBindAPI(EGL_OPENGL_API);
display_wayland->egl_context =
eglCreateContext(display_wayland->egl_display, NULL, EGL_NO_CONTEXT, NULL);
if (display_wayland->egl_context == NULL) {
fprintf(stderr, "failed to create context\n");
return FALSE;
}
if (!eglMakeCurrent(display_wayland->egl_display,
NULL, NULL, display_wayland->egl_context)) {
fprintf(stderr, "faile to make context current\n");
return FALSE;
}
display_wayland->cairo_device =
cairo_egl_device_create(display_wayland->egl_display,
display_wayland->egl_context);
if (cairo_device_status (display_wayland->cairo_device) != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "failed to get cairo drm device\n");
return FALSE;
}
for (i = 0; i < G_N_ELEMENTS(extension_functions); i++) {
p = eglGetProcAddress(extension_functions[i].f);
*(void **) ((char *) display_wayland + extension_functions[i].offset) = p;
if (p == NULL) {
fprintf(stderr, "failed to look up %s\n", extension_functions[i].f);
return FALSE;
}
}
fprintf(stderr, "egl initialized\n");
return TRUE;
}
GdkDisplay *
_gdk_wayland_display_open (const gchar *display_name)
{
struct wl_display *wl_display;
GdkDisplay *display;
GdkDisplayWayland *display_wayland;
GdkWindowAttr attr;
gint i;
wl_display = wl_display_connect(display_name);
if (!wl_display)
return NULL;
display = g_object_new (GDK_TYPE_DISPLAY_WAYLAND, NULL);
display_wayland = GDK_DISPLAY_WAYLAND (display);
display_wayland->wl_display = wl_display;
/* initialize the display's screens */
display_wayland->screens = g_new (GdkScreen *, 1);
for (i = 0; i < 1; i++)
display_wayland->screens[i] = _gdk_wayland_screen_new (display);
/*set the default screen */
display_wayland->default_screen = display_wayland->screens[0];
display->device_manager = _gdk_device_manager_new (display);
/* Set up listener so we'll catch all events. */
wl_display_add_global_listener(display_wayland->wl_display,
gdk_display_handle_global, display_wayland);
/* Process connection events. */
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
gdk_display_init_egl(display);
display_wayland->event_source = _gdk_wayland_display_event_source_new (display);
attr.window_type = GDK_WINDOW_TOPLEVEL;
attr.wclass = GDK_INPUT_OUTPUT;
attr.x = 10;
attr.y = 10;
attr.width = 10;
attr.height = 10;
attr.event_mask = 0;
gdk_input_init (display);
g_signal_emit_by_name (display, "opened");
g_signal_emit_by_name (gdk_display_manager_get(),
"display_opened", display);
return display;
}
static void
gdk_wayland_display_dispose (GObject *object)
{
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (object);
gint i;
_gdk_wayland_display_manager_remove_display (gdk_display_manager_get (),
GDK_DISPLAY (display_wayland));
g_list_foreach (display_wayland->input_devices,
(GFunc) g_object_run_dispose, NULL);
for (i = 0; i < 1; i++)
_gdk_screen_close (display_wayland->screens[i]);
if (display_wayland->event_source)
{
g_source_destroy (display_wayland->event_source);
g_source_unref (display_wayland->event_source);
display_wayland->event_source = NULL;
}
G_OBJECT_CLASS (_gdk_display_wayland_parent_class)->dispose (object);
}
static void
gdk_wayland_display_finalize (GObject *object)
{
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (object);
gint i;
/* Keymap */
if (display_wayland->keymap)
g_object_unref (display_wayland->keymap);
/* Atom Hashtable */
g_hash_table_destroy (display_wayland->atom_from_virtual);
g_hash_table_destroy (display_wayland->atom_to_virtual);
/* list of filters for client messages */
g_list_foreach (display_wayland->client_filters, (GFunc) g_free, NULL);
g_list_free (display_wayland->client_filters);
/* List of event window extraction functions */
g_slist_foreach (display_wayland->event_types, (GFunc)g_free, NULL);
g_slist_free (display_wayland->event_types);
/* input GdkDevice list */
g_list_foreach (display_wayland->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (display_wayland->input_devices);
/* input GdkWindow list */
g_list_foreach (display_wayland->input_windows, (GFunc) g_free, NULL);
g_list_free (display_wayland->input_windows);
/* Free all GdkScreens */
for (i = 0; i < 1; i++)
g_object_unref (display_wayland->screens[i]);
g_free (display_wayland->screens);
g_free (display_wayland->startup_notification_id);
/* X ID hashtable */
g_hash_table_destroy (display_wayland->xid_ht);
G_OBJECT_CLASS (_gdk_display_wayland_parent_class)->finalize (object);
}
static G_CONST_RETURN gchar *
gdk_wayland_display_get_name (GdkDisplay *display)
{
return "Wayland";
}
static gint
gdk_wayland_display_get_n_screens (GdkDisplay *display)
{
return 1;
}
static GdkScreen *
gdk_wayland_display_get_screen (GdkDisplay *display,
gint screen_num)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (screen_num == 0, NULL);
return GDK_DISPLAY_WAYLAND (display)->screens[0];
}
static GdkScreen *
gdk_wayland_display_get_default_screen (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return GDK_DISPLAY_WAYLAND (display)->default_screen;
}
static void
gdk_wayland_display_beep (GdkDisplay *display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
}
static void
sync_callback(void *data)
{
gboolean *done = data;
*done = TRUE;
}
static void
gdk_wayland_display_sync (GdkDisplay *display)
{
GdkDisplayWayland *display_wayland;
gboolean done;
g_return_if_fail (GDK_IS_DISPLAY (display));
display_wayland = GDK_DISPLAY_WAYLAND (display);
wl_display_sync_callback(display_wayland->wl_display, sync_callback, &done);
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_WRITABLE);
while (!done)
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
}
static void
gdk_wayland_display_flush (GdkDisplay *display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
if (!display->closed)
wl_display_iterate(GDK_DISPLAY_WAYLAND (display)->wl_display,
WL_DISPLAY_WRITABLE);
}
static gboolean
gdk_wayland_display_has_pending (GdkDisplay *display)
{
return FALSE;
}
static GdkWindow *
gdk_wayland_display_get_default_group (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return NULL;
}
static gboolean
gdk_wayland_display_supports_selection_notification (GdkDisplay *display)
{
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (display);
return display_wayland->have_xfixes;
}
static gboolean
gdk_wayland_display_request_selection_notification (GdkDisplay *display,
GdkAtom selection)
{
return FALSE;
}
static gboolean
gdk_wayland_display_supports_clipboard_persistence (GdkDisplay *display)
{
return FALSE;
}
static void
gdk_wayland_display_store_clipboard (GdkDisplay *display,
GdkWindow *clipboard_window,
guint32 time_,
const GdkAtom *targets,
gint n_targets)
{
}
static gboolean
gdk_wayland_display_supports_shapes (GdkDisplay *display)
{
return GDK_DISPLAY_WAYLAND (display)->have_shapes;
}
static gboolean
gdk_wayland_display_supports_input_shapes (GdkDisplay *display)
{
return GDK_DISPLAY_WAYLAND (display)->have_input_shapes;
}
static gboolean
gdk_wayland_display_supports_composite (GdkDisplay *display)
{
return TRUE;
}
static GList *
gdk_wayland_display_list_devices (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return GDK_DISPLAY_WAYLAND (display)->input_devices;
}
static gboolean
gdk_wayland_display_send_client_message (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid)
{
return 0;
}
static void
gdk_wayland_display_add_client_message_filter (GdkDisplay *display,
GdkAtom message_type,
GdkFilterFunc func,
gpointer data)
{
GdkClientFilter *filter;
g_return_if_fail (GDK_IS_DISPLAY (display));
filter = g_new (GdkClientFilter, 1);
filter->type = message_type;
filter->function = func;
filter->data = data;
GDK_DISPLAY_WAYLAND(display)->client_filters =
g_list_append (GDK_DISPLAY_WAYLAND (display)->client_filters,
filter);
}
static void
gdk_wayland_display_before_process_all_updates (GdkDisplay *display)
{
}
static void
gdk_wayland_display_after_process_all_updates (GdkDisplay *display)
{
/* Post the damage here instead? */
}
static gulong
gdk_wayland_display_get_next_serial (GdkDisplay *display)
{
return 0;
}
void
_gdk_wayland_display_make_default (GdkDisplay *display)
{
}
/**
* gdk_wayland_display_broadcast_startup_message:
* @display: a #GdkDisplay
* @message_type: startup notification message type ("new", "change",
* or "remove")
* @...: a list of key/value pairs (as strings), terminated by a
* %NULL key. (A %NULL value for a key will cause that key to be
* skipped in the output.)
*
* Sends a startup notification message of type @message_type to
* @display.
*
* This is a convenience function for use by code that implements the
* freedesktop startup notification specification. Applications should
* not normally need to call it directly. See the <ulink
* url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
* Notification Protocol specification</ulink> for
* definitions of the message types and keys that can be used.
*
* Since: 2.12
**/
void
gdk_wayland_display_broadcast_startup_message (GdkDisplay *display,
const char *message_type,
...)
{
GString *message;
va_list ap;
const char *key, *value, *p;
message = g_string_new (message_type);
g_string_append_c (message, ':');
va_start (ap, message_type);
while ((key = va_arg (ap, const char *)))
{
value = va_arg (ap, const char *);
if (!value)
continue;
g_string_append_printf (message, " %s=\"", key);
for (p = value; *p; p++)
{
switch (*p)
{
case ' ':
case '"':
case '\\':
g_string_append_c (message, '\\');
break;
}
g_string_append_c (message, *p);
}
g_string_append_c (message, '\"');
}
va_end (ap);
printf ("startup message: %s\n", message->str);
g_string_free (message, TRUE);
}
static void
gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
const gchar *startup_id)
{
gdk_wayland_display_broadcast_startup_message (display, "remove",
"ID", startup_id,
NULL);
}
static void
gdk_wayland_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_wayland_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
}
static GdkKeymap *
gdk_wayland_display_get_keymap (GdkDisplay *display)
{
GdkDisplayWayland *display_wayland;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
display_wayland = GDK_DISPLAY_WAYLAND (display);
if (!display_wayland->keymap)
display_wayland->keymap =
g_object_new (_gdk_wayland_keymap_get_type(), NULL);
display_wayland->keymap->display = display;
return display_wayland->keymap;
}
static void
gdk_wayland_display_push_error_trap (GdkDisplay *display)
{
}
static gint
gdk_wayland_display_pop_error_trap (GdkDisplay *display,
gboolean ignored)
{
return 0;
}
static void
_gdk_display_wayland_class_init (GdkDisplayWaylandClass * class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
object_class->dispose = gdk_wayland_display_dispose;
object_class->finalize = gdk_wayland_display_finalize;
display_class->window_type = _gdk_wayland_window_get_type ();
display_class->get_name = gdk_wayland_display_get_name;
display_class->get_n_screens = gdk_wayland_display_get_n_screens;
display_class->get_screen = gdk_wayland_display_get_screen;
display_class->get_default_screen = gdk_wayland_display_get_default_screen;
display_class->beep = gdk_wayland_display_beep;
display_class->sync = gdk_wayland_display_sync;
display_class->flush = gdk_wayland_display_flush;
display_class->has_pending = gdk_wayland_display_has_pending;
display_class->queue_events = _gdk_wayland_display_queue_events;
display_class->get_default_group = gdk_wayland_display_get_default_group;
display_class->supports_selection_notification = gdk_wayland_display_supports_selection_notification;
display_class->request_selection_notification = gdk_wayland_display_request_selection_notification;
display_class->supports_clipboard_persistence = gdk_wayland_display_supports_clipboard_persistence;
display_class->store_clipboard = gdk_wayland_display_store_clipboard;
display_class->supports_shapes = gdk_wayland_display_supports_shapes;
display_class->supports_input_shapes = gdk_wayland_display_supports_input_shapes;
display_class->supports_composite = gdk_wayland_display_supports_composite;
display_class->list_devices = gdk_wayland_display_list_devices;
display_class->send_client_message = gdk_wayland_display_send_client_message;
display_class->add_client_message_filter = gdk_wayland_display_add_client_message_filter;
display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
display_class->get_drag_protocol = _gdk_wayland_display_get_drag_protocol;
display_class->get_cursor_for_type = _gdk_wayland_display_get_cursor_for_type;
display_class->get_cursor_for_name = _gdk_wayland_display_get_cursor_for_name;
display_class->get_cursor_for_pixbuf = _gdk_wayland_display_get_cursor_for_pixbuf;
display_class->get_default_cursor_size = _gdk_wayland_display_get_default_cursor_size;
display_class->get_maximal_cursor_size = _gdk_wayland_display_get_maximal_cursor_size;
display_class->supports_cursor_alpha = _gdk_wayland_display_supports_cursor_alpha;
display_class->supports_cursor_color = _gdk_wayland_display_supports_cursor_color;
display_class->before_process_all_updates = gdk_wayland_display_before_process_all_updates;
display_class->after_process_all_updates = gdk_wayland_display_after_process_all_updates;
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->event_data_copy = gdk_wayland_display_event_data_copy;
display_class->event_data_free = gdk_wayland_display_event_data_free;
display_class->create_window_impl = _gdk_wayland_display_create_window_impl;
display_class->get_keymap = gdk_wayland_display_get_keymap;
display_class->push_error_trap = gdk_wayland_display_push_error_trap;
display_class->pop_error_trap = gdk_wayland_display_pop_error_trap;
display_class->get_selection_owner = _gdk_wayland_display_get_selection_owner;
display_class->set_selection_owner = _gdk_wayland_display_set_selection_owner;
display_class->send_selection_notify = _gdk_wayland_display_send_selection_notify;
display_class->get_selection_property = _gdk_wayland_display_get_selection_property;
display_class->convert_selection = _gdk_wayland_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
}
static void
_gdk_display_wayland_init (GdkDisplayWayland *display)
{
_gdk_wayland_display_manager_add_display (gdk_display_manager_get (),
GDK_DISPLAY (display));
}

View File

@ -0,0 +1,173 @@
/*
* gdkdisplay-wayland.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DISPLAY_WAYLAND__
#define __GDK_DISPLAY_WAYLAND__
#include <stdint.h>
#include <wayland-client.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <cairo-gl.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
#include <gdk/gdkwindow.h>
#include <gdk/gdkinternals.h>
#include <gdk/gdk.h> /* For gdk_get_program_class() */
#include "gdkdisplayprivate.h"
G_BEGIN_DECLS
typedef struct _GdkDisplayWayland GdkDisplayWayland;
typedef struct _GdkDisplayWaylandClass GdkDisplayWaylandClass;
#define GDK_TYPE_DISPLAY_WAYLAND (_gdk_display_wayland_get_type())
#define GDK_DISPLAY_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWayland))
#define GDK_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWaylandClass))
#define GDK_IS_DISPLAY_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_WAYLAND))
#define GDK_IS_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_WAYLAND))
#define GDK_DISPLAY_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWaylandClass))
struct _GdkDisplayWayland
{
GdkDisplay parent_instance;
GdkScreen *default_screen;
GdkScreen **screens;
gint grab_count;
/* Keyboard related information */
gint xkb_event_type;
gboolean use_xkb;
/* Whether we were able to turn on detectable-autorepeat using
* XkbSetDetectableAutorepeat. If FALSE, we'll fall back
* to checking the next event with XPending(). */
gboolean have_xkb_autorepeat;
GdkKeymap *keymap;
guint keymap_serial;
gboolean have_xfixes;
gint xfixes_event_base;
gboolean have_xcomposite;
gboolean have_xdamage;
gint xdamage_event_base;
gboolean have_randr13;
gint xrandr_event_base;
/* If the SECURITY extension is in place, whether this client holds
* a trusted authorization and so is allowed to make various requests
* (grabs, properties etc.) Otherwise always TRUE. */
gboolean trusted_client;
/* drag and drop information */
GdkDragContext *current_dest_drag;
/* data needed for MOTIF DnD */
Window motif_drag_window;
GdkWindow *motif_drag_gdk_window;
GList **motif_target_lists;
gint motif_n_target_lists;
/* Mapping to/from virtual atoms */
GHashTable *atom_from_virtual;
GHashTable *atom_to_virtual;
/* list of filters for client messages */
GList *client_filters;
/* List of functions to go from extension event => X window */
GSList *event_types;
/* X ID hashtable */
GHashTable *xid_ht;
/* translation queue */
GQueue *translate_queue;
/* Input device */
/* input GdkDevice list */
GList *input_devices;
/* input GdkWindow list */
GList *input_windows;
/* Startup notification */
gchar *startup_notification_id;
/* Time of most recent user interaction. */
gulong user_time;
/* Sets of atoms for DND */
guint base_dnd_atoms_precached : 1;
guint xdnd_atoms_precached : 1;
guint motif_atoms_precached : 1;
guint use_sync : 1;
guint have_shapes : 1;
guint have_input_shapes : 1;
gint shape_event_base;
/* The offscreen window that has the pointer in it (if any) */
GdkWindow *active_offscreen_window;
/* Wayland fields below */
char *device_name;
struct wl_display *wl_display;
struct wl_drm *drm;
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_output *output;
struct wl_input_device *input_device;
GSource *event_source;
int fd;
EGLDisplay egl_display;
EGLContext egl_context;
cairo_device_t *cairo_device;
int authenticated;
PFNEGLCREATEDRMIMAGEMESA create_drm_image;
PFNEGLEXPORTDRMIMAGEMESA export_drm_image;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
};
struct _GdkDisplayWaylandClass
{
GdkDisplayClass parent_class;
};
GType _gdk_display_wayland_get_type (void);
GdkScreen *_gdk_wayland_display_screen_for_xrootwin (GdkDisplay *display,
Window xrootwin);
G_END_DECLS
#endif /* __GDK_DISPLAY_WAYLAND__ */

View File

@ -0,0 +1,298 @@
/* GDK - The GIMP Drawing Kit
* gdkdisplaymanager-wayland.c
*
* Copyright 2010 Red Hat, Inc.
*
* Author: Matthias clasen
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkdisplay-wayland.h"
#include "gdkprivate-wayland.h"
#include "gdkinternals.h"
typedef struct _GdkWaylandDisplayManager GdkWaylandDisplayManager;
typedef struct _GdkWaylandDisplayManagerClass GdkWaylandDisplayManagerClass;
#define GDK_TYPE_WAYLAND_DISPLAY_MANAGER (gdk_wayland_display_manager_get_type())
#define GDK_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManager))
#define GDK_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
#define GDK_IS_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
#define GDK_IS_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
#define GDK_WAYLAND_DISPLAY_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
struct _GdkWaylandDisplayManager
{
GdkDisplayManager parent;
GdkDisplay *default_display;
GSList *displays;
};
struct _GdkWaylandDisplayManagerClass
{
GdkDisplayManagerClass parent_class;
};
G_DEFINE_TYPE (GdkWaylandDisplayManager, gdk_wayland_display_manager, GDK_TYPE_DISPLAY_MANAGER)
static void
gdk_wayland_display_manager_finalize (GObject *object)
{
g_error ("A GdkWaylandDisplayManager object was finalized. This should not happen");
G_OBJECT_CLASS (gdk_wayland_display_manager_parent_class)->finalize (object);
}
static GdkDisplay *
gdk_wayland_display_manager_open_display (GdkDisplayManager *manager,
const gchar *name)
{
return _gdk_wayland_display_open (name);
}
static GSList *
gdk_wayland_display_manager_list_displays (GdkDisplayManager *manager)
{
return g_slist_copy (GDK_WAYLAND_DISPLAY_MANAGER (manager)->displays);
}
static void
gdk_wayland_display_manager_set_default_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GDK_WAYLAND_DISPLAY_MANAGER (manager)->default_display = display;
_gdk_wayland_display_make_default (display);
}
static GdkDisplay *
gdk_wayland_display_manager_get_default_display (GdkDisplayManager *manager)
{
return GDK_WAYLAND_DISPLAY_MANAGER (manager)->default_display;
}
static GdkAtom
gdk_wayland_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean dup)
{
return 0;
}
static gchar *
gdk_wayland_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom)
{
return 0;
}
static guint
gdk_wayland_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *keyval_name)
{
return /* XStringToKeysym (keyval_name); */ 0;
}
static gchar *
gdk_wayland_display_manager_get_keyval_name (GdkDisplayManager *manager,
guint keyval)
{
return NULL;
}
static void
gdk_wayland_display_manager_keyval_convert_case (GdkDisplayManager *manager,
guint symbol,
guint *lower,
guint *upper)
{
guint xlower = symbol;
guint xupper = symbol;
/* Check for directly encoded 24-bit UCS characters: */
if ((symbol & 0xff000000) == 0x01000000)
{
if (lower)
*lower = gdk_unicode_to_keyval (g_unichar_tolower (symbol & 0x00ffffff));
if (upper)
*upper = gdk_unicode_to_keyval (g_unichar_toupper (symbol & 0x00ffffff));
return;
}
switch (symbol >> 8)
{
case 0: /* Latin 1 */
if ((symbol >= GDK_KEY_A) && (symbol <= GDK_KEY_Z))
xlower += (GDK_KEY_a - GDK_KEY_A);
else if ((symbol >= GDK_KEY_a) && (symbol <= GDK_KEY_z))
xupper -= (GDK_KEY_a - GDK_KEY_A);
else if ((symbol >= GDK_KEY_Agrave) && (symbol <= GDK_KEY_Odiaeresis))
xlower += (GDK_KEY_agrave - GDK_KEY_Agrave);
else if ((symbol >= GDK_KEY_agrave) && (symbol <= GDK_KEY_odiaeresis))
xupper -= (GDK_KEY_agrave - GDK_KEY_Agrave);
else if ((symbol >= GDK_KEY_Ooblique) && (symbol <= GDK_KEY_Thorn))
xlower += (GDK_KEY_oslash - GDK_KEY_Ooblique);
else if ((symbol >= GDK_KEY_oslash) && (symbol <= GDK_KEY_thorn))
xupper -= (GDK_KEY_oslash - GDK_KEY_Ooblique);
break;
case 1: /* Latin 2 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (symbol == GDK_KEY_Aogonek)
xlower = GDK_KEY_aogonek;
else if (symbol >= GDK_KEY_Lstroke && symbol <= GDK_KEY_Sacute)
xlower += (GDK_KEY_lstroke - GDK_KEY_Lstroke);
else if (symbol >= GDK_KEY_Scaron && symbol <= GDK_KEY_Zacute)
xlower += (GDK_KEY_scaron - GDK_KEY_Scaron);
else if (symbol >= GDK_KEY_Zcaron && symbol <= GDK_KEY_Zabovedot)
xlower += (GDK_KEY_zcaron - GDK_KEY_Zcaron);
else if (symbol == GDK_KEY_aogonek)
xupper = GDK_KEY_Aogonek;
else if (symbol >= GDK_KEY_lstroke && symbol <= GDK_KEY_sacute)
xupper -= (GDK_KEY_lstroke - GDK_KEY_Lstroke);
else if (symbol >= GDK_KEY_scaron && symbol <= GDK_KEY_zacute)
xupper -= (GDK_KEY_scaron - GDK_KEY_Scaron);
else if (symbol >= GDK_KEY_zcaron && symbol <= GDK_KEY_zabovedot)
xupper -= (GDK_KEY_zcaron - GDK_KEY_Zcaron);
else if (symbol >= GDK_KEY_Racute && symbol <= GDK_KEY_Tcedilla)
xlower += (GDK_KEY_racute - GDK_KEY_Racute);
else if (symbol >= GDK_KEY_racute && symbol <= GDK_KEY_tcedilla)
xupper -= (GDK_KEY_racute - GDK_KEY_Racute);
break;
case 2: /* Latin 3 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (symbol >= GDK_KEY_Hstroke && symbol <= GDK_KEY_Hcircumflex)
xlower += (GDK_KEY_hstroke - GDK_KEY_Hstroke);
else if (symbol >= GDK_KEY_Gbreve && symbol <= GDK_KEY_Jcircumflex)
xlower += (GDK_KEY_gbreve - GDK_KEY_Gbreve);
else if (symbol >= GDK_KEY_hstroke && symbol <= GDK_KEY_hcircumflex)
xupper -= (GDK_KEY_hstroke - GDK_KEY_Hstroke);
else if (symbol >= GDK_KEY_gbreve && symbol <= GDK_KEY_jcircumflex)
xupper -= (GDK_KEY_gbreve - GDK_KEY_Gbreve);
else if (symbol >= GDK_KEY_Cabovedot && symbol <= GDK_KEY_Scircumflex)
xlower += (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
else if (symbol >= GDK_KEY_cabovedot && symbol <= GDK_KEY_scircumflex)
xupper -= (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
break;
case 3: /* Latin 4 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (symbol >= GDK_KEY_Rcedilla && symbol <= GDK_KEY_Tslash)
xlower += (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
else if (symbol >= GDK_KEY_rcedilla && symbol <= GDK_KEY_tslash)
xupper -= (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
else if (symbol == GDK_KEY_ENG)
xlower = GDK_KEY_eng;
else if (symbol == GDK_KEY_eng)
xupper = GDK_KEY_ENG;
else if (symbol >= GDK_KEY_Amacron && symbol <= GDK_KEY_Umacron)
xlower += (GDK_KEY_amacron - GDK_KEY_Amacron);
else if (symbol >= GDK_KEY_amacron && symbol <= GDK_KEY_umacron)
xupper -= (GDK_KEY_amacron - GDK_KEY_Amacron);
break;
case 6: /* Cyrillic */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (symbol >= GDK_KEY_Serbian_DJE && symbol <= GDK_KEY_Serbian_DZE)
xlower -= (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
else if (symbol >= GDK_KEY_Serbian_dje && symbol <= GDK_KEY_Serbian_dze)
xupper += (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
else if (symbol >= GDK_KEY_Cyrillic_YU && symbol <= GDK_KEY_Cyrillic_HARDSIGN)
xlower -= (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
else if (symbol >= GDK_KEY_Cyrillic_yu && symbol <= GDK_KEY_Cyrillic_hardsign)
xupper += (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
break;
case 7: /* Greek */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (symbol >= GDK_KEY_Greek_ALPHAaccent && symbol <= GDK_KEY_Greek_OMEGAaccent)
xlower += (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
else if (symbol >= GDK_KEY_Greek_alphaaccent && symbol <= GDK_KEY_Greek_omegaaccent &&
symbol != GDK_KEY_Greek_iotaaccentdieresis &&
symbol != GDK_KEY_Greek_upsilonaccentdieresis)
xupper -= (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
else if (symbol >= GDK_KEY_Greek_ALPHA && symbol <= GDK_KEY_Greek_OMEGA)
xlower += (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
else if (symbol >= GDK_KEY_Greek_alpha && symbol <= GDK_KEY_Greek_omega &&
symbol != GDK_KEY_Greek_finalsmallsigma)
xupper -= (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
break;
}
if (lower)
*lower = xlower;
if (upper)
*upper = xupper;
}
static void
gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_CLASS (class);
object_class->finalize = gdk_wayland_display_manager_finalize;
manager_class->open_display = gdk_wayland_display_manager_open_display;
manager_class->list_displays = gdk_wayland_display_manager_list_displays;
manager_class->set_default_display = gdk_wayland_display_manager_set_default_display;
manager_class->get_default_display = gdk_wayland_display_manager_get_default_display;
manager_class->atom_intern = gdk_wayland_display_manager_atom_intern;
manager_class->get_atom_name = gdk_wayland_display_manager_get_atom_name;
manager_class->lookup_keyval = gdk_wayland_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_wayland_display_manager_get_keyval_name;
manager_class->keyval_convert_case = gdk_wayland_display_manager_keyval_convert_case;
}
static void
gdk_wayland_display_manager_init (GdkWaylandDisplayManager *manager)
{
}
void
_gdk_wayland_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkWaylandDisplayManager *manager_wayland = GDK_WAYLAND_DISPLAY_MANAGER (manager);
if (manager_wayland->displays == NULL)
gdk_display_manager_set_default_display (manager, display);
manager_wayland->displays = g_slist_prepend (manager_wayland->displays, display);
}
void
_gdk_wayland_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkWaylandDisplayManager *manager_wayland = GDK_WAYLAND_DISPLAY_MANAGER (manager);
manager_wayland->displays = g_slist_remove (manager_wayland->displays, display);
if (manager_wayland->default_display == display)
{
if (manager_wayland->displays)
gdk_display_manager_set_default_display (manager, manager_wayland->displays->data);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}

View File

@ -0,0 +1,190 @@
/*
* Copyright © 2010 Intel Corporation
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkdndprivate.h"
#include "gdkmain.h"
#include "gdkinternals.h"
#include "gdkproperty.h"
#include "gdkprivate-wayland.h"
#include "gdkscreen-wayland.h"
#include "gdkdisplay-wayland.h"
#include <string.h>
#define GDK_TYPE_WAYLAND_DRAG_CONTEXT (gdk_wayland_drag_context_get_type ())
#define GDK_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContext))
#define GDK_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
#define GDK_IS_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
#define GDK_IS_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
#define GDK_WAYLAND_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
typedef struct _GdkWaylandDragContext GdkWaylandDragContext;
typedef struct _GdkWaylandDragContextClass GdkWaylandDragContextClass;
struct _GdkWaylandDragContext
{
GdkDragContext context;
};
struct _GdkWaylandDragContextClass
{
GdkDragContextClass parent_class;
};
static GList *contexts;
G_DEFINE_TYPE (GdkWaylandDragContext, gdk_wayland_drag_context, GDK_TYPE_DRAG_CONTEXT)
static void
gdk_wayland_drag_context_finalize (GObject *object)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
contexts = g_list_remove (contexts, context);
G_OBJECT_CLASS (gdk_wayland_drag_context_parent_class)->finalize (object);
}
static GdkWindow *
gdk_wayland_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
{
return NULL;
}
static gboolean
gdk_wayland_drag_context_drag_motion (GdkDragContext *context,
GdkWindow *dest_window,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
GdkDragAction suggested_action,
GdkDragAction possible_actions,
guint32 time)
{
return FALSE;
}
static void
gdk_wayland_drag_context_drag_abort (GdkDragContext *context,
guint32 time)
{
}
static void
gdk_wayland_drag_context_drag_drop (GdkDragContext *context,
guint32 time)
{
}
/* Destination side */
static void
gdk_wayland_drag_context_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time_)
{
}
static void
gdk_wayland_drag_context_drop_reply (GdkDragContext *context,
gboolean accepted,
guint32 time_)
{
}
static void
gdk_wayland_drag_context_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
}
static gboolean
gdk_wayland_drag_context_drop_status (GdkDragContext *context)
{
return FALSE;
}
static GdkAtom
gdk_wayland_drag_context_get_selection (GdkDragContext *context)
{
return GDK_NONE;
}
static void
gdk_wayland_drag_context_init (GdkWaylandDragContext *context)
{
contexts = g_list_prepend (contexts, context);
}
static void
gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
object_class->finalize = gdk_wayland_drag_context_finalize;
context_class->find_window = gdk_wayland_drag_context_find_window;
context_class->drag_status = gdk_wayland_drag_context_drag_status;
context_class->drag_motion = gdk_wayland_drag_context_drag_motion;
context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
context_class->drop_reply = gdk_wayland_drag_context_drop_reply;
context_class->drop_finish = gdk_wayland_drag_context_drop_finish;
context_class->drop_status = gdk_wayland_drag_context_drop_status;
context_class->get_selection = gdk_wayland_drag_context_get_selection;
}
GdkNativeWindow
_gdk_wayland_display_get_drag_protocol (GdkDisplay *display,
GdkNativeWindow xid,
GdkDragProtocol *protocol,
guint *version)
{
return 0;
}
void
_gdk_wayland_window_register_dnd (GdkWindow *window)
{
}
GdkDragContext *
_gdk_wayland_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GList *targets)
{
GdkDragContext *context;
context = (GdkDragContext *) g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
gdk_drag_context_set_device (context, device);
return context;
}

View File

@ -0,0 +1,167 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkeventsource.h"
#include "gdkinternals.h"
typedef struct _GdkWaylandEventSource {
GSource source;
GPollFD pfd;
uint32_t mask;
GdkDisplay *display;
} GdkWaylandEventSource;
static GList *event_sources = NULL;
static gboolean
gdk_event_source_prepare(GSource *base, gint *timeout)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkDisplayWayland *display = (GdkDisplayWayland *) source->display;
*timeout = -1;
/* We have to add/remove the GPollFD if we want to update our
* poll event mask dynamically. Instead, let's just flush all
* write on idle instead, which is what this amounts to. */
if (_gdk_event_queue_find_first (source->display) != NULL)
return TRUE;
while (source->mask & WL_DISPLAY_WRITABLE)
wl_display_iterate(display->wl_display, WL_DISPLAY_WRITABLE);
return FALSE;
}
static gboolean
gdk_event_source_check(GSource *base)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
return _gdk_event_queue_find_first (source->display) != NULL ||
source->pfd.revents;
}
static gboolean
gdk_event_source_dispatch(GSource *base,
GSourceFunc callback,
gpointer data)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkDisplay *display = source->display;
GdkEvent *event;
GDK_THREADS_ENTER ();
event = gdk_display_get_event (display);
if (event)
{
_gdk_event_emit (event);
gdk_event_free (event);
}
GDK_THREADS_LEAVE ();
return TRUE;
}
static void
gdk_event_source_finalize (GSource *source)
{
event_sources = g_list_remove (event_sources, source);
}
static GSourceFuncs wl_glib_source_funcs = {
gdk_event_source_prepare,
gdk_event_source_check,
gdk_event_source_dispatch,
gdk_event_source_finalize
};
static int
gdk_event_source_update(uint32_t mask, void *data)
{
GdkWaylandEventSource *source = data;
source->mask = mask;
return 0;
}
void
_gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event)
{
GList *node;
static int serial;
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial++);
}
GSource *
_gdk_wayland_display_event_source_new (GdkDisplay *display)
{
GSource *source;
GdkWaylandEventSource *wl_source;
GdkDisplayWayland *display_wayland;
char *name;
source = g_source_new (&wl_glib_source_funcs,
sizeof (GdkWaylandEventSource));
name = g_strdup_printf ("GDK Wayland Event source (%s)", "display name");
g_source_set_name (source, name);
g_free (name);
wl_source = (GdkWaylandEventSource *) source;
display_wayland = GDK_DISPLAY_WAYLAND (display);
wl_source->display = display;
wl_source->pfd.fd = wl_display_get_fd(display_wayland->wl_display,
gdk_event_source_update, source);
wl_source->pfd.events = G_IO_IN | G_IO_ERR;
g_source_add_poll(source, &wl_source->pfd);
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
event_sources = g_list_prepend (event_sources, source);
return source;
}
void
_gdk_wayland_display_queue_events (GdkDisplay *display)
{
GdkDisplayWayland *display_wayland;
GdkWaylandEventSource *source;
display_wayland = GDK_DISPLAY_WAYLAND (display);
source = (GdkWaylandEventSource *) display_wayland->event_source;
if (source->pfd.revents)
{
wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
source->pfd.revents = 0;
}
}

View File

@ -0,0 +1,44 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_EVENT_SOURCE_H__
#define __GDK_EVENT_SOURCE_H__
#include "gdkprivate-wayland.h"
G_BEGIN_DECLS
typedef struct _GdkEventSource GdkEventSource;
G_GNUC_INTERNAL
GSource * gdk_event_source_new (GdkDisplay *display);
G_GNUC_INTERNAL
void gdk_event_source_select_events (GdkEventSource *source,
Window window,
GdkEventMask event_mask,
unsigned int extra_x_mask);
G_GNUC_INTERNAL
void _gdk_deliver_event (GdkDisplay *display, GdkEvent *event);
G_END_DECLS
#endif /* __GDK_EVENT_SOURCE_H__ */

View File

@ -0,0 +1,171 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include "gdk.h"
#include "gdkwayland.h"
#include "gdkprivate-wayland.h"
#include "gdkinternals.h"
#include "gdkdisplay-wayland.h"
#include "gdkkeysprivate.h"
#include <X11/extensions/XKBcommon.h>
typedef struct _GdkWaylandKeymap GdkWaylandKeymap;
typedef struct _GdkWaylandKeymapClass GdkWaylandKeymapClass;
struct _GdkWaylandKeymap
{
GdkKeymap parent_instance;
};
struct _GdkWaylandKeymapClass
{
GdkKeymapClass parent_class;
};
#define GDK_TYPE_WAYLAND_KEYMAP (_gdk_wayland_keymap_get_type ())
#define GDK_WAYLAND_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_KEYMAP, GdkWaylandKeyMap))
#define GDK_IS_WAYLAND_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_KEYMAP))
G_DEFINE_TYPE (GdkWaylandKeymap, _gdk_wayland_keymap, GDK_TYPE_KEYMAP)
static void
gdk_wayland_keymap_finalize (GObject *object)
{
G_OBJECT_CLASS (_gdk_wayland_keymap_parent_class)->finalize (object);
}
static PangoDirection
gdk_wayland_keymap_get_direction (GdkKeymap *keymap)
{
return PANGO_DIRECTION_NEUTRAL;
}
static gboolean
gdk_wayland_keymap_have_bidi_layouts (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_wayland_keymap_get_caps_lock_state (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_wayland_keymap_get_num_lock_state (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_wayland_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys)
{
return FALSE;
}
static gboolean
gdk_wayland_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries)
{
return FALSE;
}
static guint
gdk_wayland_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key)
{
return 0;
}
static gboolean
gdk_wayland_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers)
{
return FALSE;
}
static void
gdk_wayland_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
}
static gboolean
gdk_wayland_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
return FALSE;
}
static void
_gdk_wayland_keymap_class_init (GdkWaylandKeymapClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkKeymapClass *keymap_class = GDK_KEYMAP_CLASS (klass);
object_class->finalize = gdk_wayland_keymap_finalize;
keymap_class->get_direction = gdk_wayland_keymap_get_direction;
keymap_class->have_bidi_layouts = gdk_wayland_keymap_have_bidi_layouts;
keymap_class->get_caps_lock_state = gdk_wayland_keymap_get_caps_lock_state;
keymap_class->get_num_lock_state = gdk_wayland_keymap_get_num_lock_state;
keymap_class->get_entries_for_keyval = gdk_wayland_keymap_get_entries_for_keyval;
keymap_class->get_entries_for_keycode = gdk_wayland_keymap_get_entries_for_keycode;
keymap_class->lookup_key = gdk_wayland_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_wayland_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_wayland_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_wayland_keymap_map_virtual_modifiers;
}
static void
_gdk_wayland_keymap_init (GdkWaylandKeymap *keymap)
{
}

View File

@ -0,0 +1,141 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/*
* Private uninstalled header defining things local to X windowing code
*/
#ifndef __GDK_PRIVATE_WAYLAND_H__
#define __GDK_PRIVATE_WAYLAND_H__
#include <gdk/gdkcursor.h>
#include <gdk/gdkprivate.h>
#include <gdk/wayland/gdkwindow-wayland.h>
#include <gdk/wayland/gdkdisplay-wayland.h>
#include "gdkinternals.h"
#include "config.h"
#define GDK_SCREEN_DISPLAY(screen) (GDK_SCREEN_WAYLAND (screen)->display)
#define GDK_WINDOW_SCREEN(win) (gdk_window_get_screen (win))
#define GDK_WINDOW_DISPLAY(win) (GDK_SCREEN_WAYLAND (GDK_WINDOW_SCREEN (win))->display)
#define GDK_WINDOW_IS_WAYLAND(win) (GDK_IS_WINDOW_IMPL_WAYLAND (((GdkWindow *)win)->impl))
GType _gdk_wayland_window_get_type (void);
GType _gdk_wayland_keymap_get_type (void);
GdkCursor *_gdk_wayland_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type);
GdkCursor *_gdk_wayland_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name);
GdkCursor *_gdk_wayland_display_get_cursor_for_pixbuf (GdkDisplay *display,
GdkPixbuf *pixbuf,
gint x,
gint y);
void _gdk_wayland_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
void _gdk_wayland_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
gboolean _gdk_wayland_display_supports_cursor_alpha (GdkDisplay *display);
gboolean _gdk_wayland_display_supports_cursor_color (GdkDisplay *display);
GdkNativeWindow _gdk_wayland_display_get_drag_protocol (GdkDisplay *display,
GdkNativeWindow xid,
GdkDragProtocol *protocol,
guint *version);
void _gdk_wayland_window_register_dnd (GdkWindow *window);
GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GList *targets);
void _gdk_wayland_display_create_window_impl (GdkDisplay *display,
GdkWindow *window,
GdkWindow *real_parent,
GdkScreen *screen,
GdkEventMask event_mask,
GdkWindowAttr *attributes,
gint attributes_mask);
GdkKeymap *_gdk_wayland_display_get_keymap (GdkDisplay *display);
GdkWindow *_gdk_wayland_display_get_selection_owner (GdkDisplay *display,
GdkAtom selection);
gboolean _gdk_wayland_display_set_selection_owner (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event);
void _gdk_wayland_display_send_selection_notify (GdkDisplay *display,
GdkNativeWindow requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time);
gint _gdk_wayland_display_get_selection_property (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void _gdk_wayland_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time);
gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list);
gchar * _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str);
GdkDeviceManager *_gdk_device_manager_new (GdkDisplay *display);
void _gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event);
GSource *_gdk_wayland_display_event_source_new (GdkDisplay *display);
void _gdk_wayland_display_queue_events (GdkDisplay *display);
GdkAppLaunchContext *_gdk_wayland_display_get_app_launch_context (GdkDisplay *display);
GdkDisplay *_gdk_wayland_display_open (const gchar *display_name);
void _gdk_wayland_display_make_default (GdkDisplay *display);
GdkWindow *_gdk_wayland_screen_create_root_window (GdkScreen *screen,
int width,
int height);
GdkScreen *_gdk_wayland_screen_new (GdkDisplay *display);
void _gdk_wayland_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_wayland_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
#endif /* __GDK_PRIVATE_WAYLAND_H__ */

View File

@ -0,0 +1,586 @@
/*
* Copyright © 2010 Intel Corporation
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "gdkscreenprivate.h"
#include "gdkvisualprivate.h"
#include "gdkdisplay.h"
#include "gdkdisplay-wayland.h"
#include "gdkwayland.h"
#include "gdkprivate-wayland.h"
typedef struct _GdkScreenWayland GdkScreenWayland;
typedef struct _GdkScreenWaylandClass GdkScreenWaylandClass;
#define GDK_TYPE_SCREEN_WAYLAND (_gdk_screen_wayland_get_type ())
#define GDK_SCREEN_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWayland))
#define GDK_SCREEN_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWaylandClass))
#define GDK_IS_SCREEN_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SCREEN_WAYLAND))
#define GDK_IS_SCREEN_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SCREEN_WAYLAND))
#define GDK_SCREEN_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWaylandClass))
typedef struct _GdkWaylandMonitor GdkWaylandMonitor;
struct _GdkScreenWayland
{
GdkScreen parent_instance;
GdkDisplay *display;
GdkWindow *root_window;
int width, height;
int width_mm, height_mm;
/* Window manager */
long last_wmspec_check_time;
Window wmspec_check_window;
char *window_manager_name;
/* TRUE if wmspec_check_window has changed since last
* fetch of _NET_SUPPORTED
*/
guint need_refetch_net_supported : 1;
/* TRUE if wmspec_check_window has changed since last
* fetch of window manager name
*/
guint need_refetch_wm_name : 1;
/* Visual Part */
GdkVisual *argb_visual;
GdkVisual *premultiplied_argb_visual;
GdkVisual *rgb_visual;
/* Xinerama/RandR 1.2 */
gint n_monitors;
GdkWaylandMonitor *monitors;
gint primary_monitor;
/* Xft resources for the display, used for default values for
* the Xft/ XSETTINGS
*/
gboolean xft_init; /* Whether we've intialized these values yet */
gboolean xft_antialias;
gboolean xft_hinting;
gint xft_hintstyle;
gint xft_rgba;
gint xft_dpi;
GdkAtom cm_selection_atom;
gboolean is_composited;
};
struct _GdkScreenWaylandClass
{
GdkScreenClass parent_class;
void (* window_manager_changed) (GdkScreenWayland *screen_wayland);
};
struct _GdkWaylandMonitor
{
GdkRectangle geometry;
XID output;
int width_mm;
int height_mm;
char * output_name;
char * manufacturer;
};
G_DEFINE_TYPE (GdkScreenWayland, _gdk_screen_wayland, GDK_TYPE_SCREEN)
static void
init_monitor_geometry (GdkWaylandMonitor *monitor,
int x, int y, int width, int height)
{
monitor->geometry.x = x;
monitor->geometry.y = y;
monitor->geometry.width = width;
monitor->geometry.height = height;
monitor->output = None;
monitor->width_mm = -1;
monitor->height_mm = -1;
monitor->output_name = NULL;
monitor->manufacturer = NULL;
}
static void
free_monitors (GdkWaylandMonitor *monitors,
gint n_monitors)
{
int i;
for (i = 0; i < n_monitors; ++i)
{
g_free (monitors[i].output_name);
g_free (monitors[i].manufacturer);
}
g_free (monitors);
}
static void
deinit_multihead (GdkScreen *screen)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
free_monitors (screen_wayland->monitors, screen_wayland->n_monitors);
screen_wayland->n_monitors = 0;
screen_wayland->monitors = NULL;
}
static void
init_multihead (GdkScreen *screen)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
/* No multihead support of any kind for this screen */
screen_wayland->n_monitors = 1;
screen_wayland->monitors = g_new0 (GdkWaylandMonitor, 1);
screen_wayland->primary_monitor = 0;
init_monitor_geometry (screen_wayland->monitors, 0, 0,
screen_wayland->width, screen_wayland->height);
}
static void
gdk_wayland_screen_dispose (GObject *object)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (object);
if (screen_wayland->root_window)
_gdk_window_destroy (screen_wayland->root_window, TRUE);
G_OBJECT_CLASS (_gdk_screen_wayland_parent_class)->dispose (object);
screen_wayland->wmspec_check_window = None;
}
static void
gdk_wayland_screen_finalize (GObject *object)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (object);
if (screen_wayland->root_window)
g_object_unref (screen_wayland->root_window);
/* Visual Part */
g_object_unref (screen_wayland->argb_visual);
g_object_unref (screen_wayland->premultiplied_argb_visual);
g_object_unref (screen_wayland->rgb_visual);
g_free (screen_wayland->window_manager_name);
deinit_multihead (GDK_SCREEN (object));
G_OBJECT_CLASS (_gdk_screen_wayland_parent_class)->finalize (object);
}
static GdkDisplay *
gdk_wayland_screen_get_display (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_SCREEN_WAYLAND (screen)->display;
}
static gint
gdk_wayland_screen_get_width (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->width;
}
static gint
gdk_wayland_screen_get_height (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->height;
}
static gint
gdk_wayland_screen_get_width_mm (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->width_mm;
}
static gint
gdk_wayland_screen_get_height_mm (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->height_mm;
}
static gint
gdk_wayland_screen_get_number (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
static GdkWindow *
gdk_wayland_screen_get_root_window (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_SCREEN_WAYLAND (screen)->root_window;
}
static gint
gdk_wayland_screen_get_n_monitors (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->n_monitors;
}
static gint
gdk_wayland_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_WAYLAND (screen)->primary_monitor;
}
static gint
gdk_wayland_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num >= 0, -1);
g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, -1);
return screen_wayland->monitors[monitor_num].width_mm;
}
static gint
gdk_wayland_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num >= 0, -1);
g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, -1);
return screen_wayland->monitors[monitor_num].height_mm;
}
static gchar *
gdk_wayland_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (monitor_num >= 0, NULL);
g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, NULL);
return g_strdup (screen_wayland->monitors[monitor_num].output_name);
}
static void
gdk_wayland_screen_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest)
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (monitor_num >= 0);
g_return_if_fail (monitor_num < screen_wayland->n_monitors);
if (dest)
*dest = screen_wayland->monitors[monitor_num].geometry;
}
static GdkVisual *
gdk_wayland_screen_get_system_visual (GdkScreen * screen)
{
return (GdkVisual *) GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static GdkVisual *
gdk_wayland_screen_get_rgba_visual (GdkScreen *screen)
{
return (GdkVisual *) GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static gboolean
gdk_wayland_screen_is_composited (GdkScreen *screen)
{
return TRUE;
}
static gchar *
gdk_wayland_screen_make_display_name (GdkScreen *screen)
{
return NULL;
}
static GdkWindow *
gdk_wayland_screen_get_active_window (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return NULL;
}
static GList *
gdk_wayland_screen_get_window_stack (GdkScreen *screen)
{
return NULL;
}
static void
gdk_wayland_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event)
{
}
static gboolean
gdk_wayland_screen_get_setting (GdkScreen *screen,
const gchar *name,
GValue *value)
{
return FALSE;
}
typedef struct _GdkWaylandVisual GdkWaylandVisual;
typedef struct _GdkWaylandVisualClass GdkWaylandVisualClass;
struct _GdkWaylandVisual
{
GdkVisual visual;
struct wl_visual *wl_visual;
};
struct _GdkWaylandVisualClass
{
GdkVisualClass parent_class;
};
G_DEFINE_TYPE (GdkWaylandVisual, _gdk_wayland_visual, GDK_TYPE_VISUAL)
static void
_gdk_wayland_visual_class_init (GdkWaylandVisualClass *klass)
{
}
static void
_gdk_wayland_visual_init (GdkWaylandVisual *visual)
{
}
static gint
gdk_wayland_screen_visual_get_best_depth (GdkScreen *screen)
{
return 32;
}
static GdkVisualType
gdk_wayland_screen_visual_get_best_type (GdkScreen *screen)
{
return GDK_VISUAL_TRUE_COLOR;
}
static GdkVisual*
gdk_wayland_screen_visual_get_best (GdkScreen *screen)
{
return GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static GdkVisual*
gdk_wayland_screen_visual_get_best_with_depth (GdkScreen *screen,
gint depth)
{
return GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static GdkVisual*
gdk_wayland_screen_visual_get_best_with_type (GdkScreen *screen,
GdkVisualType visual_type)
{
return GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static GdkVisual*
gdk_wayland_screen_visual_get_best_with_both (GdkScreen *screen,
gint depth,
GdkVisualType visual_type)
{
return GDK_SCREEN_WAYLAND (screen)->argb_visual;
}
static void
gdk_wayland_screen_query_depths (GdkScreen *screen,
gint **depths,
gint *count)
{
static gint static_depths[] = { 32 };
*count = G_N_ELEMENTS(static_depths);
*depths = static_depths;
}
static void
gdk_wayland_screen_query_visual_types (GdkScreen *screen,
GdkVisualType **visual_types,
gint *count)
{
static GdkVisualType static_visual_types[] = { GDK_VISUAL_TRUE_COLOR };
*count = G_N_ELEMENTS(static_visual_types);
*visual_types = static_visual_types;
}
static GList *
gdk_wayland_screen_list_visuals (GdkScreen *screen)
{
GList *list;
GdkScreenWayland *screen_wayland;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
screen_wayland = GDK_SCREEN_WAYLAND (screen);
list = g_list_append (NULL, screen_wayland->argb_visual);
list = g_list_append (NULL, screen_wayland->premultiplied_argb_visual);
list = g_list_append (NULL, screen_wayland->rgb_visual);
return list;
}
#define GDK_TYPE_WAYLAND_VISUAL (_gdk_wayland_visual_get_type ())
#define GDK_WAYLAND_VISUAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_VISUAL, GdkWaylandVisual))
static GdkVisual *
gdk_wayland_visual_new (GdkScreen *screen, struct wl_visual *wl_visual)
{
GdkVisual *visual;
visual = g_object_new (GDK_TYPE_WAYLAND_VISUAL, NULL);
visual->screen = GDK_SCREEN (screen);
visual->type = GDK_VISUAL_TRUE_COLOR;
visual->depth = 32;
GDK_WAYLAND_VISUAL (visual)->wl_visual = wl_visual;
return visual;
}
GdkScreen *
_gdk_wayland_screen_new (GdkDisplay *display)
{
GdkScreen *screen;
GdkScreenWayland *screen_wayland;
GdkDisplayWayland *display_wayland;
struct wl_visual *visual;
display_wayland = GDK_DISPLAY_WAYLAND (display);
screen = g_object_new (GDK_TYPE_SCREEN_WAYLAND, NULL);
screen_wayland = GDK_SCREEN_WAYLAND (screen);
screen_wayland->display = display;
screen_wayland->wmspec_check_window = None;
/* we want this to be always non-null */
screen_wayland->window_manager_name = g_strdup ("unknown");
screen_wayland->width = 8192;
screen_wayland->height = 8192;
visual = wl_display_get_argb_visual(display_wayland->wl_display);
screen_wayland->argb_visual = gdk_wayland_visual_new (screen, visual);
visual =
wl_display_get_premultiplied_argb_visual(display_wayland->wl_display);
screen_wayland->premultiplied_argb_visual =
gdk_wayland_visual_new (screen, visual);
visual = wl_display_get_rgb_visual(display_wayland->wl_display);
screen_wayland->rgb_visual = gdk_wayland_visual_new (screen, visual);
screen_wayland->root_window =
_gdk_wayland_screen_create_root_window (screen,
screen_wayland->width,
screen_wayland->height);
init_multihead (screen);
return screen;
}
static void
_gdk_screen_wayland_class_init (GdkScreenWaylandClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
object_class->dispose = gdk_wayland_screen_dispose;
object_class->finalize = gdk_wayland_screen_finalize;
screen_class->get_display = gdk_wayland_screen_get_display;
screen_class->get_width = gdk_wayland_screen_get_width;
screen_class->get_height = gdk_wayland_screen_get_height;
screen_class->get_width_mm = gdk_wayland_screen_get_width_mm;
screen_class->get_height_mm = gdk_wayland_screen_get_height_mm;
screen_class->get_number = gdk_wayland_screen_get_number;
screen_class->get_root_window = gdk_wayland_screen_get_root_window;
screen_class->get_n_monitors = gdk_wayland_screen_get_n_monitors;
screen_class->get_primary_monitor = gdk_wayland_screen_get_primary_monitor;
screen_class->get_monitor_width_mm = gdk_wayland_screen_get_monitor_width_mm;
screen_class->get_monitor_height_mm = gdk_wayland_screen_get_monitor_height_mm;
screen_class->get_monitor_plug_name = gdk_wayland_screen_get_monitor_plug_name;
screen_class->get_monitor_geometry = gdk_wayland_screen_get_monitor_geometry;
screen_class->get_system_visual = gdk_wayland_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_wayland_screen_get_rgba_visual;
screen_class->is_composited = gdk_wayland_screen_is_composited;
screen_class->make_display_name = gdk_wayland_screen_make_display_name;
screen_class->get_active_window = gdk_wayland_screen_get_active_window;
screen_class->get_window_stack = gdk_wayland_screen_get_window_stack;
screen_class->broadcast_client_message = gdk_wayland_screen_broadcast_client_message;
screen_class->get_setting = gdk_wayland_screen_get_setting;
screen_class->visual_get_best_depth = gdk_wayland_screen_visual_get_best_depth;
screen_class->visual_get_best_type = gdk_wayland_screen_visual_get_best_type;
screen_class->visual_get_best = gdk_wayland_screen_visual_get_best;
screen_class->visual_get_best_with_depth = gdk_wayland_screen_visual_get_best_with_depth;
screen_class->visual_get_best_with_type = gdk_wayland_screen_visual_get_best_with_type;
screen_class->visual_get_best_with_both = gdk_wayland_screen_visual_get_best_with_both;
screen_class->query_depths = gdk_wayland_screen_query_depths;
screen_class->query_visual_types = gdk_wayland_screen_query_visual_types;
screen_class->list_visuals = gdk_wayland_screen_list_visuals;
}
static void
_gdk_screen_wayland_init (GdkScreenWayland *screen_wayland)
{
}

View File

@ -0,0 +1,36 @@
/*
* gdkscreen-wayland.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_SCREEN_WAYLAND_H__
#define __GDK_SCREEN_WAYLAND_H__
#include "gdkprivate-wayland.h"
#include <gdk/gdkscreenprivate.h>
#include <gdk/gdkvisual.h>
G_BEGIN_DECLS
G_END_DECLS
#endif /* __GDK_SCREEN_WAYLAND_H__ */

View File

@ -0,0 +1,90 @@
/*
* Copyright © 2010 Intel Corporation
*
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkselection.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include <string.h>
GdkWindow *
_gdk_wayland_display_get_selection_owner (GdkDisplay *display,
GdkAtom selection)
{
return NULL;
}
gboolean
_gdk_wayland_display_set_selection_owner (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event)
{
return FALSE;
}
void
_gdk_wayland_display_send_selection_notify (GdkDisplay *display,
GdkNativeWindow requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
}
gint
_gdk_wayland_display_get_selection_property (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
return 0;
}
void
_gdk_wayland_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
}
gint
_gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
return 0;
}
gchar *
_gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str)
{
return NULL;
}

38
gdk/wayland/gdkwayland.h Normal file
View File

@ -0,0 +1,38 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_WAYLAND_H__
#define __GDK_WAYLAND_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
GType gdk_wayland_display_manager_get_type (void);
G_END_DECLS
#endif /* __GDK_WAYLAND_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_WINDOW_WAYLAND_H__
#define __GDK_WINDOW_WAYLAND_H__
#include <gdk/wayland/gdkprivate-wayland.h>
#include <gdk/gdkwindowimpl.h>
#include <stdint.h>
#include <wayland-client.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GL/gl.h>
G_BEGIN_DECLS
typedef struct _GdkToplevelWayland GdkToplevelWayland;
typedef struct _GdkWindowImplWayland GdkWindowImplWayland;
typedef struct _GdkWindowImplWaylandClass GdkWindowImplWaylandClass;
typedef struct _GdkXPositionInfo GdkXPositionInfo;
/* Window implementation for Wayland
*/
#define GDK_TYPE_WINDOW_IMPL_WAYLAND (_gdk_window_impl_wayland_get_type ())
#define GDK_WINDOW_IMPL_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWayland))
#define GDK_WINDOW_IMPL_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWaylandClass))
#define GDK_IS_WINDOW_IMPL_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_WAYLAND))
#define GDK_IS_WINDOW_IMPL_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_WAYLAND))
#define GDK_WINDOW_IMPL_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_WAYLAND, GdkWindowImplWaylandClass))
struct _GdkWindowImplWayland
{
GdkWindowImpl parent_instance;
GdkWindow *wrapper;
GdkToplevelWayland *toplevel; /* Toplevel-specific information */
GdkCursor *cursor;
GHashTable *device_cursor;
gint8 toplevel_window_type;
guint no_bg : 1; /* Set when the window background is temporarily
* unset during resizing and scaling */
guint override_redirect : 1;
struct wl_surface *surface;
EGLImageKHR *pending_image;
EGLImageKHR *next_image;
cairo_surface_t *cairo_surface;
GLuint texture;
EGLImageKHR image;
};
struct _GdkWindowImplWaylandClass
{
GdkWindowImplClass parent_class;
};
struct _GdkToplevelWayland
{
/* Set if the window, or any descendent of it, is the server's focus window
*/
guint has_focus_window : 1;
/* Set if window->has_focus_window and the focus isn't grabbed elsewhere.
*/
guint has_focus : 1;
/* Set if the pointer is inside this window. (This is needed for
* for focus tracking)
*/
guint has_pointer : 1;
/* Set if the window is a descendent of the focus window and the pointer is
* inside it. (This is the case where the window will receive keystroke
* events even window->has_focus_window is FALSE)
*/
guint has_pointer_focus : 1;
/* Set if we are requesting these hints */
guint skip_taskbar_hint : 1;
guint skip_pager_hint : 1;
guint urgency_hint : 1;
guint on_all_desktops : 1; /* _NET_WM_STICKY == 0xFFFFFFFF */
guint have_sticky : 1; /* _NET_WM_STATE_STICKY */
guint have_maxvert : 1; /* _NET_WM_STATE_MAXIMIZED_VERT */
guint have_maxhorz : 1; /* _NET_WM_STATE_MAXIMIZED_HORZ */
guint have_fullscreen : 1; /* _NET_WM_STATE_FULLSCREEN */
gulong map_serial; /* Serial of last transition from unmapped */
cairo_surface_t *icon_pixmap;
cairo_surface_t *icon_mask;
/* Time of most recent user interaction. */
gulong user_time;
/* We use an extra X window for toplevel windows that we XSetInputFocus()
* to in order to avoid getting keyboard events redirected to subwindows
* that might not even be part of this app
*/
Window focus_window;
};
GType _gdk_window_impl_wayland_get_type (void);
GdkToplevelWayland *_gdk_wayland_window_get_toplevel (GdkWindow *window);
void _gdk_wayland_window_attach_image (GdkWindow *window,
EGLImageKHR image);
GdkCursor *_gdk_wayland_window_get_cursor (GdkWindow *window);
void _gdk_wayland_window_get_offsets (GdkWindow *window,
gint *x_offset,
gint *y_offset);
void _gdk_wayland_window_update_size (GdkWindowImplWayland *drawable);
G_END_DECLS
#endif /* __GDK_WINDOW_WAYLAND_H__ */

View File

@ -1466,9 +1466,12 @@ gtk_settings_get_for_screen (GdkScreen *screen)
settings_init_style (settings);
settings_update_double_click (settings);
#ifdef GDK_WINDOWING_X11
settings_update_cursor_theme (settings);
settings_update_resolution (settings);
settings_update_font_options (settings);
if (GDK_IS_X11_SCREEN (screen))
{
settings_update_cursor_theme (settings);
settings_update_resolution (settings);
settings_update_font_options (settings);
}
#endif
settings_update_color_scheme (settings);
}