Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mx: add mir native window support #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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"],
Expand All @@ -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 ====================================================
Expand Down
6 changes: 6 additions & 0 deletions mx/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
125 changes: 125 additions & 0 deletions mx/mir/mx-window-mir.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/

#include <clutter/mir/clutter-mir.h>

#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);
}
75 changes: 75 additions & 0 deletions mx/mir/mx-window-mir.h
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/

#ifndef _MX_WINDOW_MIR_H
#define _MX_WINDOW_MIR_H

#include <glib-object.h>
#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 */
8 changes: 8 additions & 0 deletions mx/mx-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down