diff --git a/configure.ac b/configure.ac index b2aae065..03c7babc 100644 --- a/configure.ac +++ b/configure.ac @@ -152,7 +152,7 @@ dnl = Winsys =============================================================== MX_WINSYS=x11 AC_ARG_WITH([winsys], - [AC_HELP_STRING([--with-winsys=@<:@none/x11@:>@], + [AC_HELP_STRING([--with-winsys=@<:@none/x11/wayland/mir@:>@], [Select the window system backend])], [MX_WINSYS=$with_winsys]) @@ -170,12 +170,18 @@ AS_CASE([$MX_WINSYS], WINSYS_WAYLAND_REQUIRES="clutter-wayland-1.0 wayland-client" MX_REQUIRES="$MX_REQUIRES $WINSYS_WAYLAND_REQUIRES" ], + [mir], + [ + SUPPORT_MIR=yes + WINSYS_MIR_REQUIRES="clutter-mir-1.0" + MX_REQUIRES="$MX_REQUIRES $WINSYS_MIR_REQUIRES" + ], [none], [ WINSYS_NONE_REQUIRES="clutter-1.0 >= $CLUTTER_VERSION_REQUIRED" MX_REQUIRES="$MX_REQUIRES $WINSYS_NONE_REQUIRES" ], - [AC_MSG_ERROR([Invalid winsys: use 'x11' or 'none'])] + [AC_MSG_ERROR([Invalid winsys: use 'x11', 'wayland', 'mir' or 'none'])] ) AS_IF([test "x$SUPPORT_X11" = "xyes"], @@ -186,6 +192,10 @@ AS_IF([test "x$SUPPORT_WAYLAND" = "xyes"], [AC_DEFINE([HAVE_WAYLAND], [1], [Mx supports the WAYLAND window system])]) AM_CONDITIONAL([HAVE_WAYLAND], [test "x$SUPPORT_WAYLAND" = "xyes"]) +AS_IF([test "x$SUPPORT_MIR" = "xyes"], + [AC_DEFINE([HAVE_MIR], [1], [Mx supports the Mir window system])]) +AM_CONDITIONAL([HAVE_MIR], [test "x$SUPPORT_MIR" = "xyes"]) + AC_SUBST(MX_WINSYS) dnl = Optional Packages ==================================================== diff --git a/mx/Makefile.am b/mx/Makefile.am index 84ad480a..373e835a 100644 --- a/mx/Makefile.am +++ b/mx/Makefile.am @@ -39,6 +39,12 @@ WINSYS_SRC += \ $(top_srcdir)/mx/wayland/mx-window-wayland.h \ $(NULL) endif +if HAVE_MIR +WINSYS_SRC += \ + $(top_srcdir)/mx/mir/mx-window-mir.c \ + $(top_srcdir)/mx/mir/mx-window-mir.h \ + $(NULL) +endif WINSYS_SRC += \ $(top_srcdir)/mx/mx-clipboard-default.c \ $(NULL) diff --git a/mx/mir/mx-window-mir.c b/mx/mir/mx-window-mir.c new file mode 100644 index 00000000..c7e04911 --- /dev/null +++ b/mx/mir/mx-window-mir.c @@ -0,0 +1,125 @@ +/* + * mx-window-mir: MxNativeWindow implementation for Mir + * + * Copyright 2014 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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 program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + * Written by: Marco Trevisan + */ + +#include + +#include "mx-window-mir.h" +#include "mx-private.h" + +static void mx_native_window_iface_init (MxNativeWindowIface *iface); + +G_DEFINE_TYPE_WITH_CODE (MxWindowMir, mx_window_mir, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (MX_TYPE_NATIVE_WINDOW, mx_native_window_iface_init)) + +#define WINDOW_MIR_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), MX_TYPE_WINDOW_MIR, MxWindowMirPrivate)) + +struct _MxWindowMirPrivate +{ + MxWindow *window; +}; + +enum +{ + PROP_0, + + PROP_WINDOW +}; + +static void +mx_native_window_iface_init (MxNativeWindowIface *iface) +{ + +} + + +static void +mx_window_mir_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + case PROP_WINDOW: + g_value_set_object (value, MX_WINDOW_MIR (object)->priv->window); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +mx_window_mir_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + case PROP_WINDOW: + MX_WINDOW_MIR (object)->priv->window = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +mx_window_mir_dispose (GObject *object) +{ + G_OBJECT_CLASS (mx_window_mir_parent_class)->dispose (object); +} + +static void +mx_window_mir_finalize (GObject *object) +{ + G_OBJECT_CLASS (mx_window_mir_parent_class)->finalize (object); +} + +static void +mx_window_mir_class_init (MxWindowMirClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (MxWindowMirPrivate)); + + object_class->get_property = mx_window_mir_get_property; + object_class->set_property = mx_window_mir_set_property; + object_class->dispose = mx_window_mir_dispose; + object_class->finalize = mx_window_mir_finalize; + + g_object_class_override_property (object_class, PROP_WINDOW, "window"); +} + +static void +mx_window_mir_init (MxWindowMir *self) +{ + self->priv = WINDOW_MIR_PRIVATE (self); +} + +MxNativeWindow * +_mx_window_mir_new (MxWindow *window) +{ + return g_object_new (MX_TYPE_WINDOW_MIR, + "window", window, + NULL); +} diff --git a/mx/mir/mx-window-mir.h b/mx/mir/mx-window-mir.h new file mode 100644 index 00000000..b8715222 --- /dev/null +++ b/mx/mir/mx-window-mir.h @@ -0,0 +1,75 @@ +/* + * mx-window-mir: MxNativeWindow implementation for Mir + * + * Copyright 2014 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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 program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + * Written by: Marco Trevisan + */ + +#ifndef _MX_WINDOW_MIR_H +#define _MX_WINDOW_MIR_H + +#include +#include "mx-window.h" +#include "mx-native-window.h" + +G_BEGIN_DECLS + +#define MX_TYPE_WINDOW_MIR mx_window_mir_get_type() + +#define MX_WINDOW_MIR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + MX_TYPE_WINDOW_MIR, MxWindowMir)) + +#define MX_WINDOW_MIR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + MX_TYPE_WINDOW_MIR, MxWindowMirClass)) + +#define MX_IS_WINDOW_MIR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + MX_TYPE_WINDOW_MIR)) + +#define MX_IS_WINDOW_MIR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + MX_TYPE_WINDOW_MIR)) + +#define MX_WINDOW_MIR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + MX_TYPE_WINDOW_MIR, MxWindowMirClass)) + +typedef struct _MxWindowMir MxWindowMir; +typedef struct _MxWindowMirClass MxWindowMirClass; +typedef struct _MxWindowMirPrivate MxWindowMirPrivate; + +struct _MxWindowMir +{ + GObject parent; + + MxWindowMirPrivate *priv; +}; + +struct _MxWindowMirClass +{ + GObjectClass parent_class; +}; + +GType mx_window_mir_get_type (void) G_GNUC_CONST; + +MxNativeWindow *_mx_window_mir_new (MxWindow *window); + +G_END_DECLS + +#endif /* _MX_WINDOW_MIR_H */ diff --git a/mx/mx-window.c b/mx/mx-window.c index 2abb29a2..4964b839 100644 --- a/mx/mx-window.c +++ b/mx/mx-window.c @@ -54,6 +54,10 @@ #include "wayland/mx-window-wayland.h" #endif +#ifdef HAVE_MIR +#include "mir/mx-window-mir.h" +#endif + G_DEFINE_TYPE (MxWindow, mx_window, G_TYPE_OBJECT) static GQuark window_quark = 0; @@ -771,6 +775,10 @@ mx_window_constructed (GObject *object) #ifdef HAVE_WAYLAND priv->native_window = _mx_window_wayland_new (self); #endif + +#ifdef HAVE_MIR + priv->native_window = _mx_window_mir_new (self); +#endif } static void