Exemplo n.º 1
0
AppX11::AppX11(QObject *parent)
: QObject(parent), d(new Data) {
    d->xssTimer.setInterval(20000);
    connect(&d->xssTimer, &QTimer::timeout, this, [this] () {
        if (d->xss && d->display) {
            _Trace("Call XResetScreenSaver().");
            XResetScreenSaver(d->display);
        } else
            _Error("Cannot run XResetScreenSaver().");
    });
    connect(&d->hbTimer, &QTimer::timeout, this, [this] () {
        if (!d->hbCommand.isEmpty()) {
            if (QProcess::startDetached(d->hbCommand))
                _Trace("Run command: %%", d->hbCommand);
            else
                _Error("Cannot run command: %%", d->hbCommand);
        } else
            _Error("No command for heartbeat");
    });
    d->connection = QX11Info::connection();
    d->display = QX11Info::display();
    d->root = QX11Info::appRootWindow();
    d->aNetWmState = d->getAtom("_NET_WM_STATE");
    d->aNetWmStateAbove = d->getAtom("_NET_WM_STATE_ABOVE");
    d->aNetWmStateStaysOnTop = d->getAtom("_NET_WM_STATE_STAYS_ON_TOP");
}
Exemplo n.º 2
0
EXPORT_C_(void) PADupdate(int pad)
{
	// Gamepad inputs don't count as an activity. Therefore screensaver will
	// be fired after a couple of minute.
	// Emulate an user activity
	static int count = 0;
	count++;
	if ((count & 0xFFF) == 0) {
		// 1 call every 4096 Vsync is enough
		XResetScreenSaver(GSdsp);
	}

	// Actually PADupdate is always call with pad == 0. So you need to update both
	// pads -- Gregory

	// Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
	// So we will populate both pad in the same time
	for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
		key_status->keyboard_state_acces(cpad);
	}
	PollForX11KeyboardInput();

	// Get joystick state + Commit
	for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
		key_status->joystick_state_acces(cpad);

		PollForJoystickInput(cpad);

		key_status->commit_status(cpad);
	}
}
Exemplo n.º 3
0
void ScreenSaverX11::Reset(void)
{
    bool need_xsync = false;
    Display *dsp = NULL;
    if (d->m_display)
        dsp = d->m_display->GetDisplay();

    if (dsp)
    {
        XResetScreenSaver(dsp);
        need_xsync = true;
    }

    if (d->IsScreenSaverRunning())
        resetSlot();

    if (Asleep() && dsp)
    {
        DPMSForceLevel(dsp, DPMSModeOn);
        need_xsync = true;
    }

    if (need_xsync && d->m_display)
        d->m_display->Sync();
}
Exemplo n.º 4
0
void
X11_SuspendScreenSaver(_THIS)
{
#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    int dummy;
    int major_version, minor_version;

    if (SDL_X11_HAVE_XSS) {
        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
            !XScreenSaverQueryVersion(data->display,
                                      &major_version, &minor_version) ||
            major_version < 1 || (major_version == 1 && minor_version < 1)) {
            return;
        }

        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
        XResetScreenSaver(data->display);
    }
#endif

#if SDL_USE_LIBDBUS
    if (_this->suspend_screensaver) {
        SDL_dbus_screensaver_tickle(_this);
    }
#endif
}
Exemplo n.º 5
0
void
X11_SuspendScreenSaver(_THIS)
{
#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    int dummy;
    int major_version, minor_version;

    if (SDL_X11_HAVE_XSS) {
        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
            !XScreenSaverQueryVersion(data->display,
                                      &major_version, &minor_version) ||
            major_version < 1 || (major_version == 1 && minor_version < 1)) {
            return;
        }

        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
        XResetScreenSaver(data->display);
    }
#endif

#ifdef GNOME_SCREENSAVER_HACK
    if (_this->suspend_screensaver) {
        gnome_screensaver_disable();
    } else {
        gnome_screensaver_enable();
    }
