Ejemplo n.º 1
0
	std::list<Window> getAllWindows()
	{
		std::list<Window> res;

		for (int i = 0; i < ScreenCount(disp()); ++i)
			getAllWindows(RootWindow(disp(), i), res);

		return res;
	}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
    /* Parse options */
    struct Options o = parse_options(argc, argv);

    /* Create an X Display */
    Display *display = XOpenDisplay(o.display_name);
    if(!display)
    {
        fprintf(stderr,"%s: cannot connect to X server %s\n", argv[0],
                o.display_name);
        exit(-1);
    }

    int screen = (o.screen == -1) ? DefaultScreen(display) : o.screen;
    if(screen >= ScreenCount(display))
        invalid_argument(argv[0], "screen %d requested but X server only has %d screen%s\n",
                         screen, ScreenCount(display),
                         ScreenCount(display) == 1 ? "" : "s");
    printf("display: %s   screen: %i\n", o.display_name, screen);

    /* Create device */
    VdpDevice device;
    VdpGetProcAddress *get_proc_address;
    VdpStatus rv;
    rv = vdp_device_create_x11(display, screen, &device, &get_proc_address);
    if(rv != VDP_STATUS_OK)
    {
        fprintf(stderr, "Error creating VDPAU device: %i\n", rv); /* cannot use GetErrorString here */
        exit(-1);
    }

    VDPDeviceImpl *impl = new VDPDeviceImpl(device, get_proc_address);

    queryBaseInfo(impl);
    queryVideoSurface(impl);
    queryDecoderCaps(impl);
    queryOutputSurface(impl);
    queryBitmapSurface(impl);
    queryVideoMixer(impl);

    printf("\n");
}
Ejemplo n.º 3
0
int screen_number (Screen *screen)
{
  Display *dpy = DisplayOfScreen (screen);
  int i;
  for (i = 0; i < ScreenCount (dpy); i++)
    if (ScreenOfDisplay (dpy, i) == screen)
      return i;
  abort ();
  return 0;
}
Ejemplo n.º 4
0
/**
 * @brief constructor: gets Display vars and registers us
 */
