static gboolean init_fake_xinerama (GdkScreen *screen) { #ifdef G_ENABLE_DEBUG GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); XSetWindowAttributes atts; Window win; gint w, h; if (!(_gdk_debug_flags & GDK_DEBUG_XINERAMA)) return FALSE; /* Fake Xinerama mode by splitting the screen into 4 monitors. * Also draw a little cross to make the monitor boundaries visible. */ w = WidthOfScreen (x11_screen->xscreen); h = HeightOfScreen (x11_screen->xscreen); x11_screen->n_monitors = 4; x11_screen->monitors = g_new0 (GdkX11Monitor, 4); init_monitor_geometry (&x11_screen->monitors[0], 0, 0, w / 2, h / 2); init_monitor_geometry (&x11_screen->monitors[1], w / 2, 0, w / 2, h / 2); init_monitor_geometry (&x11_screen->monitors[2], 0, h / 2, w / 2, h / 2); init_monitor_geometry (&x11_screen->monitors[3], w / 2, h / 2, w / 2, h / 2); atts.override_redirect = 1; atts.background_pixel = WhitePixel(GDK_SCREEN_XDISPLAY (screen), x11_screen->screen_num); win = XCreateWindow(GDK_SCREEN_XDISPLAY (screen), x11_screen->xroot_window, 0, h / 2, w, 1, 0, DefaultDepth(GDK_SCREEN_XDISPLAY (screen), x11_screen->screen_num), InputOutput, DefaultVisual(GDK_SCREEN_XDISPLAY (screen), x11_screen->screen_num), CWOverrideRedirect|CWBackPixel, &atts); XMapRaised(GDK_SCREEN_XDISPLAY (screen), win); win = XCreateWindow(GDK_SCREEN_XDISPLAY (screen), x11_screen->xroot_window, w/2 , 0, 1, h, 0, DefaultDepth(GDK_SCREEN_XDISPLAY (screen), x11_screen->screen_num), InputOutput, DefaultVisual(GDK_SCREEN_XDISPLAY (screen), x11_screen->screen_num), CWOverrideRedirect|CWBackPixel, &atts); XMapRaised(GDK_SCREEN_XDISPLAY (screen), win); return TRUE; #endif return FALSE; }
static void init_multihead (GdkScreen *screen) { GdkScreenGix *screen_gix = GDK_SCREEN_GIX (screen); /* No multihead support of any kind for this screen */ screen_gix->n_monitors = 1; screen_gix->monitors = g_new0 (GdkGixMonitor, 1); screen_gix->primary_monitor = 0; init_monitor_geometry (screen_gix->monitors, 0, 0, screen_gix->width, screen_gix->height); }
static gboolean init_xfree_xinerama (GdkScreen *screen) { #ifdef HAVE_XFREE_XINERAMA Display *dpy = GDK_SCREEN_XDISPLAY (screen); GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); XineramaScreenInfo *monitors; int i, n_monitors; if (!XineramaIsActive (dpy)) return FALSE; monitors = XineramaQueryScreens (dpy, &n_monitors); if (n_monitors <= 0 || monitors == NULL) { /* If Xinerama doesn't think we have any monitors, try acting as * though we had no Xinerama. If the "no monitors" condition * is because XRandR 1.2 is currently switching between CRTCs, * we'll be notified again when we have our monitor back, * and can go back into Xinerama-ish mode at that point. */ if (monitors) XFree (monitors); return FALSE; } x11_screen->n_monitors = n_monitors; x11_screen->monitors = g_new0 (GdkX11Monitor, n_monitors); for (i = 0; i < n_monitors; ++i) { init_monitor_geometry (&x11_screen->monitors[i], monitors[i].x_org, monitors[i].y_org, monitors[i].width, monitors[i].height); } XFree (monitors); x11_screen->primary_monitor = 0; return TRUE; #endif /* HAVE_XFREE_XINERAMA */ return FALSE; }
static gboolean init_solaris_xinerama (GdkScreen *screen) { #ifdef HAVE_SOLARIS_XINERAMA Display *dpy = GDK_SCREEN_XDISPLAY (screen); int screen_no = gdk_screen_get_number (screen); GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); XRectangle monitors[MAXFRAMEBUFFERS]; unsigned char hints[16]; gint result; int n_monitors; int i; if (!XineramaGetState (dpy, screen_no)) return FALSE; result = XineramaGetInfo (dpy, screen_no, monitors, hints, &n_monitors); /* Yes I know it should be Success but the current implementation * returns the num of monitor */ if (result == 0) { return FALSE; } x11_screen->monitors = g_new0 (GdkX11Monitor, n_monitors); x11_screen->n_monitors = n_monitors; for (i = 0; i < n_monitors; i++) { init_monitor_geometry (&x11_screen->monitors[i], monitors[i].x, monitors[i].y, monitors[i].width, monitors[i].height); } x11_screen->primary_monitor = 0; return TRUE; #endif /* HAVE_SOLARIS_XINERAMA */ return FALSE; }
static void init_multihead (GdkScreen *screen) { GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); int opcode, firstevent, firsterror; /* There are four different implementations of multihead support: * * 1. Fake Xinerama for debugging purposes * 2. RandR 1.2 * 3. Solaris Xinerama * 4. XFree86/Xorg Xinerama * * We use them in that order. */ if (init_fake_xinerama (screen)) return; if (init_randr13 (screen)) return; if (XQueryExtension (GDK_SCREEN_XDISPLAY (screen), "XINERAMA", &opcode, &firstevent, &firsterror)) { if (init_solaris_xinerama (screen)) return; if (init_xfree_xinerama (screen)) return; } /* No multihead support of any kind for this screen */ x11_screen->n_monitors = 1; x11_screen->monitors = g_new0 (GdkX11Monitor, 1); x11_screen->primary_monitor = 0; init_monitor_geometry (x11_screen->monitors, 0, 0, WidthOfScreen (x11_screen->xscreen), HeightOfScreen (x11_screen->xscreen)); }