#endif
}
Exemplo n.º 6
0
void MainWindowImpl::PokeScreensaver(void)
{
	XResetScreenSaver (QX11Info::display ());
	if( pProxy )
	{
		dbus_g_proxy_call_no_reply (pProxy, "SimulateUserActivity",G_TYPE_INVALID);
	}
}
Exemplo n.º 7
0
void ScreenSaverX11::Restore(void)
{
    d->RestoreScreenSaver();
    d->RestoreDPMS();

    // One must reset after the restore
    XResetScreenSaver(qt_xdisplay());

    if (d->IsScreenSaverRunning())
        d->StopTimer();
}
Exemplo n.º 8
0
void ScreenSaverX11::Disable(void)
{
    d->SaveScreenSaver();
    XResetScreenSaver(qt_xdisplay());

    XSetScreenSaver(qt_xdisplay(), 0, 0, 0, 0);

    d->DisableDPMS();

    if (d->IsScreenSaverRunning())
        d->ResetTimer();
}
Exemplo n.º 9
0
void ScreenSaverX11::Reset(void)
{
    XResetScreenSaver(qt_xdisplay());
    if (d->IsScreenSaverRunning())
        resetSlot();

    if (Asleep())
    {
        DPMSForceLevel(qt_xdisplay(), DPMSModeOn);
	// Calling XSync is necessary for the case when Myth executes
	// another application before the event loop regains control
        XSync(qt_xdisplay(), false);
    }
}
Exemplo n.º 10
0
void ScreenSaverX11::Restore(void)
{
    d->RestoreScreenSaver();
    d->RestoreDPMS();

    // One must reset after the restore
    if (d->m_display)
    {
        XResetScreenSaver(d->m_display->GetDisplay());
        d->m_display->Sync();
    }

    if (d->IsScreenSaverRunning())
        d->StopTimer();
}
Exemplo n.º 11
0
void ScreenSaverX11::Disable(void)
{
    d->SaveScreenSaver();

    if (d->m_display)
    {
        XResetScreenSaver(d->m_display->GetDisplay());
        XSetScreenSaver(d->m_display->GetDisplay(), 0, 0, 0, 0);
        d->m_display->Sync();
    }

    d->DisableDPMS();

    if (d->IsScreenSaverRunning())
        d->ResetTimer();
}
Exemplo n.º 12
0
AppX11::AppX11(QObject *parent)
: QObject(parent), d(new Data) {
	d->ss_timer.setInterval(20000);
	connect(&d->ss_timer, &QTimer::timeout, [this] () {
		if (d->xss && d->display) {
			_Trace("Call XResetScreenSaver().");
			XResetScreenSaver(d->display);
		} else
			_Error("Cannot run XResetScreenSaver().");
	});
	d->connection = QX11Info::connection();
	d->display = QX11Info::display();
	d->root = QX11Info::appRootWindow();
	d->aNetWmState = d->getAtom("_NET_WM_STATE");
	d->aNetWmStateAbove = d->getAtom("_NET_WM_STATE_ABOVE");
	d->aNetWmStateStaysOnTop = d->getAtom("_NET_WM_STATE_STAYS_ON_TOP");
}
Exemplo n.º 13
0
int XForceScreenSaver(Display *display, int mode) {
    // https://tronche.com/gui/x/xlib/window-and-session-manager/XForceScreenSaver.html
    // https://www.libsdl.org/tmp/docs-1.3/_s_d_l__video_8h.html#6e5293ce67509a49c1ead749fc4547d9
    SET_X_SERVER_REQUEST(display, X_ForceScreenSaver);
    switch (mode) {
        case ScreenSaverActive:
            // Activate the screen saver now
            SDL_EnableScreenSaver();
            break;
        case ScreenSaverReset:
            XResetScreenSaver(display);
            break;
        default:
            handleError(0, display, None, 0, BadValue, 0);
            return 0;
    }
    return 1;
}
Exemplo n.º 14
0
void CWinSystemX11::ResetOSScreensaver()
{
  if (m_bFullScreen)
  {
    //disallow the screensaver when we're fullscreen by periodically calling XResetScreenSaver(),
    //normally SDL does this but we disable that in CApplication::Create()
    //for some reason setting a 0 timeout with XSetScreenSaver doesn't work with gnome
    if (!m_screensaverReset.IsRunning() || m_screensaverReset.GetElapsedSeconds() > 5.0f)
    {
      m_screensaverReset.StartZero();
      XResetScreenSaver(m_dpy);
    }
  }
  else
  {
    m_screensaverReset.Stop();
  }
}
Exemplo n.º 15
0
void
X11_PumpEvents(_THIS)
{
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

    /* Update activity every 30 seconds to prevent screensaver */
    if (_this->suspend_screensaver) {
        Uint32 now = SDL_GetTicks();
        if (!data->screensaver_activity ||
            (int) (now - data->screensaver_activity) >= 30000) {
            XResetScreenSaver(data->display);
            data->screensaver_activity = now;
        }
    }

    /* Keep processing pending events */
    while (X11_Pending(data->display)) {
        X11_DispatchEvent(_this);
    }
}
Exemplo n.º 16
0
void DGA_PumpEvents(_THIS)
{
	/* Keep processing pending events */
	LOCK_DISPLAY();

	/* Update activity every five seconds to prevent screensaver. --ryan. */
	if (!allow_screensaver) {
		static Uint32 screensaverTicks;
		Uint32 nowTicks = SDL_GetTicks();
		if ((nowTicks - screensaverTicks) > 5000) {
			XResetScreenSaver(DGA_Display);
			screensaverTicks = nowTicks;
		}
	}

	while ( X11_Pending(DGA_Display) ) {
		DGA_DispatchEvent(this);
	}
	UNLOCK_DISPLAY();
}
void
screensaver_deactivate(Display *dpy, uint32_t types)
{
    if (types & SST_XSCREENSAVER)
        deactivate_xscreensaver(dpy);

    // reset internal X screen saver timer
    XResetScreenSaver(dpy);

#if HAVE_GLIB_DBUS
    if (types & SST_FDO_SCREENSAVER)
        deactivate_dbus_based_screensaver(FDOS_SERVICE, FDOS_PATH, FDOS_INTERFACE);

    if (types & SST_GNOME_SCREENSAVER)
        deactivate_dbus_based_screensaver(GS_SERVICE, GS_PATH, GS_INTERFACE);

    if (types & SST_KDE_SCREENSAVER)
        deactivate_dbus_based_screensaver(KS_SERVICE, KS_PATH, KS_INTERFACE);

    if (types & SST_CINNAMON_SCREENSAVER)
        deactivate_dbus_based_screensaver(CINNAMON_SERVICE, CINNAMON_PATH, CINNAMON_INTERFACE);
#endif // HAVE_GLIB_DBUS
}
Exemplo n.º 18
0
void
Tk_ResetUserInactiveTime(
    Display *dpy)
{
    XResetScreenSaver(dpy);
}
Exemplo n.º 19
0
void
X11_PumpEvents(_THIS)
{
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

    /* Update activity every 30 seconds to prevent screensaver */
    if (_this->suspend_screensaver) {
        Uint32 now = SDL_GetTicks();
        if (!data->screensaver_activity ||
            (int) (now - data->screensaver_activity) >= 30000) {
            XResetScreenSaver(data->display);
            data->screensaver_activity = now;
        }
    }

    /* Keep processing pending events */
    while (X11_Pending(data->display)) {
        X11_DispatchEvent(_this);
    }

#ifdef SDL_INPUT_LINUXEV
    /* Process Touch events - TODO When X gets touch support, use that instead*/
    int i = 0,rd;
    char name[256];
    struct input_event ev[64];
    int size = sizeof (struct input_event);

    for(i = 0;i < SDL_GetNumTouch();++i) {
	SDL_Touch* touch = SDL_GetTouchIndex(i);
	if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
	EventTouchData* data;
	data = (EventTouchData*)(touch->driverdata);
	if(data == NULL) {
	  printf("No driver data\n");
	  continue;
	}
	if(data->eventStream <= 0) 
	    printf("Error: Couldn't open stream\n");
	rd = read(data->eventStream, ev, size * 64);
	//printf("Got %i/%i bytes\n",rd,size);
	if(rd >= size) {
	    for (i = 0; i < rd / sizeof(struct input_event); i++) {
		switch (ev[i].type) {
		case EV_ABS:
		    //printf("Got position x: %i!\n",data->x);
		    switch (ev[i].code) {
			case ABS_X:
			    data->x = ev[i].value;
			    break;
			case ABS_Y:
			    data->y = ev[i].value;
			    break;
			case ABS_PRESSURE:
			    data->pressure = ev[i].value;
			    if(data->pressure < 0) data->pressure = 0;
			    break;
			case ABS_MISC:
			    if(ev[i].value == 0)
			        data->up = SDL_TRUE;			    
			    break;
			}
		    break;
		case EV_MSC:
		    if(ev[i].code == MSC_SERIAL)
			data->finger = ev[i].value;
		    break;
		case EV_SYN:
		  //printf("Id: %i\n",touch->id); 
		  if(data->up) {
		      SDL_SendFingerDown(touch->id,data->finger,
			  	       SDL_FALSE,data->x,data->y,
				       data->pressure);		    
		  }
		  else if(data->x >= 0 || data->y >= 0)
		    SDL_SendTouchMotion(touch->id,data->finger, 
					SDL_FALSE,data->x,data->y,
					data->pressure);
		  
		    //printf("Synched: %i tx: %i, ty: %i\n",
		    //	   data->finger,data->x,data->y);
		  data->x = -1;
		  data->y = -1;
		  data->pressure = -1;
		  data->finger = 0;
		  data->up = SDL_FALSE;
		    
		  break;		
		}
	    }
	}
    }
#endif
}
Exemplo n.º 20
0
void gl_handle_events () {
	XEvent event;
	while (XPending(_gl_display) > 0) {
		XNextEvent(_gl_display, &event);
#ifdef XDLG
		if (handle_xdlg_event(_gl_display, &event)) continue;
#endif
#ifdef XFIB
		if (x_fib_handle_events (_gl_display, &event)) {
			if (x_fib_status () > 0) {
				char *fn = x_fib_filename ();
				xapi_open (fn);
				free (fn);
			}
		}
#endif
		if (event.xany.window != _gl_win) {
			continue;
		}
#ifdef DND
		if (handle_dnd_event(_gl_display, _gl_win, &event)) continue;
#endif
		switch (event.type) {
			case MapNotify:
				loop_run=1;
				break;
			case UnmapNotify:
				loop_run=0;
				break;

			case ConfigureNotify:
				if (
						(event.xconfigure.width > 1 && event.xconfigure.height > 1)
						&&
						(event.xconfigure.width != _gl_width || event.xconfigure.height != _gl_height)
					 )
				{
					gl_reshape(event.xconfigure.width, event.xconfigure.height);
				}
				break;
			case Expose:
				if (event.xexpose.count != 0) {
					break;
				}
				_gl_reexpose = true;
				break;
			case MotionNotify:
				if (osd_seeking && ui_syncsource() == SYNC_NONE && OSD_mode & OSD_POS) {
					const float sk = calc_slider (event.xmotion.x, event.xmotion.y);
					if (sk >= 0)
						ui_sync_manual (sk);
				}
				break;
			case ButtonPress:
				if (event.xbutton.button == 1 && ui_syncsource() == SYNC_NONE && OSD_mode & OSD_POS) {
					const float sk = calc_slider (event.xbutton.x, event.xbutton.y);
					if (sk >= 0) {
						ui_sync_manual (sk);
						osd_seeking = 1;
						force_redraw = 1;
					}
				}
				break;
			case ButtonRelease:
				if (osd_seeking) {
					osd_seeking = 0;
					force_redraw = 1;
				} else
#ifdef XDLG
				if (event.xbutton.button == 3) {
					if (event.xbutton.x >= 0 && event.xbutton.x < _gl_width
							&& event.xbutton.y >= 0 && event.xbutton.y < _gl_height)
						show_x_dialog(_gl_display, _gl_win,
								event.xbutton.x_root, event.xbutton.y_root
								);
				} else
#endif
				xjglButton(event.xbutton.button);
				break;
			case ReparentNotify:
				break;
			case KeyPress:
				{
				KeySym  sym;
				char    buf[6] = {0,0,0,0,0,0};
				static XComposeStatus stat;
				int n = XLookupString(&event.xkey, buf, sizeof(buf), &sym, &stat);
				if (event.xkey.state & ControlMask && n == 1 && sym == XK_o) {
#ifdef XFIB
					if (!(interaction_override & OVR_LOADFILE)) {
						x_fib_cfg_filter_callback(fib_filter_movie_filename);
						x_fib_show (_gl_display, _gl_win, 0, 0);
					}
#endif
				}
				else if (event.xkey.state & ControlMask && n == 1 && sym == XK_w) {
					if (!(interaction_override & OVR_LOADFILE))
						xapi_close (NULL);
				}
				else if (event.xkey.state & ControlMask && n == 1 && sym == XK_q) {
					if (!(interaction_override&OVR_QUIT_WMG))
						loop_flag = 0;
				}
				else if (n == 1) {
					xjglKeyPress(sym, buf);
				}
				}
				break;
			case ClientMessage:
				if (!strcmp(XGetAtomName(_gl_display, event.xclient.message_type), "WM_PROTOCOLS")) {
					if ((interaction_override&OVR_QUIT_WMG) == 0) loop_flag=0;
				}
				break;
			default:
				break;
		}
	}
	if (_gl_reexpose) {
		_gl_reexpose = false;
		force_redraw = true;
	}

	static int periodic = 10;
	if (--periodic == 0) {
		periodic = 50 * framerate; // we should use 1/delay if delay > 0
		XResetScreenSaver(_gl_display);
		// ..or spawn `xdg-screensaver`
	}
}
Exemplo n.º 21
0
void
X11_PumpEvents(_THIS)
{
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

    /* Update activity every 30 seconds to prevent screensaver */
    if (_this->suspend_screensaver) {
        Uint32 now = SDL_GetTicks();
        if (!data->screensaver_activity ||
            (int) (now - data->screensaver_activity) >= 30000) {
            XResetScreenSaver(data->display);

            #if SDL_USE_LIBDBUS
            SDL_dbus_screensaver_tickle(_this);
            #endif

            data->screensaver_activity = now;
        }
    }   

    /* Keep processing pending events */
    while (X11_Pending(data->display)) {
        X11_DispatchEvent(_this);
    }

    /* FIXME: Only need to do this when there are pending focus changes */
    X11_HandleFocusChanges(_this);

    /*Dont process evtouch events if XInput2 multitouch is supported*/
    if(X11_Xinput2IsMultitouchSupported()) {
        return;
    }

#ifdef SDL_INPUT_LINUXEV
    /* Process Touch events*/
    int i = 0,rd;
    struct input_event ev[64];
    int size = sizeof (struct input_event);

/* !!! FIXME: clean the tabstops out of here. */
    for(i = 0;i < SDL_GetNumTouch();++i) {
	SDL_Touch* touch = SDL_GetTouchIndex(i);
	if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
	EventTouchData* data;
	data = (EventTouchData*)(touch->driverdata);
	if(data == NULL) {
	  printf("No driver data\n");
	  continue;
	}
	if(data->eventStream <= 0) 
	    printf("Error: Couldn't open stream\n");
	rd = read(data->eventStream, ev, size * 64);
	if(rd >= size) {
	    for (i = 0; i < rd / sizeof(struct input_event); i++) {
		switch (ev[i].type) {
		case EV_ABS:
		    switch (ev[i].code) {
			case ABS_X:
			    data->x = ev[i].value;
			    break;
			case ABS_Y:
			    data->y = ev[i].value;
			    break;
			case ABS_PRESSURE:
			    data->pressure = ev[i].value;
			    if(data->pressure < 0) data->pressure = 0;
			    break;
			case ABS_MISC:
			    if(ev[i].value == 0)
			        data->up = SDL_TRUE;			    
			    break;
			}
		    break;
		case EV_MSC:
			if(ev[i].code == MSC_SERIAL)
				data->finger = ev[i].value;
			break;
		case EV_KEY:
			if(ev[i].code == BTN_TOUCH)
			    if(ev[i].value == 0)
			        data->up = SDL_TRUE;
			break;
		case EV_SYN:
		  if(!data->down) {
		      data->down = SDL_TRUE;
		      SDL_SendFingerDown(touch->id,data->finger,
		    		  data->down, data->x, data->y,
		    		  data->pressure);
		  }
		  else if(!data->up)
		    SDL_SendTouchMotion(touch->id,data->finger, 
					SDL_FALSE, data->x,data->y,
					data->pressure);
		  else
		  {
		      data->down = SDL_FALSE;
			  SDL_SendFingerDown(touch->id,data->finger,
					  data->down, data->x,data->y,
					  data->pressure);
			  data->x = -1;
			  data->y = -1;
			  data->pressure = -1;
			  data->finger = 0;
			  data->up = SDL_FALSE;
		  }
		  break;		
		}
	    }
	}
    }
#endif
}
Exemplo n.º 22
0
void COSScreenSaverX11::ResetScreenSaver()
{
  XResetScreenSaver(m_dpy);
}
Exemplo n.º 23
0
void
x_gram_create(Display *dpy,
              x_gram *gram,
              int xalign,
              int yalign,
              int xpos,
              int ypos,
              int xsize,
              int ysize,
              int beepcount)
{
    Window w;
    XSizeHints sizehints;
    XWMHints wmhints;
    XSetWindowAttributes attributes;
    unsigned long all_desktops = 0xFFFFFFFF;

    /*
     * Adjust xpos, ypos based on the alignments xalign, yalign and the sizes:
     */
    if (xalign < 0)
      xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy))
          - xpos - xsize - 2 * border_width;
    else if (xalign == 0)
      xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy))
               - xsize - 2 * border_width) >> 1) + xpos;

    if (yalign<0)
      ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy))
          - ypos - ysize - 2 * border_width;
    else if (yalign == 0)
      ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy))
               - ysize - 2 * border_width) >> 1) + ypos;

    /*
     * Create the window:
     */
    attributes = xattributes;
    attributes.background_pixel = gram->bgcolor;
    
    gram->w = w = XCreateWindow (dpy, DefaultRootWindow (dpy), xpos, ypos,
                                 xsize, ysize, border_width, 0,
                                 CopyFromParent, CopyFromParent,
                                 xattributes_mask, &attributes);
    
    sizehints.x = xpos;
    sizehints.y = ypos;
    sizehints.width = xsize;
    sizehints.height = ysize;
    sizehints.win_gravity = x_calc_gravity(xalign, yalign);
    sizehints.flags = USPosition | USSize | PWinGravity;

    wmhints.input = False;
    wmhints.initial_state = NormalState;
    if (set_transient) {
       wmhints.window_group = group_leader;
       wmhints.flags = InputHint | StateHint | WindowGroupHint;

       x_set_icccm_hints(dpy, w, title_name, icon_name, &sizehints, &wmhints,
                         group_leader);
    } else {
       wmhints.flags = InputHint | StateHint;

       x_set_icccm_hints(dpy, w, title_name, icon_name, &sizehints, &wmhints, 0);
    }
       
    if (net_wm_window_type != None && net_wm_window_type_utility != None)
        XChangeProperty(dpy, w, net_wm_window_type, XA_ATOM, 32, PropModeReplace,
                        (unsigned char *) &net_wm_window_type_utility, 1);
    if (set_all_desktops && net_wm_desktop != None)
        XChangeProperty(dpy, w, net_wm_desktop, XA_CARDINAL, 32, PropModeReplace,
                        (unsigned char *) &all_desktops, 1);

    XSaveContext(dpy, w, desc_context, (XPointer)gram);

    gram->can_die.tv_sec = 0;

    XMapWindow(dpy, w);

    if (beepcount)
        XBell(dpy, 0);

    xerror_happened = 0;
    if (reverse_stack && bottom_gram) {
       XWindowChanges winchanges;
       
       winchanges.sibling = bottom_gram->w;
       winchanges.stack_mode = Below;
       /* Metacity may use border_width even if it's not specified in
        * the value mask, so we must initialize it.  See:
        * http://bugzilla.gnome.org/show_bug.cgi?id=305257 */
       winchanges.border_width = border_width;

       begin_xerror_trap (dpy);
       XReconfigureWMWindow (dpy, w, DefaultScreen (dpy),
                             CWSibling | CWStackMode, &winchanges);
       end_xerror_trap (dpy);
       if (xerror_happened) {
           /* The event didn't go.  Print an error message, and continue.  */
           ERROR ("Error configuring window to the bottom of the stack.\n");
       }
    }
    /* we always need to keep a linked list of windows */
    add_to_bottom(gram);
    if (xerror_happened)
       pull_to_top(gram);

    if (reset_saver)
        XResetScreenSaver(dpy);

    XFlush(dpy);
    /* Because the flushing/syncing/etc with the error trapping can cause
       events to be read into the Xlib queue, we need to go through the queue
       here before exiting so that any pending events get processed.
       */
    x_get_input(dpy);
}
Exemplo n.º 24
0
static void xglx_background_thread(_AL_THREAD *self, void *arg)
{
   ALLEGRO_SYSTEM_XGLX *s = arg;
   XEvent event;
   double last_reset_screensaver_time = 0.0;

   while (!_al_get_thread_should_stop(self)) {
      /* Note:
       * Most older X11 implementations are not thread-safe no matter what, so
       * we simply cannot sit inside a blocking XNextEvent from another thread
       * if another thread also uses X11 functions.
       * 
       * The usual use of XNextEvent is to only call it from the main thread. We
       * could of course do this for A5, just needs some slight adjustments to
       * the events system (polling for an Allegro event would call a function
       * of the system driver).
       * 
       * As an alternative, we can use locking. This however can never fully
       * work, as for example OpenGL implementations also will access X11, in a
       * way we cannot know and cannot control (and we can't require users to
       * only call graphics functions inside a lock).
       * 
       * However, most X11 implementations are somewhat thread safe, and do
       * use locking quite a bit themselves, so locking mostly does work.
       * 
       * (Yet another alternative might be to use a separate X11 display
       * connection for graphics output.)
       *
       */

      _al_mutex_lock(&s->lock);

      while (XEventsQueued(s->x11display, QueuedAfterFlush)) {
         XNextEvent(s->x11display, &event);
         process_x11_event(s, event);
      }

      /* The Xlib manual is particularly useless about the XResetScreenSaver()
       * function.  Nevertheless, this does seem to work to inhibit the native
       * screensaver facility.  Probably it won't do anything for other
       * systems, though.
       */
      if (s->inhibit_screensaver) {
         double now = al_current_time();
         if (now - last_reset_screensaver_time > 10.0) {
            XResetScreenSaver(s->x11display);
            last_reset_screensaver_time = now;
         }
      }

      _al_mutex_unlock(&s->lock);

      /* If no X11 events are there, unlock so other threads can run. We use
       * a select call to wake up when as soon as anything is available on
       * the X11 connection - and just for safety also wake up 10 times
       * a second regardless.
       */
      int x11_fd = ConnectionNumber(s->x11display);
      fd_set fdset;
      FD_ZERO(&fdset);
      FD_SET(x11_fd, &fdset);
      struct timeval small_time = {0, 100000}; /* 10 times a second */
      select(x11_fd + 1, &fdset, NULL, NULL, &small_time);
   }
}
Exemplo n.º 25
0
void XScreensaverBasedPoller::simulateUserActivity()
{
    stopCatchingIdleEvents();
    XResetScreenSaver(QX11Info::display());
    emit resumingFromIdle();
}
Exemplo n.º 26
0
void
cs_screen_reset_screensaver (void)
{
    XResetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
}