XfitMan::XfitMan()
{
#if 0
    getAtoms();
#endif
    root = QX11Info::appRootWindow();
#if 0
    screencount = ScreenCount(QX11Info::display());
#endif
}
Ejemplo n.º 5
0
static void
get_server_info (Window *server_window, Display **display, string identity)
{
    int scr;

    /* Open our own connection to the X server, since sending messages
       through the server's connection hangs.  */
    *display = XOpenDisplay (NULL);
    if (*display == NULL)
        FATAL1 ("limn: Could not open display `%s'", getenv ("DISPLAY"));

    /* Get the identity atom. Create it if it doesn't exist.  */
    foserver_identity_atom
        = XInternAtom (*display, FOSERVER_IDENTITY_ATOM, False);

    /* Ask to be told about most window events.  */
    XSelectInput (*display, DefaultRootWindow (*display),
                  SubstructureNotifyMask);

    /* Remove potential race condition below -- if our server has already
       had its window realized, we wouldn't find it otherwise. Search all
       windows first.  We might just as well search all screens too. */
    *server_window = None;
    for (scr = ScreenCount (*display); scr > 0 && *server_window == None; scr--)
    {
        Window root = RootWindow (*display, scr - 1);
        *server_window = search_children (*display, root, identity);
    }

    while (*server_window == None)
    {
        XEvent event;
        Window w;

        /* Wait for an event that might mean our server is ready.  */
        XIfEvent (*display, &event, window_change_p, NULL);

        /* We look for some property on the window, and rely on our server
           setting that property.  */
        switch (event.type)
        {
        case MapNotify:
            w = event.xmap.window;
            *server_window = search_children (*display, w, identity);
            break;

        default:
            FATAL1 ("limn: Unexpected event (type %d)", event.type);
        }
    }

    /* We don't want to see any events any more.  */
    XSelectInput (*display, DefaultRootWindow (*display),
                  NoEventMask);
}
Ejemplo n.º 6
0
static void find_trans_colors()
{
    struct OverlayProp {
	long  visual;
	long  type;
	long  value;
	long  layer;
    };

    trans_colors_init = TRUE;

    Display* appDisplay = QPaintDevice::x11AppDisplay();

    int scr;
    int lastsize = 0;
    for ( scr = 0; scr < ScreenCount( appDisplay ); scr++ ) {
	QWidget* rootWin = QApplication::desktop()->screen( scr );
	if ( !rootWin )
	    return;					// Should not happen
	Atom overlayVisualsAtom = XInternAtom( appDisplay,
					       "SERVER_OVERLAY_VISUALS", True );
	if ( overlayVisualsAtom == None )
	    return;					// Server has no overlays

	Atom actualType;
	int actualFormat;
	ulong nItems;
	ulong bytesAfter;
	OverlayProp* overlayProps = 0;
	int res = XGetWindowProperty( appDisplay, rootWin->winId(),
				      overlayVisualsAtom, 0, 10000, False,
				      overlayVisualsAtom, &actualType,
				      &actualFormat, &nItems, &bytesAfter,
				      (uchar**)&overlayProps );

	if ( res != Success || actualType != overlayVisualsAtom
	     || actualFormat != 32 || nItems < 4 || !overlayProps )
	    return;					// Error reading property

	int numProps = nItems / 4;
	trans_colors.resize( lastsize + numProps );
	int j = lastsize;
	for ( int i = 0; i < numProps; i++ ) {
	    if ( overlayProps[i].type == 1 ) {
		trans_colors[j].vis = (VisualID)overlayProps[i].visual;
		trans_colors[j].screen = scr;
		trans_colors[j].color = (int)overlayProps[i].value;
		j++;
	    }
	}
	XFree( overlayProps );
	lastsize = j;
	trans_colors.truncate( lastsize );
    }
}
Ejemplo n.º 7
0
static int
_XftDrawScreen (Display *dpy, Drawable drawable, Visual *visual)
{
    int		    s;
    Window	    root;
    int		    x, y;
    unsigned int    width, height, borderWidth, depth;
    /* Special case the most common environment */
    if (ScreenCount (dpy) == 1)
	return 0;
    /*
     * If we've got a visual, look for the screen that points at it.
     * This requires no round trip.
     */
    if (visual)
    {
	for (s = 0; s < ScreenCount (dpy); s++)
	{
	    XVisualInfo	template, *ret;
	    int		nret;
Ejemplo n.º 8
0
void initscreens(void) {
   numscreens = ScreenCount(display);
   screens = malloc(numscreens * sizeof(struct screen));
   int i;
   for (i=0; i<numscreens; i++) {
      screens[i].screen = ScreenOfDisplay(display,i);
      screens[i].desktop = i;//initially screens are parallel to desktops
      screens[i].width = screens[i].screen->width;
      screens[i].height = screens[i].screen->height;
   }
}
Ejemplo n.º 9
0
void DeleteXloginResources(struct display *d, Display * dpy)
{
	int i;
	Atom prop = XInternAtom(dpy, "SCREEN_RESOURCES", True);

	XDeleteProperty(dpy, RootWindow(dpy, 0), XA_RESOURCE_MANAGER);
	if (prop) {
		for (i = ScreenCount(dpy); --i >= 0;)
			XDeleteProperty(dpy, RootWindow(dpy, i), prop);
	}
}
Ejemplo n.º 10
0
void
run(void) {
	for(int scr=0;scr < ScreenCount(dpy); scr++) {
		XUngrabButton(dpy, AnyButton, AnyModifier, RootWindow (dpy, scr));
	}

	for(int scr=0;scr < ScreenCount(dpy); scr++) {
		XGrabButton(dpy, button, AnyModifier, RootWindow(dpy, scr),
				False, ButtonPressMask | ButtonReleaseMask,
				GrabModeAsync, GrabModeAsync, None, None);
	}

	for(;;) {
		XEvent ev;
		XNextEvent(dpy, &ev);
		if(ev.xbutton.button == button && ev.xbutton.type == btype) {
			spawn();
		}
	}
}
Ejemplo n.º 11
0
void x11_hotkeys::ungrabkeys()
{ 
  if (grab_key.key.sym==0)
    return;
  Display *d=display;

  for (int screen = 0; screen<ScreenCount(d); screen++) {
    XUngrabKey(d, AnyKey, AnyModifier, RootWindow (d, screen));
    XUngrabButton(d, AnyButton, AnyModifier, RootWindow (d, screen));
  }  
}
Ejemplo n.º 12
0
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
*/
static Bool
AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
   __GLXscreenConfigs *psc;
   GLint i, screens;

   /*
    ** First allocate memory for the array of per screen configs.
    */
   screens = ScreenCount(dpy);
   psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
   if (!psc) {
      return GL_FALSE;
   }
   memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
   priv->screenConfigs = psc;

   priv->serverGLXversion =
      __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
   if (priv->serverGLXversion == NULL) {
      FreeScreenConfigs(priv);
      return GL_FALSE;
   }

   for (i = 0; i < screens; i++, psc++) {
      getVisualConfigs(dpy, priv, i);
      getFBConfigs(dpy, priv, i);

#ifdef GLX_DIRECT_RENDERING
      psc->scr = i;
      psc->dpy = dpy;
      psc->drawHash = __glxHashCreate();
      if (psc->drawHash == NULL)
         continue;

      if (priv->dri2Display)
         psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL && priv->driDisplay)
         psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL && priv->driswDisplay)
         psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL) {
         __glxHashDestroy(psc->drawHash);
         psc->drawHash = NULL;
      }
#endif
   }
   SyncHandle();
   return GL_TRUE;
}
Ejemplo n.º 13
0
static void ungrab_key(KeyCode code)
{
	int i;

	gdk_error_trap_push();
	for (i = 0; i < ScreenCount(GDK_DISPLAY()); i++)
		XUngrabKey(GDK_DISPLAY(), code,
				AnyModifier, RootWindow(GDK_DISPLAY(),i));
	gdk_flush();
	if (gdk_error_trap_pop())
		g_warning("Couldn't ungrab keycode %d", code);
}
Ejemplo n.º 14
0
/*
 *	NAME
 *		_XcmsInitDefaultCCCs
 *
 *	SYNOPSIS
 */
