Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/NeutrinoRDP.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-05-18 07:00:31 +0400
committerJay Sorg <jay.sorg@gmail.com>2014-05-18 07:00:31 +0400
commitdf44374ed6f61bd66e1840f753e0c50f0e213cfe (patch)
tree034a6f7d214706c5d3ebf63de63c9117208108d7
parent74c80e2ca2a88ef72d64e52a54f19bdd9391245e (diff)
X11: add an option to use GrabKey
-rw-r--r--client/X11/xf_event.c26
-rw-r--r--client/X11/xf_window.c17
-rw-r--r--client/X11/xfreerdp.h3
3 files changed, 41 insertions, 5 deletions
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
index 80b7c2c..768e4f2 100644
--- a/client/X11/xf_event.c
+++ b/client/X11/xf_event.c
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -333,6 +333,22 @@ tbool xf_event_KeyRelease(xfInfo* xfi, XEvent* event, tbool app)
return true;
}
+static void ui_grab_keyboard(Display* dis, Window wnd)
+{
+#if XF_GRAB_MODE == 1
+ printf("ui_grab_keyboard:\n");
+ XGrabKeyboard(dis, wnd, true, GrabModeAsync, GrabModeAsync, CurrentTime);
+#endif
+}
+
+static void ui_ungrab_keyboard(Display* dis)
+{
+#if XF_GRAB_MODE == 1
+ printf("ui_ungrab_keyboard:\n");
+ XUngrabKeyboard(dis, CurrentTime);
+#endif
+}
+
tbool xf_event_FocusIn(xfInfo* xfi, XEvent* event, tbool app)
{
if (event->xfocus.mode == NotifyGrab)
@@ -341,7 +357,7 @@ tbool xf_event_FocusIn(xfInfo* xfi, XEvent* event, tbool app)
xfi->focused = true;
if (xfi->mouse_active && (app == false))
- XGrabKeyboard(xfi->display, xfi->window->handle, true, GrabModeAsync, GrabModeAsync, CurrentTime);
+ ui_grab_keyboard(xfi->display, xfi->window->handle);
if (app)
xf_rail_send_activate(xfi, event->xany.window, true);
@@ -362,7 +378,7 @@ tbool xf_event_FocusOut(xfInfo* xfi, XEvent* event, tbool app)
xfi->focused = false;
if (event->xfocus.mode == NotifyWhileGrabbed)
- XUngrabKeyboard(xfi->display, CurrentTime);
+ ui_ungrab_keyboard(xfi->display);
if (app)
xf_rail_send_activate(xfi, event->xany.window, false);
@@ -419,7 +435,7 @@ tbool xf_event_EnterNotify(xfInfo* xfi, XEvent* event, tbool app)
XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime);
if (xfi->focused)
- XGrabKeyboard(xfi->display, xfi->window->handle, true, GrabModeAsync, GrabModeAsync, CurrentTime);
+ ui_grab_keyboard(xfi->display, xfi->window->handle);
}
else
{
@@ -445,7 +461,7 @@ tbool xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, tbool app)
if (app == false)
{
xfi->mouse_active = false;
- XUngrabKeyboard(xfi->display, CurrentTime);
+ ui_ungrab_keyboard(xfi->display);
}
return true;
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c
index 3b61cb3..6f04977 100644
--- a/client/X11/xf_window.c
+++ b/client/X11/xf_window.c
@@ -257,6 +257,18 @@ void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, uint32 style, uint32 ex_st
}
+void ui_grab_keys(Display* dis, Window wnd)
+{
+ int index;
+ int grab_keys[4] = { 0x25, 0x40, 0x6d, 0x71 }; /* alt and ctl keys */
+
+ printf("ui_grab_keys:\n");
+ for (index = 0; index < 4; index++)
+ {
+ XGrabKey(dis, grab_keys[index], AnyModifier, wnd, True, GrabModeAsync, GrabModeAsync);
+ }
+}
+
xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, tbool decorations)
{
xfWindow* window;
@@ -311,6 +323,11 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height,
XStoreName(xfi->display, window->handle, name);
+#if XF_GRAB_MODE == 2
+ if (xfi->grab_keyboard)
+ ui_grab_keys(xfi->display, window->handle);
+#endif
+
return window;
}
diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h
index 3fd2e22..8a20f4e 100644
--- a/client/X11/xfreerdp.h
+++ b/client/X11/xfreerdp.h
@@ -33,6 +33,9 @@ typedef struct xf_info xfInfo;
#include "xf_window.h"
#include "xf_monitor.h"
+/* 1 is grab keyboard, 2 is grab key */
+#define XF_GRAB_MODE 2
+
#define GET_DST(_xfi, _dst) \
do \
{ \