summaryrefslogtreecommitdiff
path: root/tests/test-get-transients
diff options
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-08-25 00:34:06 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-08-25 00:34:06 +0800
commitaf27a66a949aebe16a5ee1c6a7ac662a3bc6666c (patch)
tree3d48348cce1d45e348c2ec19015d3e7868698a27 /tests/test-get-transients
parent460c7b8df9310771a77bc16a199d1704d30ee691 (diff)
Added minimize window handler test and split out X11Window into its own file
(bzr r1410.5.12)
Diffstat (limited to 'tests/test-get-transients')
-rw-r--r--tests/test-get-transients/CMakeLists.txt4
-rw-r--r--tests/test-get-transients/test-get-transients.cpp118
2 files changed, 4 insertions, 118 deletions
diff --git a/tests/test-get-transients/CMakeLists.txt b/tests/test-get-transients/CMakeLists.txt
index 1e012c5d7..cd53f0c33 100644
--- a/tests/test-get-transients/CMakeLists.txt
+++ b/tests/test-get-transients/CMakeLists.txt
@@ -6,6 +6,7 @@ pkg_check_modules (COMPIZ_TEST_GET_TRANSIENTS REQUIRED x11 xext)
if (COMPIZ_TEST_GET_TRANSIENTS_FOUND)
include_directories (${COMPIZ_TEST_GET_TRANSIENTS_INCLUDE_DIRS}
+ ..
../../plugins/unityshell/src)
link_directories (${COMPIZ_TEST_GET_TRANSIENTS_LINK_DIRS})
@@ -13,7 +14,8 @@ if (COMPIZ_TEST_GET_TRANSIENTS_FOUND)
add_executable (test-get-transients
test-get-transients.cpp
../../plugins/unityshell/src/transientfor.cpp
- ../../plugins/unityshell/src/inputremover.cpp)
+ ../../plugins/unityshell/src/inputremover.cpp
+ ../x11-window.cpp)
target_link_libraries (test-get-transients
${COMPIZ_TEST_GET_TRANSIENTS_LIBRARIES})
diff --git a/tests/test-get-transients/test-get-transients.cpp b/tests/test-get-transients/test-get-transients.cpp
index 1bbacc1cd..cfac40ca2 100644
--- a/tests/test-get-transients/test-get-transients.cpp
+++ b/tests/test-get-transients/test-get-transients.cpp
@@ -22,131 +22,15 @@
#define _GNU_SOURCE
#endif
-#include <transientfor.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <sstream>
-#include <poll.h>
#include <cstring>
-class X11Window
-{
- public:
-
- X11Window (Display *, Window id = 0);
- ~X11Window ();
-
- void makeTransientFor (X11Window *w);
- void setClientLeader (X11Window *w);
- void printTransients ();
-
- std::vector<unsigned int> transients ();
-
- unsigned int id () { return mXid; }
-
- private:
-
- Window mXid;
- Display *mDpy;
- bool mCreated;
-};
-
-X11Window::X11Window (Display *dpy, Window id)
-{
- if (id == 0)
- {
- XSetWindowAttributes attrib;
- XEvent e;
-
- attrib.background_pixel = 0x0;
- attrib.backing_pixel = 0x0;
-
- id = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0, 100, 100, 0,
- DefaultDepth (dpy, DefaultScreen (dpy)), InputOutput,
- DefaultVisual (dpy, DefaultScreen (dpy)), CWBackingPixel | CWBackPixel, &attrib);
-
- XSelectInput (dpy, id, ExposureMask | StructureNotifyMask);
- XMapRaised (dpy, id);
-
- while (1)
- {
- XNextEvent (dpy, &e);
- bool exposed = false;
-
- switch (e.type)
- {
- case Expose:
- if (e.xexpose.window == id)
- exposed = true;
- break;
- default:
- break;
- }
-
- if (exposed)
- break;
- }
-
- XClearWindow (dpy, id);
-
- mCreated = true;
- }
- else
- mCreated = false;
-
- mXid = id;
- mDpy = dpy;
-}
-
-X11Window::~X11Window ()
-{
- if (mCreated)
- XDestroyWindow (mDpy, mXid);
-}
-
-void
-X11Window::makeTransientFor (X11Window *w)
-{
- XSetTransientForHint (mDpy, mXid, w->id ());
- XSync (mDpy, false);
-}
-
-void
-X11Window::setClientLeader (X11Window *w)
-{
- Atom wmClientLeader = XInternAtom (mDpy, "WM_CLIENT_LEADER", 0);
- Atom netWmWindowType = XInternAtom (mDpy, "_NET_WM_WINDOW_TYPE", 0);
- Atom netWmWindowTypeDialog = XInternAtom (mDpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
-
- Window cl = w->id ();
-
- XChangeProperty (mDpy, mXid, wmClientLeader, XA_WINDOW, 32,
- PropModeReplace, (unsigned char *) &cl, 1);
- XChangeProperty (mDpy, mXid, netWmWindowType, XA_ATOM, 32,
- PropModeAppend, (const unsigned char *) &netWmWindowTypeDialog, 1);
-
- XSync (mDpy, false);
-}
-
-std::vector<unsigned int>
-X11Window::transients ()
-{
- compiz::X11TransientForReader *reader = new compiz::X11TransientForReader (mDpy, mXid);
- std::vector<unsigned int> transients = reader->getTransients ();
-
- delete reader;
- return transients;
-}
-
-void
-X11Window::printTransients ()
-{
- for (unsigned int &w : transients ())
- printf ("window id 0x%x\n", w);
-}
+#include <x11-window.h>
void usage ()
{