int
_XcmsInitDefaultCCCs(
    Display *dpy)
/*
 *	DESCRIPTION
 *		Initializes the Xcms per Display Info structure
 *		(XcmsPerDpyInfo).
 *
 *	RETURNS
 *		Returns 0 if failed; otherwise non-zero.
 *
 */
{
    int nScrn = ScreenCount(dpy);
    int i;
    XcmsCCC ccc;

    if (nScrn <= 0) {
	return(0);
    }

    /*
     * Create an array of XcmsCCC structures, one for each screen.
     * They serve as the screen's default CCC.
     */
    if (!(ccc = (XcmsCCC)
	    Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
	return(0);
    }
    dpy->cms.defaultCCCs = (XPointer)ccc;
    dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;

    for (i = 0; i < nScrn; i++, ccc++) {
	ccc->dpy = dpy;
	ccc->screenNumber = i;
	ccc->visual = DefaultVisual(dpy, i);
	/*
	 * Used calloc to allocate memory so:
	 *	ccc->clientWhitePt->format == XcmsUndefinedFormat
	 *	ccc->gamutCompProc == NULL
	 *	ccc->whitePtAdjProc == NULL
	 *	ccc->pPerScrnInfo = NULL
	 *
	 * Don't need to create XcmsPerScrnInfo and its functionSet and
	 * pScreenData components until the default CCC is accessed.
	 * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
	 * to do this.
	 */
	ccc->gamutCompProc = XCMSCOMPPROC;
    }

    return(1);
}
Ejemplo n.º 15
0
int NvCtrlGetScreenCount(NvCtrlAttributeHandle *handle)
{
    NvCtrlAttributePrivateHandle *h;

    if (!handle) return -1;

    h = (NvCtrlAttributePrivateHandle *) handle;

    if (!h->dpy) return -1;
    return ScreenCount(h->dpy);

} /* NvCtrlGetScreenCount() */
Ejemplo n.º 16
0
int
screen_number (Screen *screen)
{
#ifndef WIN32
  Display *dpy = DisplayOfScreen (screen);
  int i;
  for (i = 0; i < ScreenCount (dpy); i++)
    if (ScreenOfDisplay (dpy, i) == screen)
      return i;
#endif
  return 0;
}
Ejemplo n.º 17
0
int xdo_window_search(const xdo_t *xdo, const xdo_search_t *search,
                      Window **windowlist_ret, int *nwindows_ret) {
  Window *candidate_window_list = NULL;
  int ncandidate_windows = 0;
  int candidate_window_list_size = 0;
  int matched_window_list_size = 100;
  int i = 0;

  *nwindows_ret = 0;
  *windowlist_ret = calloc(sizeof(Window), matched_window_list_size);

  /* TODO(sissel): Support multiple screens */
  if (search->searchmask & SEARCH_SCREEN) {
    _xdo_get_child_windows(xdo, RootWindow(xdo->xdpy, search->screen), search->max_depth,
                           &candidate_window_list, &ncandidate_windows,
                           &candidate_window_list_size);
  } else {
    const int screencount = ScreenCount(xdo->xdpy);
    for (i = 0; i < screencount; i++) {
      _xdo_get_child_windows(xdo, RootWindow(xdo->xdpy, i), search->max_depth,
                             &candidate_window_list, &ncandidate_windows,
                             &candidate_window_list_size);
    }
  }
  //printf("Window count: %d\n", (int)ncandidate_windows);
  //printf("Search:\n");
  //printf("onlyvisible: %d\n", search->only_visible);
  //printf("pid: %lu\n", search->pid);
  //printf("title: %s\n", search->title);
  //printf("name: %s\n", search->winname);
  //printf("class: %s\n", search->winclass);
  //printf("classname: %s\n", search->winclassname);
  //printf("//Search\n");

  for (i = 0; i < ncandidate_windows; i++) {
    Window wid = candidate_window_list[i];
    if (!check_window_match(xdo, wid, search))
      continue;

    (*windowlist_ret)[*nwindows_ret] = wid;
    (*nwindows_ret)++;

    if (matched_window_list_size == *nwindows_ret) {
      matched_window_list_size *= 2;
      *windowlist_ret = realloc(*windowlist_ret, 
                                matched_window_list_size * sizeof(Window));
    }
  }
  free(candidate_window_list);

  return XDO_SUCCESS;
}
Ejemplo n.º 18
0
Archivo: lock.c Proyecto: philomath/bin
int
main(int argc, char *argv[])
{
    const char *pws;
    Display *dpy;

    if ((argc == 2) && (strcmp("-v", argv[1]) == 0))
        die("lock "VERSION", © 2006-2012 Anselm R Garbe, 2012 philomath\n");
    else if (argc != 1)
        die("usage: lock [-v]\n");

    pws = getpw();

    if ((dpy = XOpenDisplay(NULL)) == NULL)
        die("lock: cannot open display\n");

    /* Get the number of screens in display "dpy" and blank them all. */
    nscreens = ScreenCount(dpy);
    locks = malloc(sizeof(Lock *) * nscreens);

    if (locks == NULL)
        die("lock: malloc failed\n");

    int nlocks = 0;

    for (int i = 0; i < nscreens; ++i)
    {
        if ((locks[i] = lockscreen(dpy, i)) != NULL)
            nlocks++;
    }

    /* Did we actually manage to lock something? */
    if (nlocks == 0)   // nothing to protect
    {
        free(locks);
        XCloseDisplay(dpy);
        die("cannot lock anything\n");
    }

    /* Everything is now blank. Now wait for the correct password. */
    readpw(dpy, pws);

    /* Password ok, unlock everything and quit. */
    for (int i = 0; i < nscreens; ++i)
        unlockscreen(dpy, locks[i]);

    free(locks);
    XCloseDisplay(dpy);
    return 0;
}
Ejemplo n.º 19
0
/*
 *	NAME
 *		_XcmsFreeDefaultCCCs - Free Default CCCs and its PerScrnInfo
 *
 *	SYNOPSIS
 */
static void
_XcmsFreeDefaultCCCs(
    Display *dpy)
/*
 *	DESCRIPTION
 *		This routine frees the default XcmsCCC's associated with
 *		each screen and its associated substructures as neccessary.
 *
 *	RETURNS
 *		void
 *
 *
 */
{
    int nScrn = ScreenCount(dpy);
    XcmsCCC ccc;
    int i;

    /*
     * Free Screen data in each DefaultCCC
     *		Do not use XcmsFreeCCC here because it will not free
     *		DefaultCCC's.
     */
    ccc = (XcmsCCC)dpy->cms.defaultCCCs;
    for (i = nScrn; i--; ccc++) {
	/*
	 * Check if XcmsPerScrnInfo exists.
	 *
	 * This is the only place where XcmsPerScrnInfo structures
	 * are freed since there is only one allocated per Screen.
	 * It just so happens that we place its reference in the
	 * default CCC.
	 */
	if (ccc->pPerScrnInfo) {
	    /* Check if SCCData exists */
	    if (ccc->pPerScrnInfo->state != XcmsInitNone
		    && ccc->pPerScrnInfo->screenData) {
		(*((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->screenFreeProc)
			(ccc->pPerScrnInfo->screenData);
	    }
	    Xfree(ccc->pPerScrnInfo);
	}
    }

    /*
     * Free the array of XcmsCCC structures
     */
    Xfree(dpy->cms.defaultCCCs);
    dpy->cms.defaultCCCs = (XPointer)NULL;
}
Ejemplo n.º 20
0
/*
 * Find which screen the window W is the root of.
 * Returns the screen number, or -1 if W is not a root.
 */
static int
awt_mgrsel_screen(Window w)
{
    Display *dpy = awt_display;
    int scr;

    for (scr = 0; scr < ScreenCount(dpy); ++scr) {
	if (w == RootWindow(dpy, scr)) {
	    return (scr);
	}
    }

    return (-1);
}
Ejemplo n.º 21
0
/*! \internal
*/
int QCursor::x11Screen()
{
    Window root;
    Window child;
    int root_x, root_y, win_x, win_y;
    uint buttons;
    Display* dpy = QPaintDevice::x11AppDisplay();
    for ( int i = 0; i < ScreenCount( dpy ); i++ ) {
	if ( XQueryPointer( dpy, QPaintDevice::x11AppRootWindow( i ), &root, &child,
			    &root_x, &root_y, &win_x, &win_y, &buttons ) )
	    return i;
    }
    return -1;
}
Ejemplo n.º 22
0
static void module_free() {

    if (data.windows) {
        int i;
        for (i = 0; i < ScreenCount(data.display); i++)
            XDestroyWindow(data.display, data.windows[i]);
        free(data.windows);
        data.windows = NULL;
    }

    free(data.colorname);
    data.colorname = NULL;

}
Ejemplo n.º 23
0
/*! \internal
*/
int QCursor::x11Screen()
{
    Window root;
    Window child;
    int root_x, root_y, win_x, win_y;
    uint buttons;
    Display* dpy = X11->display;
    for (int i = 0; i < ScreenCount(dpy); ++i) {
        if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
                          &win_x, &win_y, &buttons))
            return i;
    }
    return -1;
}
Ejemplo n.º 24
0
Archivo: main.c Proyecto: Arkq/alock
/* Lock current display and grab pointer and keyboard. On successful
 * lock this function returns 0, otherwise -1. */
static int lockDisplay(Display *display, struct aModules *modules) {

    Window window;
    Cursor cursor;
    int i;

    for (i = 0; i < ScreenCount(display); i++) {

        /* raise background window */
        if ((window = modules->background->getwindow(i)) != None) {

            Window window_input;

            if ((window_input = modules->input->getwindow(i)) != None)
                XReparentWindow(display, window_input, window, 0, 0);

            XMapWindow(display, window);
            XRaiseWindow(display, window);

        }

        /* receive notification about root window geometry change */
        XSelectInput(display, RootWindow(display, i), StructureNotifyMask);
    }

    /* grab pointer and keyboard from the default screen */
    window = DefaultRootWindow(display);
    cursor = modules->cursor->getcursor();

    if (XGrabPointer(display, window, False, None, GrabModeAsync, GrabModeAsync, None,
                cursor, CurrentTime) != GrabSuccess) {
        fprintf(stderr, "error: grab pointer failed\n");
        return -1;
    }

    /* try to grab 2 times, another process (windowmanager) may have grabbed
     * the keyboard already */
    if (XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync,
                CurrentTime) != GrabSuccess) {
        sleep(1);
        if (XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync,
                    CurrentTime) != GrabSuccess) {
            fprintf(stderr, "error: grab keyboard failed\n");
            return -1;
        }
    }

    return 0;
}
Ejemplo n.º 25
0
	std::list<Window> getTopLevelWindows()
	{
		std::list<Window> res;

		if (!ewmhIsSupported()) {
			blog(LOG_WARNING, "Unable to query window list "
					"because window manager "
					"does not support extended "
					"window manager Hints");
			return res;
		}

		Atom netClList = XInternAtom(disp(), "_NET_CLIENT_LIST", true);
		Atom actualType;
		int format;
		unsigned long num, bytes;
		Window* data = 0;

		for (int i = 0; i < ScreenCount(disp()); ++i) {
			Window rootWin = RootWindow(disp(), i);

			int status = XGetWindowProperty(
							 disp(),
							 rootWin,
							 netClList,
							 0L,
							 ~0L,
							 false,
							 AnyPropertyType,
							 &actualType,
							 &format,
							 &num,
							 &bytes,
							 (uint8_t**)&data);

			if (status != Success) {
				blog(LOG_WARNING, "Failed getting root "
				                  "window properties");
				continue;
			}

			for (unsigned long i = 0; i < num; ++i)
				res.push_back(data[i]);

			XFree(data);
		}

		return res;
	}
