aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Kapusta <dominik.kapusta@teleca.com>2010-12-23 08:48:38 +0100
committerDominik Kapusta <dominik.kapusta@teleca.com>2010-12-23 08:48:38 +0100
commit5b68e71de0e33b7d823728b378fdc6b3a2987482 (patch)
treeead60313cd952ebadb736a3081a1d0128ec24774
parent45ada02cc589f7f511e181d2868e58805f35030d (diff)
Revert "Revert "Fixes: NB#203650 - displayEntered() not emitted when switching between two windows in the same app""
This reverts commit 2d75c098be62333a6db3937c49b522e6dabe4bbe.
-rw-r--r--src/corelib/core/mapplication.cpp53
-rw-r--r--src/corelib/core/mcomponentdata.cpp55
2 files changed, 78 insertions, 30 deletions
diff --git a/src/corelib/core/mapplication.cpp b/src/corelib/core/mapplication.cpp
index 93787c83..6785d24b 100644
--- a/src/corelib/core/mapplication.cpp
+++ b/src/corelib/core/mapplication.cpp
@@ -507,36 +507,33 @@ 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);
- 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);
- if (window) {
- window->d_ptr->fullyObscured = false;
- setWindowVisibility(window, true);
+ static const bool wmRunning = MComponentData::isMeeGoWindowManagerRunning();
+
+ // Listen only to synthetic events if meego window
+ // manager is running.
+ if (xevent->send_event || !wmRunning) {
+
+ MWindow * window = MApplicationPrivate::windowForId(xevent->window);
+
+ if (!window) return;
+
+ switch (xevent->state) {
+ case VisibilityFullyObscured:
+ window->d_ptr->fullyObscured = true;
+ if (!window->d_ptr->visibleInSwitcher) {
+ setWindowVisibility(window, false);
}
+ break;
+
+ case VisibilityUnobscured:
+ case VisibilityPartiallyObscured:
+ 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 a3588ce9..abea65e5 100644
--- a/src/corelib/core/mcomponentdata.cpp
+++ b/src/corelib/core/mcomponentdata.cpp
@@ -57,6 +57,7 @@
#ifdef Q_WS_X11
#include <QX11Info>
+#include <X11/Xatom.h>
#ifdef HAVE_XDAMAGE
#include <X11/extensions/Xfixes.h>
#endif // HAVE_XFIXES
@@ -1171,10 +1172,60 @@ bool MComponentData::isOrientationForced()
return gMComponentDataPrivate->isOrientationForced;
}
+#ifdef Q_WS_X11
+static int handleXError(Display *, XErrorEvent *)
+{
+ return 0;
+}
+#endif // Q_WS_X11
+
bool MComponentData::isMeeGoWindowManagerRunning()
{
- qWarning("MComponentData::isMeeGoWindowManagerRunning() - not implemented yet");
- return false;
+ 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