2011-01-06 22:36:44 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* gdkdisplaymanager-broadway.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Imendio AB
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-01-06 22:36:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-03-23 04:47:22 +00:00
|
|
|
#include <stdlib.h>
|
2011-01-06 22:36:44 +00:00
|
|
|
#include "gdkdisplay-broadway.h"
|
|
|
|
#include "gdkbroadwaydisplaymanager.h"
|
|
|
|
#include "gdkprivate-broadway.h"
|
|
|
|
|
|
|
|
#include "gdkdisplaymanagerprivate.h"
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
|
|
|
struct _GdkBroadwayDisplayManager
|
|
|
|
{
|
|
|
|
GdkDisplayManager parent;
|
|
|
|
|
2013-03-23 04:47:22 +00:00
|
|
|
gboolean init_failed;
|
2011-01-06 22:36:44 +00:00
|
|
|
};
|
|
|
|
|
2013-03-23 04:47:22 +00:00
|
|
|
static void g_initable_iface_init (GInitableIface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkBroadwayDisplayManager, gdk_broadway_display_manager, GDK_TYPE_DISPLAY_MANAGER,
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, g_initable_iface_init))
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_broadway_display_manager_initable_init (GInitable *initable,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
const gchar *display_name;
|
|
|
|
gint port;
|
|
|
|
GdkBroadwayServer *server;
|
|
|
|
|
|
|
|
display_name = g_getenv ("BROADWAY_DISPLAY");
|
|
|
|
|
|
|
|
port = 0;
|
|
|
|
if (display_name != NULL)
|
|
|
|
{
|
|
|
|
if (*display_name == ':')
|
|
|
|
display_name++;
|
|
|
|
port = strtol(display_name, NULL, 10);
|
|
|
|
}
|
|
|
|
if (port == 0)
|
|
|
|
port = 1;
|
|
|
|
|
|
|
|
server = _gdk_broadway_server_new (port, NULL);
|
|
|
|
if (server == NULL)
|
|
|
|
{
|
|
|
|
GDK_BROADWAY_DISPLAY_MANAGER (initable)->init_failed = TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (server);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_initable_iface_init (GInitableIface *iface)
|
|
|
|
{
|
|
|
|
iface->init = gdk_broadway_display_manager_initable_init;
|
|
|
|
}
|
2011-01-06 22:36:44 +00:00
|
|
|
|
|
|
|
static GdkDisplay *
|
|
|
|
gdk_broadway_display_manager_open_display (GdkDisplayManager *manager,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
return _gdk_broadway_display_open (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_display_manager_init (GdkBroadwayDisplayManager *manager)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_display_manager_finalize (GObject *object)
|
|
|
|
{
|
2013-03-23 04:47:22 +00:00
|
|
|
if (!GDK_BROADWAY_DISPLAY_MANAGER (object)->init_failed)
|
|
|
|
g_error ("A GdkBroadwayDisplayManager object was finalized. This should not happen");
|
2011-01-06 22:36:44 +00:00
|
|
|
G_OBJECT_CLASS (gdk_broadway_display_manager_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_CLASS (class);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_broadway_display_manager_finalize;
|
|
|
|
|
|
|
|
manager_class->open_display = gdk_broadway_display_manager_open_display;
|
|
|
|
}
|