// find the dimensions of the monitor displaying point x,y void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon ) { memset ( mon, 0, sizeof ( workarea ) ); mon->w = WidthOfScreen ( screen ); mon->h = HeightOfScreen ( screen ); // locate the current monitor if ( XineramaIsActive ( display ) ) { int monitors; XineramaScreenInfo *info = XineramaQueryScreens ( display, &monitors ); if ( info ) { for ( int i = 0; i < monitors; i++ ) { if ( INTERSECT ( x, y, 1, 1, info[i].x_org, info[i].y_org, info[i].width, info[i].height ) ) { mon->x = info[i].x_org; mon->y = info[i].y_org; mon->w = info[i].width; mon->h = info[i].height; break; } } } XFree ( info ); } }
void _gdk_x11_screen_get_edge_monitors (GdkScreen *screen, gint *top, gint *bottom, gint *left, gint *right) { GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); gint top_most_pos = x11_screen->height; gint left_most_pos = x11_screen->width; gint bottom_most_pos = 0; gint right_most_pos = 0; gint i; #ifdef HAVE_XFREE_XINERAMA XineramaScreenInfo *x_monitors; int x_n_monitors; #endif *top = *bottom = *left = *right = -1; #ifdef HAVE_XFREE_XINERAMA if (!XineramaIsActive (x11_screen->xdisplay)) return; x_monitors = XineramaQueryScreens (x11_screen->xdisplay, &x_n_monitors); if (x_n_monitors <= 0 || x_monitors == NULL) { if (x_monitors) XFree (x_monitors); return; } for (i = 0; i < x_n_monitors; i++) { if (left && left_most_pos > x_monitors[i].x_org) { left_most_pos = x_monitors[i].x_org; *left = i; } if (right && right_most_pos < x_monitors[i].x_org + x_monitors[i].width) { right_most_pos = x_monitors[i].x_org + x_monitors[i].width; *right = i; } if (top && top_most_pos > x_monitors[i].y_org) { top_most_pos = x_monitors[i].y_org; *top = i; } if (bottom && bottom_most_pos < x_monitors[i].y_org + x_monitors[i].height) { bottom_most_pos = x_monitors[i].y_org + x_monitors[i].height; *bottom = i; } } XFree (x_monitors); #endif }
int main (int argc, char **argv) { int event_number, error_number; int major, minor; int nscreens = 0; XineramaScreenInfo *xsi; int i; XtAppContext app; Widget toplevel_shell = XtAppInitialize (&app, progclass, 0, 0, &argc, argv, 0, 0, 0); Display *dpy = XtDisplay (toplevel_shell); XtGetApplicationNameAndClass (dpy, &progname, &progclass); if (!XineramaQueryExtension(dpy, &event_number, &error_number)) { fprintf(stderr, "%s: XineramaQueryExtension(dpy, ...) ==> False\n", blurb()); fprintf(stderr, "%s: server does not support the Xinerama extension.\n", blurb()); exit(1); } else fprintf(stderr, "%s: XineramaQueryExtension(dpy, ...) ==> %d, %d\n", blurb(), event_number, error_number); if (!XineramaIsActive(dpy)) { fprintf(stderr, "%s: XineramaIsActive(dpy) ==> False\n", blurb()); fprintf(stderr, "%s: server says Xinerama is turned off.\n", blurb()); exit(1); } else fprintf(stderr, "%s: XineramaIsActive(dpy) ==> True\n", blurb()); if (!XineramaQueryVersion(dpy, &major, &minor)) { fprintf(stderr, "%s: XineramaQueryVersion(dpy, ...) ==> False\n", blurb()); fprintf(stderr, "%s: server didn't report Xinerama version numbers?\n", blurb()); } else fprintf(stderr, "%s: XineramaQueryVersion(dpy, ...) ==> %d, %d\n", blurb(), major, minor); xsi = XineramaQueryScreens (dpy, &nscreens); fprintf(stderr, "%s: %d Xinerama screens\n", blurb(), nscreens); for (i = 0; i < nscreens; i++) fprintf (stderr, "%s: screen %d: %dx%d+%d+%d\n", blurb(), xsi[i].screen_number, xsi[i].width, xsi[i].height, xsi[i].x_org, xsi[i].y_org); XFree (xsi); XSync (dpy, False); exit (0); }
static void _al_xsys_xinerama_init(ALLEGRO_SYSTEM_XGLX *s) { int event_base = 0; int error_base = 0; /* init xinerama info to defaults */ s->xinerama_available = 0; s->xinerama_screen_count = 0; s->xinerama_screen_info = NULL; _al_mutex_lock(&s->lock); if (XineramaQueryExtension(s->x11display, &event_base, &error_base)) { int minor_version = 0, major_version = 0; int status = XineramaQueryVersion(s->x11display, &major_version, &minor_version); ALLEGRO_INFO("Xinerama version: %i.%i\n", major_version, minor_version); if (status && !XineramaIsActive(s->x11display)) { ALLEGRO_WARN("Xinerama is not active\n"); } else { ALLEGRO_INFO("Xinerama is active\n"); s->xinerama_available = 1; } } else { ALLEGRO_WARN("Xinerama extension is not available.\n"); } _al_mutex_unlock(&s->lock); }
/* update screen and/or Xinerama dimensions */ void updategeom(void) { #ifdef XINERAMA int i; XineramaScreenInfo *info = NULL; if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &nmonitor))) { nmonitor = MIN(nmonitor, LENGTH(monitors)); for(i = 0; i < nmonitor; i++) { monitors[i].x = info[i].x_org; monitors[i].y = info[i].y_org; monitors[i].w = info[i].width; monitors[i].h = info[i].height; } XFree(info); } else #endif { nmonitor = 1; monitors[0].x = sx; monitors[0].y = sy; monitors[0].w = sw; monitors[0].h = sh; } }
/** Get and set the selected screen *\return The number of the selected screen */ int screen_get_sel(void) { int os = selscreen; selscreen = 0; #ifdef HAVE_XINERAMA if(XineramaIsActive(dpy)) { /* Unused variables (except x/y) */ Window w; int d, x, y; XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&d); selscreen = screen_get_with_geo(x, y); } #endif /* HAVE_XINERAMA */ /* Set _WMFS_CURRENT_SCREEN */ XChangeProperty(dpy, ROOT, net_atom[wmfs_current_screen], XA_CARDINAL, 32, PropModeReplace, (uchar*)&selscreen, 1); if(os != selscreen && os != prevselscreen) prevselscreen = os; return selscreen; }
int xf_list_monitors(xfInfo* xfi) { #ifdef WITH_XINERAMAZ int i, nmonitors = 0; int ignored, ignored2; XineramaScreenInfo* screen = NULL; if (XineramaQueryExtension(xfi->display, &ignored, &ignored2)) { if (XineramaIsActive(xfi->display)) { screen = XineramaQueryScreens(xfi->display, &nmonitors); for (i = 0; i < nmonitors; i++) { DEBUG_MSG(" %s [%d] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, screen[i].width, screen[i].height, screen[i].x_org, screen[i].y_org); } XFree(screen); } } #else Screen* screen; screen = ScreenOfDisplay(xfi->display, DefaultScreen(xfi->display)); DEBUG_MSG(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); #endif return 0; }
void init_xinerama(void) { if (opt.xinerama && XineramaIsActive(disp)) { int major, minor, px, py, i; /* discarded */ Window dw; int di; unsigned int du; XineramaQueryVersion(disp, &major, &minor); xinerama_screens = XineramaQueryScreens(disp, &num_xinerama_screens); if (getenv("XINERAMA_SCREEN")) xinerama_screen = atoi(getenv("XINERAMA_SCREEN")); else { xinerama_screen = 0; XQueryPointer(disp, root, &dw, &dw, &px, &py, &di, &di, &du); for (i = 0; i < num_xinerama_screens; i++) { if (XY_IN_RECT(px, py, xinerama_screens[i].x_org, xinerama_screens[i].y_org, xinerama_screens[i].width, xinerama_screens[i].height)) { xinerama_screen = i; break; } } } } }
void screen_update_geometry(struct screen_ctx *sc) { XineramaScreenInfo *info = NULL; int info_no = 0; sc->view.x = 0; sc->view.y = 0; sc->view.w = DisplayWidth(X_Dpy, sc->which); sc->view.h = DisplayHeight(X_Dpy, sc->which); sc->work.x = sc->view.x + sc->gap.left; sc->work.y = sc->view.y + sc->gap.top; sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right); sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom); /* RandR event may have a CTRC added or removed. */ if (XineramaIsActive(X_Dpy)) info = XineramaQueryScreens(X_Dpy, &info_no); if (sc->xinerama != NULL) XFree(sc->xinerama); sc->xinerama = info; sc->xinerama_no = info_no; xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_workarea(sc); }
bool AugmentationEnvironment::getScreenSizes() { Display *d=XOpenDisplay(NULL); if (d) { int dummy1, dummy2; if (XineramaQueryExtension(d, &dummy1, &dummy2)) { if (XineramaIsActive(d)) { int heads=0; XineramaScreenInfo *p=XineramaQueryScreens(d, &heads); if (heads>0) { for (int x=0; x<heads; ++x) { cout << "Head " << x+1 << " of " << heads << ": " << p[x].width << "x" << p[x].height << " at " << p[x].x_org << "," << p[x].y_org << endl; screenRect.push_back(cv::Rect(p[x].x_org, p[x].y_org, p[x].width, p[x].height)); } return true; } else cout << "XineramaQueryScreens says there aren't any" << endl; XFree(p); } else cout << "Xinerama not active" << endl; } else cout << "No Xinerama extension" << endl; XCloseDisplay(d); } else cout << "Can't open display" << endl; return false; }
void init_xinerama(void) { int evbase, errbase, major, minor; rp_have_xinerama = 0; #ifdef XINERAMA if (xine_screens) XFree(xine_screens); if (!XineramaQueryExtension(dpy, &evbase, &errbase)) { return; } if (!XineramaQueryVersion(dpy, &major, &minor) != Success) { return; } if (major != 1) { fprintf (stderr, "Warning: Xinerama version %d.%d not supported\n", major, minor); return; } if (!XineramaIsActive(dpy)) { return; } xine_screens = XineramaQueryScreens(dpy, &xine_screen_count); if ((xine_screens == NULL) || (xine_screen_count < 2)) { return; } rp_have_xinerama = 1; #endif }
void create_monitors(void) { #ifdef XINERAMA struct monitor *mon; int i, nmon; if (XineramaIsActive(dpy)) { XineramaScreenInfo *xsi = XineramaQueryScreens(dpy, &nmon); mons = NULL; for (i = 0; i < nmon; i++) { mon = monitor_create(i, xsi[i].x_org, xsi[i].y_org, xsi[i].width, xsi[i].height); mons = monitor_append(mons, mon); } selmon = mons; return; } #endif /* XINERAMA */ selmon = mons = monitor_create(0, 0, 0, screen_w, screen_h); }
/* * Update selected screen with mouse location */ struct screen* screen_update_sel(void) { #ifdef HAVE_XINERAMA if(XineramaIsActive(W->dpy)) return (W->screen = screen_gb_mouse()); #endif /* HAVE_XINERAMA */ return W->screen; }
int_fast32_t xinerama_is_active(Display *dpy) { int minor, major; if (!dpy) return 0; if (!XineramaQueryVersion(dpy, &minor, &major)) return 0; if (!XineramaIsActive(dpy)) return 0; return 1; }
int MythXDisplay::GetNumberXineramaScreens(void) { MythXLocker locker(this); int nr_xinerama_screens = 0; int event_base = 0, error_base = 0; if (XineramaQueryExtension(m_disp, &event_base, &error_base) && XineramaIsActive(m_disp)) { XFree(XineramaQueryScreens(m_disp, &nr_xinerama_screens)); } return nr_xinerama_screens; }
void HMDDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor) { // For now we'll assume the Rift DK1 is attached in extended monitor mode. Ultimately we need to // use XFree86 to enumerate X11 screens in case the Rift is attached as a separate screen. We also // need to be able to read the EDID manufacturer product code to be able to differentiate between // Rift models. bool foundHMD = false; Display* display = XOpenDisplay(NULL); if (display && XineramaIsActive(display)) { int numberOfScreens; XineramaScreenInfo* screens = XineramaQueryScreens(display, &numberOfScreens); for (int i = 0; i < numberOfScreens; i++) { XineramaScreenInfo screenInfo = screens[i]; if (screenInfo.width == 1280 && screenInfo.height == 800) { String deviceName = "OVR0001"; HMDDeviceCreateDesc hmdCreateDesc(this, deviceName, i); hmdCreateDesc.SetScreenParameters(screenInfo.x_org, screenInfo.y_org, 1280, 800, 0.14976f, 0.0936f); OVR_DEBUG_LOG_TEXT(("DeviceManager - HMD Found %s - %d\n", deviceName.ToCStr(), i)); // Notify caller about detected device. This will call EnumerateAddDevice // if the this is the first time device was detected. visitor.Visit(hmdCreateDesc); foundHMD = true; break; } } XFree(screens); } // Real HMD device is not found; however, we still may have a 'fake' HMD // device created via SensorDeviceImpl::EnumerateHMDFromSensorDisplayInfo. // Need to find it and set 'Enumerated' to true to avoid Removal notification. if (!foundHMD) { Ptr<DeviceCreateDesc> hmdDevDesc = getManager()->FindDevice("", Device_HMD); if (hmdDevDesc) hmdDevDesc->Enumerated = true; } }
static XineramaScreenInfo *x11_query_screens(Display *dpy, int *num_screens) { int major, minor; if (!XineramaQueryExtension(dpy, &major, &minor)) return NULL; XineramaQueryVersion(dpy, &major, &minor); RARCH_LOG("[X11]: Xinerama version: %d.%d.\n", major, minor); if (!XineramaIsActive(dpy)) return NULL; return XineramaQueryScreens(dpy, num_screens); }
void enumDisplayMonitors(DeviceInfo displays[], int& displayCounter) { ::Display* dpy = XOpenDisplay(NULL); if (dpy == NULL) { fatalError("Could not open display"); return; } int eventBase; int errorBase; if (XineramaQueryExtension(dpy, &eventBase, &errorBase)) { if (XineramaIsActive(dpy)) { int heads = 0; XineramaScreenInfo* queried = XineramaQueryScreens(dpy, &heads); for (int head = 0; head < heads; ++head) { ++displayCounter; XineramaScreenInfo& info = queried[head]; //log(Info, "Head %i: %ix%i @%i;%i", head + 1, info.width, info.height, info.x_org, info.y_org); DeviceInfo& di = displays[displayCounter]; di.isAvailable = true; di.x = info.x_org; di.y = info.y_org; di.width = info.width; di.height = info.height; // TODO (DK) // -is this always correct? if i switch screens on deb8/jessie with gnome it works ok // -what about other *nix or window managers? di.isPrimary = displayCounter == 0; // TODO (DK) // -this doesn't work yet, whatever is configured as primary is the first screen returned, // not what shows up in the config tool as [1], [2], ... // -and info.screen_number just seems to be useless (0 for first returned, 1 for next, ...) di.number = info.screen_number + 1; } XFree(queried); } else { log(Warning, "Xinerama is not active"); } } else { log(Warning, "Xinerama extension is not installed"); } }
int x11_shadow_xinerama_init(x11ShadowSubsystem* subsystem) { #ifdef WITH_XINERAMA int index; int numMonitors; int major, minor; int xinerama_event; int xinerama_error; MONITOR_DEF* monitor; XineramaScreenInfo* screen; XineramaScreenInfo* screens; if (!XineramaQueryExtension(subsystem->display, &xinerama_event, &xinerama_error)) return -1; if (!XDamageQueryVersion(subsystem->display, &major, &minor)) return -1; if (!XineramaIsActive(subsystem->display)) return -1; screens = XineramaQueryScreens(subsystem->display, &numMonitors); if (numMonitors > 16) numMonitors = 16; if (!screens || (numMonitors < 1)) return -1; subsystem->monitorCount = numMonitors; for (index = 0; index < numMonitors; index++) { screen = &screens[index]; monitor = &(subsystem->monitors[index]); monitor->left = screen->x_org; monitor->top = screen->y_org; monitor->right = monitor->left + screen->width; monitor->bottom = monitor->top + screen->height; monitor->flags = (index == 0) ? 1 : 0; } XFree(screens); #endif return 1; }
//========================================= // CountScreens //----------------------------------------- void CountScreens (Display *dpy) { int s_num,count; if ( XineramaIsActive(dpy)) { screens = XineramaQueryScreens(dpy, &s_num); scr_count = s_num; for (count = 0;count < scr_count; count++) { scr[count] = screens[count].screen_number; } scr_count = 1; } else { scr_count = ScreenCount(dpy); for (count = 0;count < scr_count; count++) { scr[count] = count; } } }
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; }
/** Init screen geo */ void screen_init_geo(void) { int i; int s = screen_count(); sgeo = xcalloc(s, sizeof(XRectangle)); spgeo = xcalloc(s, sizeof(XRectangle)); for(i = 0; i < s; ++i) sgeo[i] = screen_get_geo(i); spgeo[0].x = 0; spgeo[0].y = 0; spgeo[0].width = MAXW; spgeo[0].height = MAXH; #ifdef HAVE_XINERAMA XineramaScreenInfo *xsi; int n; if(XineramaIsActive(dpy)) { xsi = XineramaQueryScreens(dpy, &n); for(i = 0; i < n; ++i) { spgeo[i].x = xsi[i].x_org; spgeo[i].y = xsi[i].y_org; spgeo[i].width = xsi[i].width; spgeo[i].height = xsi[i].height; } XFree(xsi); } #endif /* HAVE_XINERAMA */ #ifdef HAVE_XRANDR /* Init xrandr stuff */ int d; XRRSelectInput(dpy, ROOT, 1); XRRQueryExtension(dpy, &xrandr_event, &d); #endif /* HAVE_XRANDR */ ewmh_set_desktop_geometry(); return; }
void wInitXinerama(WScreen * scr) { scr->xine_info.primary_head = 0; scr->xine_info.screens = NULL; scr->xine_info.count = 0; #ifdef USE_XINERAMA # ifdef SOLARIS_XINERAMA if (XineramaGetState(dpy, scr->screen)) { WXineramaInfo *info = &scr->xine_info; XRectangle head[MAXFRAMEBUFFERS]; unsigned char hints[MAXFRAMEBUFFERS]; int i; if (XineramaGetInfo(dpy, scr->screen, head, hints, &info->count)) { info->screens = wmalloc(sizeof(WMRect) * (info->count + 1)); for (i = 0; i < info->count; i++) { info->screens[i].pos.x = head[i].x; info->screens[i].pos.y = head[i].y; info->screens[i].size.width = head[i].width; info->screens[i].size.height = head[i].height; } } } # else /* !SOLARIS_XINERAMA */ if (XineramaIsActive(dpy)) { XineramaScreenInfo *xine_screens; WXineramaInfo *info = &scr->xine_info; int i; xine_screens = XineramaQueryScreens(dpy, &info->count); info->screens = wmalloc(sizeof(WMRect) * (info->count + 1)); for (i = 0; i < info->count; i++) { info->screens[i].pos.x = xine_screens[i].x_org; info->screens[i].pos.y = xine_screens[i].y_org; info->screens[i].size.width = xine_screens[i].width; info->screens[i].size.height = xine_screens[i].height; } XFree(xine_screens); } # endif /* !SOLARIS_XINERAMA */ #endif /* USE_XINERAMA */ }
/** Startup screens. */ void StartupScreens() { #ifdef USE_XINERAMA XineramaScreenInfo *info; int x; if(XineramaIsActive(display)) { info = XineramaQueryScreens(display, &screenCount); screens = Allocate(sizeof(ScreenType) * screenCount); for(x = 0; x < screenCount; x++) { screens[x].index = x; screens[x].x = info[x].x_org; screens[x].y = info[x].y_org; screens[x].width = info[x].width; screens[x].height = info[x].height; } JXFree(info); } else { screenCount = 1; screens = Allocate(sizeof(ScreenType)); screens->index = 0; screens->x = 0; screens->y = 0; screens->width = rootWidth; screens->height = rootHeight; } #else screenCount = 1; screens = Allocate(sizeof(ScreenType)); screens->index = 0; screens->x = 0; screens->y = 0; screens->width = rootWidth; screens->height = rootHeight; #endif /* USE_XINERAMA */ }
static void queryscreeninfo(Display *dpy, XRectangle *rect, int screen) { XineramaScreenInfo *xsi = NULL; int nscreens = 1; if(XineramaIsActive(dpy)) xsi = XineramaQueryScreens(dpy, &nscreens); if(xsi == NULL || screen > nscreens || screen <= 0) { qsi_no_xinerama(dpy, rect); } else { rect->x = xsi[screen-1].x_org; rect->y = xsi[screen-1].y_org; rect->width = xsi[screen-1].width; rect->height = xsi[screen-1].height; } }
int xf_list_monitors(xfContext* xfc) { #ifdef WITH_XINERAMA Display* display; int i, nmonitors = 0; int ignored, ignored2; XineramaScreenInfo* screen = NULL; display = XOpenDisplay(NULL); if (XineramaQueryExtension(display, &ignored, &ignored2)) { if (XineramaIsActive(display)) { screen = XineramaQueryScreens(display, &nmonitors); for (i = 0; i < nmonitors; i++) { printf(" %s [%d] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, screen[i].width, screen[i].height, screen[i].x_org, screen[i].y_org); } XFree(screen); } } XCloseDisplay(display); #else Screen* screen; Display* display; display = XOpenDisplay(NULL); screen = ScreenOfDisplay(display, DefaultScreen(display)); printf(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); XCloseDisplay(display); #endif return 0; }
/** Count the screens *\return the number of screen */ int screen_count(void) { int n = 0; n = ScreenCount(dpy); #ifdef HAVE_XINERAMA if(XineramaIsActive(dpy)) XineramaQueryScreens(dpy, &n); #endif /* HAVE_XINERAMA */ /* Set _WMFS_SCREEN_COUNT */ if(net_atom) XChangeProperty(dpy, ROOT, net_atom[wmfs_screen_count], XA_CARDINAL, 32, PropModeReplace, (uchar*)&n, 1); return n; }
static void initXinerama(void) { xineInfo.screens = NULL; xineInfo.count = 0; #ifdef USE_XINERAMA # ifdef SOLARIS_XINERAMA if (XineramaGetState(dpy, scr)) { XRectangle head[MAXFRAMEBUFFERS]; unsigned char hints[MAXFRAMEBUFFERS]; int i; if (XineramaGetInfo(dpy, scr, head, hints, &xineInfo.count)) { xineInfo.screens = wmalloc(sizeof(WMRect) * (xineInfo.count + 1)); for (i = 0; i < xineInfo.count; i++) { xineInfo.screens[i].pos.x = head[i].x; xineInfo.screens[i].pos.y = head[i].y; xineInfo.screens[i].size.width = head[i].width; xineInfo.screens[i].size.height = head[i].height; } } } # else /* !SOLARIS_XINERAMA */ if (XineramaIsActive(dpy)) { XineramaScreenInfo *xine_screens; int i; xine_screens = XineramaQueryScreens(dpy, &xineInfo.count); xineInfo.screens = wmalloc(sizeof(WMRect) * (xineInfo.count + 1)); for (i = 0; i < xineInfo.count; i++) { xineInfo.screens[i].pos.x = xine_screens[i].x_org; xineInfo.screens[i].pos.y = xine_screens[i].y_org; xineInfo.screens[i].size.width = xine_screens[i].width; xineInfo.screens[i].size.height = xine_screens[i].height; } XFree(xine_screens); } # endif /* !SOLARIS_XINERAMA */ #endif /* USE_XINERAMA */ }
static gboolean init_xfree_xinerama_indices (GdkX11Screen *x11_screen) { #ifdef HAVE_XFREE_XINERAMA XineramaScreenInfo *x_monitors; gint monitor_num; gint x_n_monitors; gint i; if (!XineramaIsActive (x11_screen->xdisplay)) return FALSE; x_monitors = XineramaQueryScreens (x11_screen->xdisplay, &x_n_monitors); if (x_n_monitors <= 0 || x_monitors == NULL) { if (x_monitors) XFree (x_monitors); return FALSE; } for (monitor_num = 0; monitor_num < x11_screen->n_monitors; ++monitor_num) { for (i = 0; i < x_n_monitors; ++i) { if (x11_screen->monitors[monitor_num].geometry.x == x_monitors[i].x_org && x11_screen->monitors[monitor_num].geometry.y == x_monitors[i].y_org && x11_screen->monitors[monitor_num].geometry.width == x_monitors[i].width && x11_screen->monitors[monitor_num].geometry.height == x_monitors[i].height) { g_hash_table_insert (x11_screen->xinerama_matches, GINT_TO_POINTER (monitor_num), GINT_TO_POINTER (i)); } } } XFree (x_monitors); return TRUE; #endif /* HAVE_XFREE_XINERAMA */ return FALSE; }
void screen_init(void) { struct geo g; SLIST_INIT(&W->h.screen); #ifdef HAVE_XINERAMA XineramaScreenInfo *xsi; int i, n = 0; if(XineramaIsActive(W->dpy)) { xsi = XineramaQueryScreens(W->dpy, &n); for(i = 0; i < n; ++i) { g.x = xsi[i].x_org; g.y = xsi[i].y_org; g.w = xsi[i].width; g.h = xsi[i].height; screen_new(&g, i); } W->nscreen = n; XFree(xsi); } else #endif /* HAVE_XINERAMA */ { g.x = g.y = 0; g.w = DisplayWidth(W->dpy, W->xscreen); g.h = DisplayHeight(W->dpy, W->xscreen); screen_new(&g, 0); W->nscreen = 1; } }