2010-12-11 00:42:09 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* gdkdisplaymanager-x11.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"
|
|
|
|
|
2010-12-21 04:14:47 +00:00
|
|
|
#include "gdkx11displaymanager.h"
|
|
|
|
#include "gdkdisplaymanagerprivate.h"
|
2010-12-11 00:42:09 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
|
|
|
#include "gdkprivate-x11.h"
|
|
|
|
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
2010-12-21 04:14:47 +00:00
|
|
|
struct _GdkX11DisplayManager
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
|
|
|
GdkDisplayManager parent;
|
|
|
|
|
|
|
|
GdkDisplay *default_display;
|
|
|
|
GSList *displays;
|
|
|
|
};
|
|
|
|
|
2010-12-21 04:14:47 +00:00
|
|
|
struct _GdkX11DisplayManagerClass
|
|
|
|
{
|
|
|
|
GdkDisplayManagerClass parent_class;
|
|
|
|
};
|
|
|
|
|
2010-12-21 17:19:03 +00:00
|
|
|
G_DEFINE_TYPE (GdkX11DisplayManager, gdk_x11_display_manager, GDK_TYPE_DISPLAY_MANAGER)
|
2010-12-11 00:42:09 +00:00
|
|
|
|
|
|
|
static GdkDisplay *
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_open_display (GdkDisplayManager *manager,
|
2010-12-11 00:42:09 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
2010-12-27 06:02:52 +00:00
|
|
|
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
|
|
|
display = _gdk_x11_display_open (name);
|
2011-01-18 14:36:59 +00:00
|
|
|
if (manager_x11->default_display == NULL && display != NULL)
|
2010-12-27 06:02:52 +00:00
|
|
|
gdk_display_manager_set_default_display (manager, display);
|
|
|
|
|
|
|
|
return display;
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_list_displays (GdkDisplayManager *manager)
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
return g_slist_copy (GDK_X11_DISPLAY_MANAGER (manager)->displays);
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDisplay *
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_get_default_display (GdkDisplayManager *manager)
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
return GDK_X11_DISPLAY_MANAGER (manager)->default_display;
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_set_default_display (GdkDisplayManager *manager,
|
2010-12-11 00:42:09 +00:00
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
GDK_X11_DISPLAY_MANAGER (manager)->default_display = display;
|
2010-12-11 00:42:09 +00:00
|
|
|
|
2011-04-09 01:20:26 +00:00
|
|
|
if (display)
|
|
|
|
_gdk_x11_display_make_default (display);
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_init (GdkX11DisplayManager *manager)
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
|
|
|
_gdk_x11_windowing_init ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_finalize (GObject *object)
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
g_error ("A GdkX11DisplayManager object was finalized. This should not happen");
|
|
|
|
G_OBJECT_CLASS (gdk_x11_display_manager_parent_class)->finalize (object);
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 04:14:47 +00:00
|
|
|
gdk_x11_display_manager_class_init (GdkX11DisplayManagerClass *class)
|
2010-12-11 00:42:09 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_CLASS (class);
|
|
|
|
|
2010-12-21 04:14:47 +00:00
|
|
|
object_class->finalize = gdk_x11_display_manager_finalize;
|
2010-12-11 00:42:09 +00:00
|
|
|
|
2010-12-21 04:14:47 +00:00
|
|
|
manager_class->open_display = gdk_x11_display_manager_open_display;
|
|
|
|
manager_class->list_displays = gdk_x11_display_manager_list_displays;
|
|
|
|
manager_class->set_default_display = gdk_x11_display_manager_set_default_display;
|
|
|
|
manager_class->get_default_display = gdk_x11_display_manager_get_default_display;
|
2010-12-16 05:37:39 +00:00
|
|
|
manager_class->atom_intern = _gdk_x11_display_manager_atom_intern;
|
|
|
|
manager_class->get_atom_name = _gdk_x11_display_manager_get_atom_name;
|
2010-12-17 00:00:01 +00:00
|
|
|
manager_class->lookup_keyval = _gdk_x11_display_manager_lookup_keyval;
|
|
|
|
manager_class->get_keyval_name = _gdk_x11_display_manager_get_keyval_name;
|
|
|
|
manager_class->keyval_convert_case = _gdk_x11_display_manager_keyval_convert_case;
|
2010-12-11 00:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gdk_x11_display_manager_add_display (GdkDisplayManager *manager,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
|
2010-12-11 00:42:09 +00:00
|
|
|
|
|
|
|
manager_x11->displays = g_slist_prepend (manager_x11->displays, display);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gdk_x11_display_manager_remove_display (GdkDisplayManager *manager,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2010-12-21 04:14:47 +00:00
|
|
|
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
|
2010-12-11 00:42:09 +00:00
|
|
|
|
|
|
|
manager_x11->displays = g_slist_remove (manager_x11->displays, display);
|
|
|
|
|
|
|
|
if (manager_x11->default_display == display)
|
|
|
|
{
|
|
|
|
if (manager_x11->displays)
|
|
|
|
gdk_display_manager_set_default_display (manager, manager_x11->displays->data);
|
|
|
|
else
|
|
|
|
gdk_display_manager_set_default_display (manager, NULL);
|
|
|
|
}
|
|
|
|
}
|