Ejemplo n.º 26
0
static void
findServerOverlayVisualsInfo(Display *dpy)
{
	static Atom overlayVisualsAtom;
	Atom actualType;
	Status status;
	unsigned long sizeData, bytesLeft;
	Window root;
	int actualFormat, numScreens, i;

	if ( layersRead == False ) 
	{
		overlayVisualsAtom = XSGIFastInternAtom(dpy,
				"SERVER_OVERLAY_VISUALS", SGI_XA_SERVER_OVERLAY_VISUALS, True);
		if ( overlayVisualsAtom != None ) 
		{
			numScreens = ScreenCount(dpy);
			overlayInfoPerScreen = (sovOverlayInfo**) ALLOC(numScreens * sizeof(sovOverlayInfo*));
			numOverlaysPerScreen = ( unsigned long * ) ALLOC(numScreens * sizeof(unsigned long));
			if ( overlayInfoPerScreen != NULL && numOverlaysPerScreen != NULL )
			{
				for ( i = 0; i < numScreens; i++ )
				{
					root = RootWindow(dpy, i);
					status = XGetWindowProperty(dpy, root,
							overlayVisualsAtom, 0L, (long)10000, False,
							overlayVisualsAtom, &actualType, &actualFormat,
							&sizeData, &bytesLeft,
							(unsigned char **) &overlayInfoPerScreen[i] );
					if ( status != Success ||
							actualType != overlayVisualsAtom ||
							actualFormat != 32 || sizeData < 4 )
						numOverlaysPerScreen[i] = 0;
					else
						/* Four 32-bit quantities per SERVER_OVERLAY_VISUALS entry . */
						numOverlaysPerScreen[i] = sizeData / 4;
				}
				layersRead = True;
			}
			else
			{
				if ( overlayInfoPerScreen != NULL )
					FREE( overlayInfoPerScreen );
				if ( numOverlaysPerScreen != NULL )
					FREE( numOverlaysPerScreen );
			}
		}
	}
}
Ejemplo n.º 27
0
/* If the viewport has been scrolled since the screen was blanked,
   then scroll it back to where it belongs.  This function only exists
   to patch over a very brief race condition.
 */
