summaryrefslogtreecommitdiff
path: root/gdk/x11/gdkscreen-x11.c
diff options
context:
space:
mode:
authorErwann Chenede - <erwann.chenede@sun.com>2002-05-03 19:03:03 +0000
committerErwann Chenede <erwannc@src.gnome.org>2002-05-03 19:03:03 +0000
commit7fa24a2f2c55f509b32439b7a7df1743c6219104 (patch)
treea200bdea7351aabd14131fb9806835287d99d43d /gdk/x11/gdkscreen-x11.c
parent88eb99ff4aca845da21a5ce24612e7ebcc52d0ca (diff)
downloadgdk-pixbuf-7fa24a2f2c55f509b32439b7a7df1743c6219104.tar.gz
Rationalized the screen initialization process, changed the GdkDisplayX11
2002-05-03 Erwann Chenede - <erwann.chenede@sun.com> * gdk/x11/gdkvisual-x11.c: * gdk/x11/gdkwindow-x11.c: * gdk/x11/gdkdisplay-x11.[hc] (gdk_open_display) : Rationalized the screen initialization process, changed the GdkDisplayX11 screen list to an array. * gdk/x11/gdkscreen-x11.[hc] (_gdk_x11_screen_new) : Moved the xinerama init functions to gdkdisplay-x11.c to this file, create a single function to fully initialize a GdkScreen. #79981
Diffstat (limited to 'gdk/x11/gdkscreen-x11.c')
-rw-r--r--gdk/x11/gdkscreen-x11.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 559b2e347..61f7e6a98 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -28,6 +28,13 @@
#include "gdkdisplay-x11.h"
#include "gdkx.h"
+#ifdef HAVE_SOLARIS_XINERAMA
+#include <X11/extensions/xinerama.h>
+#endif
+#ifdef HAVE_XFREE_XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
static void gdk_screen_x11_class_init (GdkScreenX11Class *klass);
static GdkDisplay * gdk_screen_x11_get_display (GdkScreen *screen);
static gint gdk_screen_x11_get_width (GdkScreen *screen);
@@ -49,6 +56,8 @@ static gint gdk_screen_x11_get_n_monitors (GdkScreen *scre
static void gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
gint num_monitor,
GdkRectangle *dest);
+static void init_xinerama_support (GdkScreen * screen);
+
GType gdk_screen_x11_get_type ();
static gpointer parent_class = NULL;
@@ -282,3 +291,145 @@ gdk_x11_screen_get_screen_number (GdkScreen *screen)
{
return GDK_SCREEN_X11 (screen)->screen_num;
}
+
+GdkScreen *
+_gdk_x11_screen_new (GdkDisplay *display,
+ gint screen_number)
+{
+ GdkScreen *screen;
+ GdkScreenX11 *screen_x11;
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+
+ screen = g_object_new (GDK_TYPE_SCREEN_X11, NULL);
+
+ screen_x11 = GDK_SCREEN_X11 (screen);
+ screen_x11->display = display;
+ screen_x11->xdisplay = display_x11->xdisplay;
+ screen_x11->xscreen = ScreenOfDisplay (display_x11->xdisplay, screen_number);
+ screen_x11->screen_num = screen_number;
+ screen_x11->xroot_window = RootWindow (display_x11->xdisplay,screen_number);
+ screen_x11->wmspec_check_window = None;
+
+ init_xinerama_support (screen);
+
+ _gdk_visual_init (screen);
+ _gdk_windowing_window_init (screen);
+ _gdk_x11_events_init_screen (screen);
+
+ return screen;
+}
+
+#ifdef HAVE_XINERAMA
+static gboolean
+check_solaris_xinerama (GdkScreen *screen)
+{
+#ifdef HAVE_SOLARIS_XINERAMA
+
+ if (XineramaGetState (GDK_SCREEN_XDISPLAY (screen),
+ gdk_screen_get_number (screen)))
+ {
+ XRectangle monitors[MAXFRAMEBUFFERS];
+ char hints[16];
+ gint result;
+ GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
+
+ result = XineramaGetInfo (GDK_SCREEN_XDISPLAY (screen),
+ gdk_screen_get_number (screen),
+ monitors, hints,
+ &screen_x11->num_monitors);
+ /* Yes I know it should be Success but the current implementation
+ returns the num of monitor*/
+ if (result == 0)
+ {
+ /* FIXME: We need to trap errors, since XINERAMA isn't always XINERAMA.
+ */
+ g_error ("error while retrieving Xinerama information");
+ }
+ else
+ {
+ int i;
+ screen_x11->monitors = g_new0 (GdkRectangle, screen_x11->num_monitors);
+
+ for (i = 0; i < screen_x11->num_monitors; i++)
+ {
+ screen_x11->monitors[i].x = monitors[i].x;
+ screen_x11->monitors[i].y = monitors[i].y;
+ screen_x11->monitors[i].width = monitors[i].width;
+ screen_x11->monitors[i].height = monitors[i].height;
+ }
+
+ return TRUE;
+ }
+ }
+#endif /* HAVE_SOLARIS_XINERAMA */
+
+ return FALSE;
+}
+
+static gboolean
+check_xfree_xinerama (GdkScreen *screen)
+{
+#ifdef HAVE_XFREE_XINERAMA
+ if (XineramaIsActive (GDK_SCREEN_XDISPLAY (screen)))
+ {
+ XineramaScreenInfo *monitors = XineramaQueryScreens (GDK_SCREEN_XDISPLAY (screen),
+ &screen_x11->num_monitors);
+ if (screen_x11->num_monitors <= 0)
+ {
+ /* FIXME: We need to trap errors, since XINERAMA isn't always XINERAMA.
+ * I don't think the num_monitors <= 0 check has any validity.
+ */
+ g_error ("error while retrieving Xinerama information");
+ }
+ else
+ {
+ int i;
+ screen_x11->monitors = g_new0 (GdkRectangle, screen_x11->num_monitors);
+
+ for (i = 0; i < screen_x11->num_monitors; i++)
+ {
+ screen_x11->monitors[i].x = monitors[i].x_org;
+ screen_x11->monitors[i].y = monitors[i].y_org;
+ screen_x11->monitors[i].width = monitors[i].width;
+ screen_x11->monitors[i].height = monitors[i].height;
+ }
+
+ XFree (monitors);
+
+ return TRUE;
+ }
+ }
+#endif /* HAVE_XFREE_XINERAMA */
+
+ return FALSE;
+}
+#endif /* HAVE_XINERAMA */
+
+static void
+init_xinerama_support (GdkScreen * screen)
+{
+ GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
+
+#ifdef HAVE_XINERAMA
+ int opcode, firstevent, firsterror;
+ gint result;
+
+ if (XQueryExtension (GDK_SCREEN_XDISPLAY (screen), "XINERAMA",
+ &opcode, &firstevent, &firsterror))
+ {
+ if (check_solaris_xinerama (screen) ||
+ check_xfree_xinerama (screen))
+ return;
+ }
+#endif /* HAVE_XINERAMA */
+
+ /* No Xinerama
+ */
+ screen_x11->num_monitors = 1;
+ screen_x11->monitors = g_new0 (GdkRectangle, 1);
+ screen_x11->monitors[0].x = 0;
+ screen_x11->monitors[0].y = 0;
+ screen_x11->monitors[0].width = WidthOfScreen (screen_x11->xscreen);
+ screen_x11->monitors[0].height = HeightOfScreen (screen_x11->xscreen);
+}
+