2002-08-02 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
#ifndef CXWINDOWSSCREENSAVER_H
|
|
|
|
#define CXWINDOWSSCREENSAVER_H
|
|
|
|
|
|
|
|
#include "IScreenSaver.h"
|
2002-06-23 19:43:40 +04:00
|
|
|
#include "stdmap.h"
|
2002-06-22 23:20:21 +04:00
|
|
|
#if defined(X_DISPLAY_MISSING)
|
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
class IJob;
|
|
|
|
class CXWindowsScreen;
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! X11 screen saver implementation
|
2002-06-22 23:20:21 +04:00
|
|
|
class CXWindowsScreenSaver : public IScreenSaver {
|
|
|
|
public:
|
|
|
|
// note -- the caller must ensure that Display* passed to c'tor isn't
|
|
|
|
// being used in another call to Xlib when calling any method on this
|
2002-06-26 16:44:52 +04:00
|
|
|
// object (including during the c'tor and d'tor).
|
2002-06-23 19:43:40 +04:00
|
|
|
CXWindowsScreenSaver(CXWindowsScreen*, Display*);
|
2002-06-22 23:20:21 +04:00
|
|
|
virtual ~CXWindowsScreenSaver();
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! Event filtering
|
|
|
|
/*!
|
|
|
|
Called for each event before event translation and dispatch. Return
|
|
|
|
true to skip translation and dispatch. Subclasses should call the
|
|
|
|
superclass's version first and return true if it returns true.
|
|
|
|
*/
|
2002-07-13 00:41:23 +04:00
|
|
|
bool onPreDispatch(const XEvent*);
|
2002-06-22 23:20:21 +04:00
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! Set notify target
|
|
|
|
/*!
|
|
|
|
Tells this object to send a ClientMessage to the given window
|
|
|
|
when the screen saver activates or deactivates. Only one window
|
|
|
|
can be notified at a time. The message type is the "SCREENSAVER"
|
|
|
|
atom, the format is 32, and the data.l[0] member is non-zero
|
|
|
|
if activated, zero if deactivated. Pass None to disable
|
|
|
|
notification.
|
|
|
|
*/
|
2002-06-22 23:20:21 +04:00
|
|
|
void setNotify(Window);
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//@}
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
// IScreenSaver overrides
|
|
|
|
virtual void enable();
|
|
|
|
virtual void disable();
|
|
|
|
virtual void activate();
|
|
|
|
virtual void deactivate();
|
|
|
|
virtual bool isActive() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// send a notification
|
|
|
|
void sendNotify(bool activated);
|
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
// find and set the running xscreensaver's window. returns true iff
|
|
|
|
// found.
|
|
|
|
bool findXScreenSaver();
|
|
|
|
|
|
|
|
// set the xscreensaver's window, updating the activation state flag
|
|
|
|
void setXScreenSaver(Window);
|
|
|
|
|
|
|
|
// returns true if the window appears to be the xscreensaver window
|
|
|
|
bool isXScreenSaver(Window) const;
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
// set xscreensaver's activation state flag. sends notification
|
|
|
|
// if the state has changed.
|
2002-06-23 19:43:40 +04:00
|
|
|
void setXScreenSaverActive(bool activated);
|
2002-06-22 23:20:21 +04:00
|
|
|
|
|
|
|
// send a command to xscreensaver
|
2002-06-23 00:29:59 +04:00
|
|
|
void sendXScreenSaverCommand(Atom, long = 0, long = 0);
|
2002-06-22 23:20:21 +04:00
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
// watch all windows that could potentially be the xscreensaver for
|
|
|
|
// the events that will confirm it.
|
|
|
|
void watchForXScreenSaver();
|
|
|
|
|
|
|
|
// stop watching all watched windows
|
|
|
|
void clearWatchForXScreenSaver();
|
|
|
|
|
|
|
|
// add window to the watch list
|
|
|
|
void addWatchXScreenSaver(Window window);
|
|
|
|
|
2003-01-11 18:16:41 +03:00
|
|
|
// install/uninstall the job used to suppress the screensaver
|
|
|
|
void updateDisableJob();
|
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
// called periodically to prevent the screen saver from starting
|
|
|
|
void disableCallback(void*);
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
private:
|
2002-06-23 19:43:40 +04:00
|
|
|
typedef std::map<Window, long> CWatchList;
|
|
|
|
|
|
|
|
// the event loop object
|
|
|
|
CXWindowsScreen* m_screen;
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
// the X display
|
|
|
|
Display* m_display;
|
|
|
|
|
|
|
|
// old event mask on root window
|
|
|
|
long m_rootEventMask;
|
|
|
|
|
|
|
|
// window to notify on screen saver activation/deactivation
|
|
|
|
Window m_notify;
|
|
|
|
|
|
|
|
// xscreensaver's window
|
|
|
|
Window m_xscreensaver;
|
|
|
|
|
|
|
|
// xscreensaver activation state
|
|
|
|
bool m_xscreensaverActive;
|
|
|
|
|
2002-06-23 00:29:59 +04:00
|
|
|
// dummy window to receive xscreensaver repsonses
|
|
|
|
Window m_xscreensaverSink;
|
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
// potential xscreensaver windows being watched
|
|
|
|
CWatchList m_watchWindows;
|
|
|
|
|
2002-06-22 23:20:21 +04:00
|
|
|
// atoms used to communicate with xscreensaver's window
|
|
|
|
Atom m_atomScreenSaver;
|
|
|
|
Atom m_atomScreenSaverVersion;
|
|
|
|
Atom m_atomScreenSaverActivate;
|
|
|
|
Atom m_atomScreenSaverDeactivate;
|
2002-11-05 22:23:05 +03:00
|
|
|
Atom m_atomSynergyScreenSaver;
|
2002-06-22 23:20:21 +04:00
|
|
|
|
|
|
|
// built-in screen saver settings
|
|
|
|
int m_timeout;
|
|
|
|
int m_interval;
|
|
|
|
int m_preferBlanking;
|
|
|
|
int m_allowExposures;
|
2002-06-23 19:43:40 +04:00
|
|
|
|
2003-01-11 18:16:41 +03:00
|
|
|
// true iff the client wants the screen saver suppressed
|
2002-06-24 01:48:33 +04:00
|
|
|
bool m_disabled;
|
|
|
|
|
2003-01-11 18:16:41 +03:00
|
|
|
// true iff we're ignoring m_disabled. this is true, for example,
|
|
|
|
// when the client has called activate() and so presumably wants
|
|
|
|
// to activate the screen saver even if disabled.
|
|
|
|
bool m_suppressDisable;
|
|
|
|
|
|
|
|
// true iff the disabled job timer is installed
|
|
|
|
bool m_disableJobInstalled;
|
|
|
|
|
2002-06-23 19:43:40 +04:00
|
|
|
// the job used to invoke disableCallback
|
|
|
|
IJob* m_disableJob;
|
2002-06-22 23:20:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|