Clean up spurious kdesktop_lock X11 error messages

Introduce disabled framework for future ARGB visual support
(cherry picked from commit bf0b8eb3b2)
v3.5.13-sru
Timothy Pearson 11 years ago committed by Slávek Banko
parent 64ed2efaa1
commit 52b8af3d79

@ -172,6 +172,8 @@ extern bool trinity_desktop_lock_use_sak;
extern bool trinity_desktop_lock_hide_active_windows; extern bool trinity_desktop_lock_hide_active_windows;
extern bool trinity_desktop_lock_forced; extern bool trinity_desktop_lock_forced;
extern bool argb_visual;
extern TQXLibWindowList trinity_desktop_lock_hidden_window_list; extern TQXLibWindowList trinity_desktop_lock_hidden_window_list;
bool trinity_desktop_lock_autohide_lockdlg = TRUE; bool trinity_desktop_lock_autohide_lockdlg = TRUE;
@ -238,17 +240,24 @@ LockProcess::LockProcess()
setupSignals(); setupSignals();
setupPipe(); setupPipe();
// Signal that we want to be transparent to the desktop, not to windows behind us...
Atom kde_wm_transparent_to_desktop;
kde_wm_transparent_to_desktop = XInternAtom(qt_xdisplay(), "_KDE_TRANSPARENT_TO_DESKTOP", False);
XChangeProperty(qt_xdisplay(), winId(), kde_wm_transparent_to_desktop, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L);
kapp->installX11EventFilter(this); kapp->installX11EventFilter(this);
mForceContinualLockDisplayTimer = new TQTimer( this ); mForceContinualLockDisplayTimer = new TQTimer( this );
mHackDelayStartupTimer = new TQTimer( this ); mHackDelayStartupTimer = new TQTimer( this );
mEnsureVRootWindowSecurityTimer = new TQTimer( this ); mEnsureVRootWindowSecurityTimer = new TQTimer( this );
// Try to get the root pixmap if (!argb_visual) {
if (!m_rootPixmap) m_rootPixmap = new KRootPixmap(this); // Try to get the root pixmap
connect(m_rootPixmap, TQT_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQT_SLOT(slotPaintBackground(const TQPixmap &))); if (!m_rootPixmap) m_rootPixmap = new KRootPixmap(this);
m_rootPixmap->setCustomPainting(true); connect(m_rootPixmap, TQT_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQT_SLOT(slotPaintBackground(const TQPixmap &)));
m_rootPixmap->start(); m_rootPixmap->setCustomPainting(true);
m_rootPixmap->start();
}
// Get root window attributes // Get root window attributes
XWindowAttributes rootAttr; XWindowAttributes rootAttr;
@ -971,8 +980,26 @@ void LockProcess::createSaverWindow()
attrs.override_redirect = 1; attrs.override_redirect = 1;
hide(); hide();
Window w = XCreateWindow( x11Display(), RootWindow( x11Display(), x11Screen()),
x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs ); if (argb_visual) {
attrs.background_pixel = 0;
attrs.border_pixel = 0;
flags |= CWBackPixel;
flags |= CWBorderPixel;
if (!(flags & CWColormap)) {
XVisualInfo vinfo;
if (!XMatchVisualInfo( x11Display(), x11Screen(), 32, TrueColor, &vinfo )) {
printf("[ERROR] Unable to locate matching X11 Visual; this application will not function correctly!\n\r");
}
else {
visual = vinfo.visual;
attrs.colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
flags |= CWColormap;
}
}
}
Window w = XCreateWindow( x11Display(), RootWindow( x11Display(), x11Screen()), x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs );
create( w ); create( w );
// Some xscreensaver hacks check for this property // Some xscreensaver hacks check for this property
@ -982,10 +1009,13 @@ void LockProcess::createSaverWindow()
(unsigned char *) version, strlen(version)); (unsigned char *) version, strlen(version));
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.event_mask = KeyPressMask | ButtonPressMask | PointerMotionMask | attr.event_mask = KeyPressMask | ButtonPressMask | PointerMotionMask | VisibilityChangeMask | ExposureMask;
VisibilityChangeMask | ExposureMask; XChangeWindowAttributes(qt_xdisplay(), winId(), CWEventMask, &attr);
XChangeWindowAttributes(qt_xdisplay(), winId(),
CWEventMask, &attr); // Signal that we want to be transparent to the desktop, not to windows behind us...
Atom kde_wm_transparent_to_desktop;
kde_wm_transparent_to_desktop = XInternAtom(qt_xdisplay(), "_KDE_TRANSPARENT_TO_DESKTOP", False);
XChangeProperty(qt_xdisplay(), w, kde_wm_transparent_to_desktop, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L);
// erase(); // erase();
@ -1077,7 +1107,12 @@ void LockProcess::desktopResized()
XSync(qt_xdisplay(), False); XSync(qt_xdisplay(), False);
// Black out the background widget to hide ugly resize tiling artifacts // Black out the background widget to hide ugly resize tiling artifacts
setBackgroundColor(black); if (argb_visual) {
setErasePixmap(TQPixmap());
}
else {
setBackgroundColor(black);
}
erase(); erase();
// This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever // This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever
@ -1203,28 +1238,35 @@ void LockProcess::saveVRoot()
// //
void LockProcess::setVRoot(Window win, Window vr) void LockProcess::setVRoot(Window win, Window vr)
{ {
if (gVRoot) if (gVRoot) {
removeVRoot(gVRoot); removeVRoot(gVRoot);
}
unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(qt_xdisplay(), qt_xscreen())); unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(qt_xdisplay(), qt_xscreen()));
unsigned long vroot_data[1] = { vr }; unsigned long vroot_data[1] = { vr };
Window rootReturn, parentReturn, *children; Window rootReturn;
Window parentReturn;
Window *children = NULL;
unsigned int numChildren; unsigned int numChildren;
Window top = win; Window top = win;
while (1) { while (1) {
XQueryTree(qt_xdisplay(), top , &rootReturn, &parentReturn, if (XQueryTree(qt_xdisplay(), top, &rootReturn, &parentReturn, &children, &numChildren) == 0) {
&children, &numChildren); printf("[WARNING] XQueryTree() failed!\n\r"); fflush(stdout);
if (children) break;
}
if (children) {
XFree((char *)children); XFree((char *)children);
}
if (parentReturn == rw) { if (parentReturn == rw) {
break; break;
} else }
else {
top = parentReturn; top = parentReturn;
}
} }
XChangeProperty(qt_xdisplay(), top, gXA_VROOT, XA_WINDOW, 32, XChangeProperty(qt_xdisplay(), top, gXA_VROOT, XA_WINDOW, 32, PropModeReplace, (unsigned char *)vroot_data, 1);
PropModeReplace, (unsigned char *)vroot_data, 1);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1365,11 +1407,16 @@ bool LockProcess::startSaver()
} }
if (((!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced)) && (!trinity_desktop_lock_in_sec_dlg)) && mHackStartupEnabled) { if (((!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced)) && (!trinity_desktop_lock_in_sec_dlg)) && mHackStartupEnabled) {
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
@ -1527,13 +1574,19 @@ void LockProcess::repaintRootWindowIfNeeded()
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
if (!mHackProc.isRunning()) { if (!mHackProc.isRunning()) {
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
} }
else { else {
bitBlt(this, 0, 0, &backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else {
bitBlt(this, 0, 0, &backingPixmap);
}
} }
} }
if (currentDialog == NULL) { if (currentDialog == NULL) {
@ -1554,11 +1607,16 @@ bool LockProcess::startHack()
if (currentDialog || (!mDialogs.isEmpty())) if (currentDialog || (!mDialogs.isEmpty()))
{ {
// no resuming with dialog visible or when not visible // no resuming with dialog visible or when not visible
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
@ -1602,11 +1660,16 @@ bool LockProcess::startHack()
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
// Make sure we have a nice clean display to start with! // Make sure we have a nice clean display to start with!
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
@ -1637,18 +1700,31 @@ bool LockProcess::startHack()
usleep(100); usleep(100);
TQApplication::syncX(); TQApplication::syncX();
if (!trinity_desktop_lock_use_system_modal_dialogs) { if (!trinity_desktop_lock_use_system_modal_dialogs) {
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
} }
if (backingPixmap.isNull()) { if (argb_visual) {
setGeometry(0, 0, mRootWidth, mRootHeight); setErasePixmap(TQPixmap());
erase(); erase();
} }
else bitBlt(this, 0, 0, &backingPixmap); else {
if (backingPixmap.isNull()) {
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else {
bitBlt(this, 0, 0, &backingPixmap);
}
}
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
@ -1686,18 +1762,30 @@ void LockProcess::hackExited(KProcess *)
usleep(100); usleep(100);
TQApplication::syncX(); TQApplication::syncX();
if (!trinity_desktop_lock_use_system_modal_dialogs) { if (!trinity_desktop_lock_use_system_modal_dialogs) {
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
} }
if (backingPixmap.isNull()) { if (argb_visual) {
setGeometry(0, 0, mRootWidth, mRootHeight); setErasePixmap(TQPixmap());
erase(); }
else {
if (backingPixmap.isNull()) {
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else {
bitBlt(this, 0, 0, &backingPixmap);
}
} }
else bitBlt(this, 0, 0, &backingPixmap);
if (!mSuspended) { if (!mSuspended) {
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
@ -1774,11 +1862,16 @@ void LockProcess::resume( bool force )
if( !force && (!mDialogs.isEmpty() || !mVisibility )) { if( !force && (!mDialogs.isEmpty() || !mVisibility )) {
// no resuming with dialog visible or when not visible // no resuming with dialog visible or when not visible
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
if (backingPixmap.isNull()) { if (argb_visual) {
setBackgroundColor(black); setErasePixmap(TQPixmap());
} }
else { else {
setBackgroundPixmap(backingPixmap); if (backingPixmap.isNull()) {
setBackgroundColor(black);
}
else {
setBackgroundPixmap(backingPixmap);
}
} }
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
@ -1966,6 +2059,13 @@ void LockProcess::slotForcePaintBackground()
void LockProcess::slotPaintBackground(const TQPixmap &rpm) void LockProcess::slotPaintBackground(const TQPixmap &rpm)
{ {
if (argb_visual) {
if (mEnsureScreenHiddenTimer) {
mEnsureScreenHiddenTimer->stop();
}
return;
}
if (mEnsureScreenHiddenTimer) { if (mEnsureScreenHiddenTimer) {
mEnsureScreenHiddenTimer->stop(); mEnsureScreenHiddenTimer->stop();
} }

@ -19,6 +19,8 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config.h>
#include "lockprocess.h" #include "lockprocess.h"
#include "main.h" #include "main.h"
#include "kdesktopsettings.h" #include "kdesktopsettings.h"
@ -35,8 +37,19 @@
#include <stdlib.h> #include <stdlib.h>
#include <X11/Xlib.h> #if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300
#include <fixx11h.h> #define COMPOSITE
#endif
#ifdef COMPOSITE
# include <X11/Xlib.h>
# include <X11/extensions/Xrender.h>
# include <fixx11h.h>
# include <dlfcn.h>
#else
# include <X11/Xlib.h>
# include <fixx11h.h>
#endif
#define OPEN_TDMCONFIG_AND_SET_GROUP \ #define OPEN_TDMCONFIG_AND_SET_GROUP \
if( stat( KDE_CONFDIR "/kdm/kdmdistrc" , &st ) == 0) { \ if( stat( KDE_CONFDIR "/kdm/kdmdistrc" , &st ) == 0) { \
@ -64,6 +77,38 @@ bool signalled_blank;
bool signalled_run; bool signalled_run;
bool in_internal_mode = FALSE; bool in_internal_mode = FALSE;
bool argb_visual = FALSE;
static void sigusr1_handler(int)
{
signalled_forcelock = TRUE;
}
static void sigusr2_handler(int)
{
signalled_dontlock = TRUE;
}
static void sigusr3_handler(int)
{
signalled_securedialog = TRUE;
}
static void sigusr4_handler(int)
{
signalled_blank = TRUE;
}
static void sigusr5_handler(int)
{
signalled_run = TRUE;
}
static int trapXErrors(Display *, XErrorEvent *)
{
return 0;
}
bool MyApp::x11EventFilter( XEvent *ev ) bool MyApp::x11EventFilter( XEvent *ev )
{ {
if (ev->type == ButtonPress || ev->type == ButtonRelease || ev->type == MotionNotify) { if (ev->type == ButtonPress || ev->type == ButtonRelease || ev->type == MotionNotify) {
@ -119,6 +164,10 @@ bool MyApp::x11EventFilter( XEvent *ev )
XCreateWindowEvent create_event = ev->xcreatewindow; XCreateWindowEvent create_event = ev->xcreatewindow;
XWindowAttributes childAttr; XWindowAttributes childAttr;
Window childTransient; Window childTransient;
// XGetWindowAttributes may generate BadWindow errors, so make sure they are silently ignored
int (*oldHandler)(Display *, XErrorEvent *);
oldHandler = XSetErrorHandler(trapXErrors);
if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) { if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) {
if ((childAttr.override_redirect) && (childTransient)) { if ((childAttr.override_redirect) && (childTransient)) {
if (!trinity_desktop_lock_hidden_window_list.contains(create_event.window)) { if (!trinity_desktop_lock_hidden_window_list.contains(create_event.window)) {
@ -128,6 +177,7 @@ bool MyApp::x11EventFilter( XEvent *ev )
XFlush(create_event.display); XFlush(create_event.display);
} }
} }
XSetErrorHandler(oldHandler);
} }
else if (ev->type == DestroyNotify) { else if (ev->type == DestroyNotify) {
XDestroyWindowEvent destroy_event = ev->xdestroywindow; XDestroyWindowEvent destroy_event = ev->xdestroywindow;
@ -171,36 +221,6 @@ void restore_hidden_override_redirect_windows() {
} }
} }
static void sigusr1_handler(int)
{
signalled_forcelock = TRUE;
}
static void sigusr2_handler(int)
{
signalled_dontlock = TRUE;
}
static void sigusr3_handler(int)
{
signalled_securedialog = TRUE;
}
static void sigusr4_handler(int)
{
signalled_blank = TRUE;
}
static void sigusr5_handler(int)
{
signalled_run = TRUE;
}
static int trapXErrors(Display *, XErrorEvent *)
{
return 0;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int main( int argc, char **argv ) int main( int argc, char **argv )
@ -287,7 +307,16 @@ int main( int argc, char **argv )
} }
} }
// FIXME
// Composite should be enabled where possible, however using ARGB visuals seems to cause problems
// with XScreenSaver hacks (they do not display).
// #ifdef COMPOSITE
// MyApp app(KApplication::openX11RGBADisplay());
// argb_visual = app.isX11CompositionAvailable();
// #else
MyApp app; MyApp app;
// #endif
kdDebug() << "app " << kdesktop_screen_number << " " << starting_screen << " " << child << " " << child_sockets.count() << " " << parent_connection << endl; kdDebug() << "app " << kdesktop_screen_number << " " << starting_screen << " " << child << " " << child_sockets.count() << " " << parent_connection << endl;
app.disableSessionManagement(); app.disableSessionManagement();
KGlobal::locale()->insertCatalogue("libdmctl"); KGlobal::locale()->insertCatalogue("libdmctl");

@ -28,6 +28,7 @@ class MyApp : public KApplication {
Q_OBJECT Q_OBJECT
public: public:
MyApp() : KApplication(), lastTick( 0 ) {} MyApp() : KApplication(), lastTick( 0 ) {}
MyApp(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0, bool allowStyles=true) : KApplication(display, visual, colormap, allowStyles), lastTick( 0 ) {}
protected: protected:
bool x11EventFilter( XEvent * ); bool x11EventFilter( XEvent * );
signals: signals:

Loading…
Cancel
Save