summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-14 04:05:02 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-14 04:05:02 +0100
commitfcae6aa94aee2b2fc5f84f19fb2e8ab21097338f (patch)
treec61036bce731a8d7dea8194268a789784632536d /unity-shared
parentd06e1e6358b604d24f622cab680261c07f115b05 (diff)
WindowManager: add ShowActionMenu and UnGrabMousePointer
ShowActionMenu asks compiz to show the toolkit action menu for windows while UnGrabMousePointer is a workaround we need to open menus with nux. The code was put in two different places, better to just have one. (bzr r3656.1.2)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/PluginAdapter.cpp5
-rw-r--r--unity-shared/PluginAdapter.h1
-rw-r--r--unity-shared/StandaloneWindowManager.h2
-rw-r--r--unity-shared/WindowManager.h2
-rw-r--r--unity-shared/XWindowManager.cpp51
-rw-r--r--unity-shared/XWindowManager.h1
6 files changed, 38 insertions, 24 deletions
diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp
index ef76a4644..67177d7c9 100644
--- a/unity-shared/PluginAdapter.cpp
+++ b/unity-shared/PluginAdapter.cpp
@@ -698,6 +698,11 @@ void PluginAdapter::RestoreAt(Window window_id, int x, int y)
}
}
+void PluginAdapter::ShowActionMenu(Time timestamp, Window window_id, unsigned button, nux::Point const& p)
+{
+ m_Screen->toolkitAction(Atoms::toolkitActionWindowMenu, timestamp, window_id, button, p.x, p.y);
+}
+
void PluginAdapter::Minimize(Window window_id)
{
CompWindow* window = m_Screen->findWindow(window_id);
diff --git a/unity-shared/PluginAdapter.h b/unity-shared/PluginAdapter.h
index 2ae68d0d1..eef6f7109 100644
--- a/unity-shared/PluginAdapter.h
+++ b/unity-shared/PluginAdapter.h
@@ -133,6 +133,7 @@ public:
bool IsWindowMaximizable(Window window_id) const;
bool HasWindowDecorations(Window window_id) const;
+ void ShowActionMenu(Time, Window, unsigned button, nux::Point const&);
void Maximize(Window window_id);
void Restore(Window window_id);
void RestoreAt(Window window_id, int x, int y);
diff --git a/unity-shared/StandaloneWindowManager.h b/unity-shared/StandaloneWindowManager.h
index 152617da3..6d4544b77 100644
--- a/unity-shared/StandaloneWindowManager.h
+++ b/unity-shared/StandaloneWindowManager.h
@@ -91,6 +91,7 @@ public:
virtual void ShowDesktop();
virtual bool InShowDesktop() const;
+ virtual void ShowActionMenu(Time, Window, unsigned button, nux::Point const&) {}
virtual void Maximize(Window window_id);
virtual void Restore(Window window_id);
virtual void RestoreAt(Window window_id, int x, int y);
@@ -126,6 +127,7 @@ public:
virtual void MoveResizeWindow(Window window_id, nux::Geometry geometry);
virtual void StartMove(Window window_id, int x, int y);
+ virtual void UnGrabMousePointer(Time, int button, int x, int y) {}
virtual int GetWindowMonitor(Window window_id) const;
virtual nux::Geometry GetWindowGeometry(Window window_id) const;
diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h
index 65239e64f..9f492b46a 100644
--- a/unity-shared/WindowManager.h
+++ b/unity-shared/WindowManager.h
@@ -97,6 +97,7 @@ public:
virtual void ShowDesktop() = 0;
virtual bool InShowDesktop() const = 0;
+ virtual void ShowActionMenu(Time, Window, unsigned button, nux::Point const&) = 0;
virtual void Maximize(Window window_id) = 0;
virtual void Restore(Window window_id) = 0;
virtual void RestoreAt(Window window_id, int x, int y) = 0;
@@ -132,6 +133,7 @@ public:
virtual void MoveResizeWindow(Window window_id, nux::Geometry geometry) = 0;
virtual void StartMove(Window window_id, int x, int y) = 0;
+ virtual void UnGrabMousePointer(Time, int button, int x, int y) = 0;
virtual int GetWindowMonitor(Window window_id) const = 0;
virtual nux::Geometry GetWindowGeometry(Window window_id) const = 0;
diff --git a/unity-shared/XWindowManager.cpp b/unity-shared/XWindowManager.cpp
index 03f7cb5ad..aa3d9c54f 100644
--- a/unity-shared/XWindowManager.cpp
+++ b/unity-shared/XWindowManager.cpp
@@ -162,6 +162,32 @@ std::string XWindowManager::GetWindowName(Window window_id) const
return GetStringProperty(window_id, XA_WM_NAME);
}
+void XWindowManager::UnGrabMousePointer(Time timestamp, int button, int x, int y)
+{
+ Display* dpy = nux::GetGraphicsDisplay()->GetX11Display();
+ XUngrabPointer(dpy, CurrentTime);
+ XFlush(dpy);
+
+ // --------------------------------------------------------------------------
+ // FIXME: This is a workaround until the non-paired events issue is fixed in
+ // nux
+ XButtonEvent bev;
+ memset(&bev, 0, sizeof(bev));
+
+ bev.type = ButtonRelease;
+ bev.send_event = False;
+ bev.display = dpy;
+ bev.time = timestamp;
+ bev.x = x;
+ bev.y = y;
+ bev.x_root = x;
+ bev.y_root = y;
+ bev.button = button;
+ bev.same_screen = True;
+ nux::GetWindowThread()->ProcessForeignEvent(reinterpret_cast<XEvent*>(&bev), nullptr);
+ // --------------------------------------------------------------------------
+}
+
void XWindowManager::StartMove(Window window_id, int x, int y)
{
if (x < 0 || y < 0)
@@ -171,30 +197,7 @@ void XWindowManager::StartMove(Window window_id, int x, int y)
Display* d = nux::GetGraphicsDisplay()->GetX11Display();
/* We first need to ungrab the pointer. FIXME: Evil */
-
- XUngrabPointer(d, CurrentTime);
-
- // --------------------------------------------------------------------------
- // FIXME: This is a workaround until the non-paired events issue is fixed in
- // nux
- XButtonEvent bev =
- {
- ButtonRelease,
- 0,
- False,
- d,
- 0,
- 0,
- 0,
- CurrentTime,
- x, y,
- x, y,
- 0,
- Button1,
- True
- };
- XEvent* e = (XEvent*)&bev;
- nux::GetWindowThread()->ProcessForeignEvent(e, NULL);
+ UnGrabMousePointer(CurrentTime, Button1, x, y);
ev.xclient.type = ClientMessage;
ev.xclient.display = d;
diff --git a/unity-shared/XWindowManager.h b/unity-shared/XWindowManager.h
index 937bf6d63..980c9e6d2 100644
--- a/unity-shared/XWindowManager.h
+++ b/unity-shared/XWindowManager.h
@@ -31,6 +31,7 @@ public:
XWindowManager();
void StartMove(Window window_id, int x, int y);
+ void UnGrabMousePointer(Time, int button, int x, int y);
std::string GetWindowName(Window window_id) const;
std::string GetStringProperty(Window window_id, Atom atom) const;