CXWindowsScreenSaver.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CXWINDOWSSCREENSAVER_H
00016 #define CXWINDOWSSCREENSAVER_H
00017 
00018 #include "IScreenSaver.h"
00019 #include "stdmap.h"
00020 #if X_DISPLAY_MISSING
00021 #   error X11 is required to build synergy
00022 #else
00023 #   include <X11/Xlib.h>
00024 #endif
00025 
00026 class CEvent;
00027 class CEventQueueTimer;
00028 
00030 class CXWindowsScreenSaver : public IScreenSaver {
00031 public:
00032     CXWindowsScreenSaver(Display*, Window, void* eventTarget);
00033     virtual ~CXWindowsScreenSaver();
00034 
00036 
00037 
00039 
00043     bool                handleXEvent(const XEvent*);
00044 
00046 
00050     void                destroy();
00051 
00053 
00054     // IScreenSaver overrides
00055     virtual void        enable();
00056     virtual void        disable();
00057     virtual void        activate();
00058     virtual void        deactivate();
00059     virtual bool        isActive() const;
00060 
00061 private:
00062     // find and set the running xscreensaver's window.  returns true iff
00063     // found.
00064     bool                findXScreenSaver();
00065 
00066     // set the xscreensaver's window, updating the activation state flag
00067     void                setXScreenSaver(Window);
00068 
00069     // returns true if the window appears to be the xscreensaver window
00070     bool                isXScreenSaver(Window) const;
00071 
00072     // set xscreensaver's activation state flag.  sends notification
00073     // if the state has changed.
00074     void                setXScreenSaverActive(bool activated);
00075 
00076     // send a command to xscreensaver
00077     void                sendXScreenSaverCommand(Atom, long = 0, long = 0);
00078 
00079     // watch all windows that could potentially be the xscreensaver for
00080     // the events that will confirm it.
00081     void                watchForXScreenSaver();
00082 
00083     // stop watching all watched windows
00084     void                clearWatchForXScreenSaver();
00085 
00086     // add window to the watch list
00087     void                addWatchXScreenSaver(Window window);
00088 
00089     // install/uninstall the job used to suppress the screensaver
00090     void                updateDisableTimer();
00091 
00092     // called periodically to prevent the screen saver from starting
00093     void                handleDisableTimer(const CEvent&, void*);
00094 
00095     // force DPMS to activate or deactivate
00096     void                activateDPMS(bool activate);
00097 
00098     // enable/disable DPMS screen saver
00099     void                enableDPMS(bool);
00100 
00101     // check if DPMS is enabled
00102     bool                isDPMSEnabled() const;
00103 
00104     // check if DPMS is activate
00105     bool                isDPMSActivated() const;
00106 
00107 private:
00108     typedef std::map<Window, long> CWatchList;
00109 
00110     // the X display
00111     Display*            m_display;
00112 
00113     // window to receive xscreensaver repsonses
00114     Window              m_xscreensaverSink;
00115 
00116     // the target for the events we generate
00117     void*               m_eventTarget;
00118 
00119     // xscreensaver's window
00120     Window              m_xscreensaver;
00121 
00122     // xscreensaver activation state
00123     bool                m_xscreensaverActive;
00124 
00125     // old event mask on root window
00126     long                m_rootEventMask;
00127 
00128     // potential xscreensaver windows being watched
00129     CWatchList          m_watchWindows;
00130 
00131     // atoms used to communicate with xscreensaver's window
00132     Atom                m_atomScreenSaver;
00133     Atom                m_atomScreenSaverVersion;
00134     Atom                m_atomScreenSaverActivate;
00135     Atom                m_atomScreenSaverDeactivate;
00136 
00137     // built-in screen saver settings
00138     int                 m_timeout;
00139     int                 m_interval;
00140     int                 m_preferBlanking;
00141     int                 m_allowExposures;
00142 
00143     // DPMS screen saver settings
00144     bool                m_dpms;
00145     bool                m_dpmsEnabled;
00146 
00147     // true iff the client wants the screen saver suppressed
00148     bool                m_disabled;
00149 
00150     // true iff we're ignoring m_disabled.  this is true, for example,
00151     // when the client has called activate() and so presumably wants
00152     // to activate the screen saver even if disabled.
00153     bool                m_suppressDisable;
00154 
00155     // the disable timer (NULL if not installed)
00156     CEventQueueTimer*   m_disableTimer;
00157 
00158     // fake mouse motion position for suppressing the screen saver.
00159     // xscreensaver since 2.21 requires the mouse to move more than 10
00160     // pixels to be considered significant.
00161     SInt32              m_disablePos;
00162 };
00163 
00164 #endif

Generated on Fri Nov 6 00:18:46 2009 for synergy-plus by  doxygen 1.4.7