fixes to get xscreensaver integration working.
This commit is contained in:
parent
95a1ce8798
commit
4d113aa235
|
@ -292,7 +292,9 @@ CXWindowsScreen::processEvent(XEvent* xevent)
|
||||||
// looks like one of the windows that requested a clipboard
|
// looks like one of the windows that requested a clipboard
|
||||||
// transfer has gone bye-bye.
|
// transfer has gone bye-bye.
|
||||||
destroyClipboardRequest(xevent->xdestroywindow.window);
|
destroyClipboardRequest(xevent->xdestroywindow.window);
|
||||||
return true;
|
|
||||||
|
// we don't know if the event was handled or not so continue
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let screen saver have a go
|
// let screen saver have a go
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CXWindowsScreenSaver.h"
|
#include "CXWindowsScreenSaver.h"
|
||||||
#include "CXWindowsUtil.h"
|
#include "CXWindowsUtil.h"
|
||||||
|
#include "CLog.h"
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -21,6 +22,21 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(Display* display) :
|
||||||
m_atomScreenSaverDeactivate = XInternAtom(m_display,
|
m_atomScreenSaverDeactivate = XInternAtom(m_display,
|
||||||
"DEACTIVATE", False);
|
"DEACTIVATE", False);
|
||||||
|
|
||||||
|
// create dummy window to receive xscreensaver responses. earlier
|
||||||
|
// versions of xscreensaver will die if we pass None as the window.
|
||||||
|
XSetWindowAttributes attr;
|
||||||
|
attr.event_mask = 0;//PropertyChangeMask;
|
||||||
|
attr.do_not_propagate_mask = 0;
|
||||||
|
attr.override_redirect = True;
|
||||||
|
m_xscreensaverSink = XCreateWindow(m_display,
|
||||||
|
DefaultRootWindow(m_display),
|
||||||
|
0, 0, 1, 1, 0, 0,
|
||||||
|
InputOnly, CopyFromParent,
|
||||||
|
CWDontPropagate | CWEventMask |
|
||||||
|
CWOverrideRedirect,
|
||||||
|
&attr);
|
||||||
|
log((CLOG_DEBUG "xscreensaver sink window is 0x%08x", m_xscreensaverSink));
|
||||||
|
|
||||||
// watch top-level windows for changes
|
// watch top-level windows for changes
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
@ -31,6 +47,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(Display* display) :
|
||||||
m_rootEventMask = attr.your_event_mask;
|
m_rootEventMask = attr.your_event_mask;
|
||||||
XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask);
|
XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
log((CLOG_DEBUG "didn't set root event mask"));
|
||||||
m_rootEventMask = 0;
|
m_rootEventMask = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +76,7 @@ CXWindowsScreenSaver::processEvent(XEvent* xevent)
|
||||||
if (xevent->xdestroywindow.window == m_xscreensaver) {
|
if (xevent->xdestroywindow.window == m_xscreensaver) {
|
||||||
// xscreensaver is gone
|
// xscreensaver is gone
|
||||||
setXScreenSaver(false);
|
setXScreenSaver(false);
|
||||||
|
log((CLOG_DEBUG "xscreensaver died"));
|
||||||
m_xscreensaver = None;
|
m_xscreensaver = None;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -188,6 +206,7 @@ void
|
||||||
CXWindowsScreenSaver::setXScreenSaver(bool activated)
|
CXWindowsScreenSaver::setXScreenSaver(bool activated)
|
||||||
{
|
{
|
||||||
if (m_xscreensaverActive != activated) {
|
if (m_xscreensaverActive != activated) {
|
||||||
|
log((CLOG_DEBUG "xscreensaver %s", activated ? "activated" : "deactivated"));
|
||||||
m_xscreensaverActive = activated;
|
m_xscreensaverActive = activated;
|
||||||
sendNotify(activated);
|
sendNotify(activated);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +234,7 @@ CXWindowsScreenSaver::updateXScreenSaver()
|
||||||
&data, &type, NULL, False) &&
|
&data, &type, NULL, False) &&
|
||||||
type == XA_STRING) {
|
type == XA_STRING) {
|
||||||
m_xscreensaver = cw[i];
|
m_xscreensaver = cw[i];
|
||||||
|
log((CLOG_DEBUG "found xscreensaver: 0x%08x", m_xscreensaver));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,13 +255,12 @@ CXWindowsScreenSaver::updateXScreenSaver()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsScreenSaver::sendXScreenSaverCommand(
|
CXWindowsScreenSaver::sendXScreenSaverCommand(Atom cmd, long arg1, long arg2)
|
||||||
Atom cmd, long arg1, long arg2) const
|
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
event.xclient.type = ClientMessage;
|
event.xclient.type = ClientMessage;
|
||||||
event.xclient.display = m_display;
|
event.xclient.display = m_display;
|
||||||
event.xclient.window = None;
|
event.xclient.window = m_xscreensaverSink;
|
||||||
event.xclient.message_type = m_atomScreenSaver;
|
event.xclient.message_type = m_atomScreenSaver;
|
||||||
event.xclient.format = 32;
|
event.xclient.format = 32;
|
||||||
event.xclient.data.l[0] = static_cast<long>(cmd);
|
event.xclient.data.l[0] = static_cast<long>(cmd);
|
||||||
|
@ -250,6 +269,11 @@ CXWindowsScreenSaver::sendXScreenSaverCommand(
|
||||||
event.xclient.data.l[3] = 0;
|
event.xclient.data.l[3] = 0;
|
||||||
event.xclient.data.l[4] = 0;
|
event.xclient.data.l[4] = 0;
|
||||||
|
|
||||||
CXWindowsUtil::CErrorLock lock(m_display);
|
log((CLOG_DEBUG "send xscreensaver command: %d %d %d", (long)cmd, arg1, arg2));
|
||||||
|
bool error = false;
|
||||||
|
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
||||||
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
||||||
|
if (error) {
|
||||||
|
updateXScreenSaver();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
void updateXScreenSaver();
|
void updateXScreenSaver();
|
||||||
|
|
||||||
// send a command to xscreensaver
|
// send a command to xscreensaver
|
||||||
void sendXScreenSaverCommand(Atom, long = 0, long = 0) const;
|
void sendXScreenSaverCommand(Atom, long = 0, long = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the X display
|
// the X display
|
||||||
|
@ -64,6 +64,9 @@ private:
|
||||||
// xscreensaver activation state
|
// xscreensaver activation state
|
||||||
bool m_xscreensaverActive;
|
bool m_xscreensaverActive;
|
||||||
|
|
||||||
|
// dummy window to receive xscreensaver repsonses
|
||||||
|
Window m_xscreensaverSink;
|
||||||
|
|
||||||
// atoms used to communicate with xscreensaver's window
|
// atoms used to communicate with xscreensaver's window
|
||||||
Atom m_atomScreenSaver;
|
Atom m_atomScreenSaver;
|
||||||
Atom m_atomScreenSaverVersion;
|
Atom m_atomScreenSaverVersion;
|
||||||
|
|
Loading…
Reference in New Issue