aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Lind <jussi.lind@nokia.com>2010-12-08 13:54:55 +0200
committerDominik Kapusta <dominik.kapusta@teleca.com>2010-12-14 10:59:29 +0100
commit90cbcc8a618c63fd3a612d1a59002d9540d4ec8a (patch)
treebeaad23f114a9fb2d4df34b5433536f1540f0a6e
parenteef986ee81d03fbc9cbe262a05ecf8bef8d66842 (diff)
Fixes: NB#203650 - displayEntered() not emitted when switching between two windows in the same app
RevBy: Antti Kervinen Details: Listen only to synthetic visibility events if mcompositor is running.
-rw-r--r--src/corelib/core/mapplication.cpp37
-rw-r--r--src/corelib/core/mcomponentdata.cpp62
-rw-r--r--src/corelib/core/mcomponentdata.h3
3 files changed, 81 insertions, 21 deletions
diff --git a/src/corelib/core/mapplication.cpp b/src/corelib/core/mapplication.cpp
index eb35c5f9..2b5cba4b 100644
--- a/src/corelib/core/mapplication.cpp
+++ b/src/corelib/core/mapplication.cpp
@@ -405,36 +405,35 @@ bool MApplication::x11EventFilter(XEvent *event)
void MApplicationPrivate::handleXVisibilityEvent(XVisibilityEvent *xevent)
{
- switch (xevent->state) {
- case VisibilityFullyObscured:
- // Listen only to synthetic events by compositor
- if (xevent->send_event)
- {
- MWindow * window = MApplicationPrivate::windowForId(xevent->window);
+ static const bool wmRunning = MComponentData::isMeeGoWindowManagerRunning();
+
+ // Listen only to synthetic events if window
+ // manager is running.
+ if (xevent->send_event || !wmRunning) {
+
+ MWindow * window = MApplicationPrivate::windowForId(xevent->window);
+
+ switch (xevent->state) {
+ case VisibilityFullyObscured:
if (window) {
window->d_ptr->fullyObscured = true;
if (!window->d_ptr->visibleInSwitcher) {
setWindowVisibility(window, false);
}
}
- }
- break;
-
- // Always listen to these events, because if compositor is not running
- // we are not getting any synthetic events at all and the window would never get
- // the display entered signal.
- case VisibilityUnobscured:
- case VisibilityPartiallyObscured:
- {
- MWindow * window = MApplicationPrivate::windowForId(xevent->window);
+ break;
+
+ case VisibilityUnobscured:
+ case VisibilityPartiallyObscured:
if (window) {
window->d_ptr->fullyObscured = false;
setWindowVisibility(window, true);
}
+ break;
+
+ default:
+ break;
}
- break;
- default:
- break;
}
}
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp
index 3ed19820..4a174c17 100644
--- a/src/corelib/core/mcomponentdata.cpp
+++ b/src/corelib/core/mcomponentdata.cpp
@@ -56,10 +56,12 @@
#include "mgraphicssystemhelper.h"
#ifdef Q_WS_X11
-#ifdef HAVE_XDAMAGE
#include <QX11Info>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#ifdef HAVE_XDAMAGE
#include <X11/extensions/Xfixes.h>
-#endif // HAVE_XFIXES
+#endif // HAVE_XDAMAGE
#endif // Q_WS_X11
namespace
@@ -1172,6 +1174,62 @@ bool MComponentData::isOrientationForced()
}
#ifdef Q_WS_X11
+static int handleXError(Display *, XErrorEvent *)
+{
+ return 0;
+}
+#endif // Q_WS_X11
+
+bool MComponentData::isMeeGoWindowManagerRunning()
+{
+ bool retValue = false;
+
+#ifdef Q_WS_X11
+
+ Display *dpy = QX11Info::display();
+ Window rootw = RootWindow(dpy, XDefaultScreen(dpy));
+ Atom wmSupportAtom = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
+ Atom type;
+ int format;
+ unsigned long numItems;
+ unsigned long bytesAfter;
+ unsigned char *data = 0;
+
+ if (XGetWindowProperty(dpy, rootw, wmSupportAtom, 0, 1, False, XA_WINDOW,
+ &type, &format, &numItems, &bytesAfter, &data) == Success) {
+ if (data) {
+
+ Window wid = *(reinterpret_cast<Window *>(data));
+ XFree(data);
+ data = 0;
+
+ Atom wmNameAtom = XInternAtom(dpy, "WM_NAME", False);
+
+ // Set error handler because window wid we got might not exist and
+ // the following name query would fail.
+ int (*previousHandler)(Display *, XErrorEvent *) = XSetErrorHandler(handleXError);
+
+ if (XGetWindowProperty(dpy, wid, wmNameAtom, 0, 16, False, XA_STRING,
+ &type, &format, &numItems, &bytesAfter, &data) == Success) {
+ if (data) {
+ if (strcmp(reinterpret_cast<const char *>(data), "MCompositor") == 0) {
+ retValue = true;
+ }
+
+ XFree(data);
+ data = 0;
+ }
+ }
+
+ XSetErrorHandler(previousHandler);
+ }
+ }
+#endif // Q_WS_X11
+
+ return retValue;
+}
+
+#ifdef Q_WS_X11
QStack<MComponentData::ChainData> MComponentDataPrivate::chainData;
void MComponentData::pushChainData(const ChainData &newChainData)
diff --git a/src/corelib/core/mcomponentdata.h b/src/corelib/core/mcomponentdata.h
index 8441698c..589470d8 100644
--- a/src/corelib/core/mcomponentdata.h
+++ b/src/corelib/core/mcomponentdata.h
@@ -186,6 +186,9 @@ public:
//! Sets whether MComponentData should automatically load m input context
static void setLoadMInputContext(bool enable);
+ //! Returns whether MCompositor is present
+ static bool isMeeGoWindowManagerRunning();
+
//! \internal
static M::OrientationAngle forcedOrientationAngle();