static void
undo_vp_motion (saver_info *si)
{
#ifdef HAVE_XF86VMODE
  saver_preferences *p = &si->prefs;
  int screen;
  int real_nscreens = ScreenCount (si->dpy);
  int event, error;

  if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
    return;

  for (screen = 0; screen < real_nscreens; screen++)
    {
      saver_screen_info *ssi = &si->screens[screen];
      int x, y;
      Bool status;

      if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
        break;
      if (!XF86VidModeGetViewPort (si->dpy, screen, &x, &y))
        return;
      if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
        return;

      /* We're going to move the viewport.  The mouse has just been grabbed on
         (and constrained to, thus warped to) the password window, so it is no
         longer near the edge of the screen.  However, wait a bit anyway, just
         to make sure the server drains its last motion event, so that the
         screen doesn't continue to scroll after we've reset the viewport.
       */
      XSync (si->dpy, False);
      usleep (250000);  /* 1/4 second */
      XSync (si->dpy, False);

      status = XF86VidModeSetViewPort (si->dpy, screen,
                                       ssi->blank_vp_x, ssi->blank_vp_y);

      if (!status)
        fprintf (stderr,
                 "%s: %d: unable to move vp from (%d,%d) back to (%d,%d)!\n",
                 blurb(), screen, x, y, ssi->blank_vp_x, ssi->blank_vp_y);
      else if (p->verbose_p)
        fprintf (stderr,
                 "%s: %d: vp moved to (%d,%d); moved it back to (%d,%d).\n",
                 blurb(), screen, x, y, ssi->blank_vp_x, ssi->blank_vp_y);
    }
#endif /* HAVE_XF86VMODE */
}
Ejemplo n.º 28
0
static void
initScreens(void) {
    int screen;

    /* Find out how many screens we've got, and allocate space for their info. */
    screen_count = ScreenCount(dpy);
    screens = (ScreenInfo *) malloc(screen_count * sizeof(ScreenInfo));

    /* Go through the screens one-by-one, initialising them. */
    for (screen = 0; screen < screen_count; screen++) {
        initialiseCursors(screen);
        initScreen(screen);
        scanWindowTree(screen);
    }
}
Ejemplo n.º 29
0
void sendUpdateInfo(Atom what)
{
    unsigned int i, nrootwins;
    Window dw1, dw2, *rootwins = 0;
    int screen_count = ScreenCount(fl_display);
    for (int s = 0; s < screen_count; s++) {
        Window root = RootWindow(fl_display, s);
        XQueryTree(fl_display, root, &dw1, &dw2, &rootwins, &nrootwins);
        for (i = 0; i < nrootwins; i++) {
            if (rootwins[i]!=RootWindow(fl_display, fl_screen)) {
                sendClientMessage(rootwins[i], what, 0);
            }
        }
    }
}
// Look for an existing Colormap that known to be associated with visual.
static Colormap
LookupColormapForVisual(const Screen* screen, const Visual* visual)
{
    // common case
    if (visual == DefaultVisualOfScreen(screen))
        return DefaultColormapOfScreen(screen);

#ifdef MOZ_WIDGET_GTK2
    // I wish there were a gdk_x11_display_lookup_screen.
    Display* dpy = DisplayOfScreen(screen);
    GdkDisplay* gdkDpy = gdk_x11_lookup_xdisplay(dpy);
    if (gdkDpy) {
        gint screen_num = 0;
        for (int s = 0; s < ScreenCount(dpy); ++s) {
            if (ScreenOfDisplay(dpy, s) == screen) {
                screen_num = s;
                break;
            }
        }
        GdkScreen* gdkScreen = gdk_display_get_screen(gdkDpy, screen_num);

        GdkColormap* gdkColormap = NULL;
        if (visual ==
            GDK_VISUAL_XVISUAL(gdk_screen_get_rgb_visual(gdkScreen))) {
            // widget/src/gtk2/mozcontainer.c uses gdk_rgb_get_colormap()
            // which is inherited by child widgets, so this is the visual
            // expected when drawing directly to widget surfaces or surfaces
            // created using cairo_surface_create_similar with
            // CAIRO_CONTENT_COLOR.
            // gdk_screen_get_rgb_colormap is the generalization of
            // gdk_rgb_get_colormap for any screen.
            gdkColormap = gdk_screen_get_rgb_colormap(gdkScreen);
        }
        else if (visual ==
             GDK_VISUAL_XVISUAL(gdk_screen_get_rgba_visual(gdkScreen))) {
            // This is the visual expected on displays with the Composite
            // extension enabled when the surface has been created using
            // cairo_surface_create_similar with CAIRO_CONTENT_COLOR_ALPHA,
            // as happens with non-unit opacity.
            gdkColormap = gdk_screen_get_rgba_colormap(gdkScreen);
        }
        if (gdkColormap != NULL)
            return GDK_COLORMAP_XCOLORMAP(gdkColormap);
    }
#endif

    return None;
}