2011-08-07 21:41:54 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-07 21:41:54 +04:00
|
|
|
* X11 Keyboard Handling
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-08-15 01:20:53 +04:00
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
#include <ctype.h>
|
2011-08-07 21:41:54 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-11-22 06:22:06 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
2014-03-22 22:40:52 +04:00
|
|
|
#include <winpr/path.h>
|
2022-01-19 11:27:39 +03:00
|
|
|
#include <winpr/assert.h>
|
2014-03-22 22:40:52 +04:00
|
|
|
#include <winpr/collections.h>
|
2012-11-22 06:22:06 +04:00
|
|
|
|
2022-06-03 11:25:30 +03:00
|
|
|
#include <freerdp/utils/string.h>
|
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
2014-10-06 12:37:37 +04:00
|
|
|
#include <X11/XKBlib.h>
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2012-11-29 10:33:19 +04:00
|
|
|
#include <freerdp/locale/keyboard.h>
|
|
|
|
|
2014-03-23 01:12:50 +04:00
|
|
|
#include "xf_event.h"
|
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
#include "xf_keyboard.h"
|
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
#include "xf_utils.h"
|
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
#define TAG CLIENT_TAG("x11")
|
|
|
|
|
2022-11-28 08:22:32 +03:00
|
|
|
static void xf_keyboard_modifier_map_free(xfContext* xfc)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
if (xfc->modifierMap)
|
|
|
|
{
|
|
|
|
XFreeModifiermap(xfc->modifierMap);
|
|
|
|
xfc->modifierMap = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL xf_keyboard_update_modifier_map(xfContext* xfc)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
xf_keyboard_modifier_map_free(xfc);
|
|
|
|
xfc->modifierMap = XGetModifierMapping(xfc->display);
|
|
|
|
return xfc->modifierMap != NULL;
|
|
|
|
}
|
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
static void xf_keyboard_send_key(xfContext* xfc, BOOL down, BOOL repeat, const XKeyEvent* ev);
|
2021-09-10 16:46:33 +03:00
|
|
|
|
2020-06-29 09:39:09 +03:00
|
|
|
static BOOL xf_sync_kbd_state(xfContext* xfc)
|
|
|
|
{
|
|
|
|
const UINT32 syncFlags = xf_keyboard_get_toggle_keys_state(xfc);
|
2022-01-19 11:27:39 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
return freerdp_input_send_synchronize_event(xfc->common.context.input, syncFlags);
|
2020-06-29 09:39:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void xf_keyboard_clear(xfContext* xfc)
|
|
|
|
{
|
2022-01-19 11:27:39 +03:00
|
|
|
WINPR_ASSERT(xfc);
|
2022-10-13 17:25:36 +03:00
|
|
|
ZeroMemory(xfc->KeyboardState, sizeof(xfc->KeyboardState));
|
2020-06-29 09:39:09 +03:00
|
|
|
}
|
2016-12-20 12:59:45 +03:00
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
static BOOL xf_action_script_append(xfContext* xfc, const char* buffer, size_t size, void* user,
|
|
|
|
const char* what, const char* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
WINPR_UNUSED(what);
|
|
|
|
WINPR_UNUSED(arg);
|
|
|
|
|
|
|
|
if (!buffer || (size == 0))
|
|
|
|
return TRUE;
|
|
|
|
return ArrayList_Append(xfc->keyCombinations, buffer);
|
|
|
|
}
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static BOOL xf_keyboard_action_script_init(xfContext* xfc)
|
2014-03-22 22:40:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wObject* obj = NULL;
|
|
|
|
const rdpSettings* settings = NULL;
|
2022-01-19 11:27:39 +03:00
|
|
|
|
|
|
|
settings = xfc->common.context.settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2014-03-22 22:40:52 +04:00
|
|
|
xfc->keyCombinations = ArrayList_New(TRUE);
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!xfc->keyCombinations)
|
2015-06-17 23:08:02 +03:00
|
|
|
return FALSE;
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2020-05-12 18:16:14 +03:00
|
|
|
obj = ArrayList_Object(xfc->keyCombinations);
|
2024-01-24 10:21:47 +03:00
|
|
|
WINPR_ASSERT(obj);
|
2024-02-12 12:39:37 +03:00
|
|
|
obj->fnObjectNew = winpr_ObjectStringClone;
|
|
|
|
obj->fnObjectFree = winpr_ObjectStringFree;
|
2014-03-22 22:40:52 +04:00
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
if (!run_action_script(xfc, "key", NULL, xf_action_script_append, NULL))
|
2015-06-17 23:08:02 +03:00
|
|
|
return FALSE;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
return xf_event_action_script_init(xfc);
|
2014-03-22 22:40:52 +04:00
|
|
|
}
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static void xf_keyboard_action_script_free(xfContext* xfc)
|
2014-03-22 22:40:52 +04:00
|
|
|
{
|
2014-03-23 01:12:50 +04:00
|
|
|
xf_event_action_script_free(xfc);
|
|
|
|
|
2014-03-22 22:40:52 +04:00
|
|
|
if (xfc->keyCombinations)
|
|
|
|
{
|
|
|
|
ArrayList_Free(xfc->keyCombinations);
|
|
|
|
xfc->keyCombinations = NULL;
|
2017-02-06 07:54:54 +03:00
|
|
|
xfc->actionScriptExists = FALSE;
|
2014-03-22 22:40:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
BOOL xf_keyboard_init(xfContext* xfc)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpSettings* settings = NULL;
|
2022-01-19 11:27:39 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
|
|
|
|
settings = xfc->common.context.settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
xf_keyboard_clear(xfc);
|
2023-10-13 10:48:44 +03:00
|
|
|
xfc->KeyboardLayout = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout);
|
|
|
|
xfc->KeyboardLayout = freerdp_keyboard_init_ex(
|
|
|
|
xfc->KeyboardLayout, freerdp_settings_get_string(settings, FreeRDP_KeyboardRemappingList));
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, xfc->KeyboardLayout))
|
|
|
|
return FALSE;
|
2013-11-01 07:35:24 +04:00
|
|
|
|
2022-11-28 08:22:32 +03:00
|
|
|
if (!xf_keyboard_update_modifier_map(xfc))
|
2015-06-17 23:08:02 +03:00
|
|
|
return FALSE;
|
2014-03-22 22:40:52 +04:00
|
|
|
|
|
|
|
xf_keyboard_action_script_init(xfc);
|
2015-06-17 23:08:02 +03:00
|
|
|
return TRUE;
|
2014-03-22 22:40:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void xf_keyboard_free(xfContext* xfc)
|
|
|
|
{
|
2022-11-28 08:22:32 +03:00
|
|
|
xf_keyboard_modifier_map_free(xfc);
|
2014-03-22 22:40:52 +04:00
|
|
|
xf_keyboard_action_script_free(xfc);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:31:07 +03:00
|
|
|
void xf_keyboard_key_press(xfContext* xfc, const XKeyEvent* event, KeySym keysym)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL last = 0;
|
2022-12-12 12:42:40 +03:00
|
|
|
|
2021-09-07 09:31:07 +03:00
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
WINPR_ASSERT(event);
|
2024-04-11 11:45:28 +03:00
|
|
|
WINPR_ASSERT(event->keycode < ARRAYSIZE(xfc->KeyboardState));
|
2014-03-14 05:10:22 +04:00
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
last = xfc->KeyboardState[event->keycode];
|
2021-09-07 09:31:07 +03:00
|
|
|
xfc->KeyboardState[event->keycode] = TRUE;
|
2014-03-14 08:11:44 +04:00
|
|
|
|
|
|
|
if (xf_keyboard_handle_special_keys(xfc, keysym))
|
|
|
|
return;
|
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
xf_keyboard_send_key(xfc, TRUE, last, event);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:31:07 +03:00
|
|
|
void xf_keyboard_key_release(xfContext* xfc, const XKeyEvent* event, KeySym keysym)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2021-09-07 09:31:07 +03:00
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
WINPR_ASSERT(event);
|
2024-04-11 11:45:01 +03:00
|
|
|
WINPR_ASSERT(event->keycode < ARRAYSIZE(xfc->KeyboardState));
|
2014-03-14 05:10:22 +04:00
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
BOOL last = xfc->KeyboardState[event->keycode];
|
2021-09-07 09:31:07 +03:00
|
|
|
xfc->KeyboardState[event->keycode] = FALSE;
|
2016-12-20 12:59:45 +03:00
|
|
|
xf_keyboard_handle_special_keys_release(xfc, keysym);
|
2022-12-12 12:42:40 +03:00
|
|
|
xf_keyboard_send_key(xfc, FALSE, last, event);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
void xf_keyboard_release_all_keypress(xfContext* xfc)
|
2012-04-11 08:37:47 +04:00
|
|
|
{
|
2022-01-19 11:27:39 +03:00
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
|
2023-08-02 13:07:03 +03:00
|
|
|
for (size_t keycode = 0; keycode < ARRAYSIZE(xfc->KeyboardState); keycode++)
|
2012-04-11 08:37:47 +04:00
|
|
|
{
|
2016-01-15 03:59:08 +03:00
|
|
|
if (xfc->KeyboardState[keycode])
|
2012-04-11 08:37:47 +04:00
|
|
|
{
|
2023-08-02 13:07:03 +03:00
|
|
|
const DWORD rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode);
|
2015-02-27 18:02:40 +03:00
|
|
|
|
|
|
|
// release tab before releasing the windows key.
|
|
|
|
// this stops the start menu from opening on unfocus event.
|
|
|
|
if (rdp_scancode == RDP_SCANCODE_LWIN)
|
2022-12-12 12:42:40 +03:00
|
|
|
freerdp_input_send_keyboard_event_ex(xfc->common.context.input, FALSE, FALSE,
|
2022-01-19 11:27:39 +03:00
|
|
|
RDP_SCANCODE_TAB);
|
2015-02-27 18:02:40 +03:00
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
freerdp_input_send_keyboard_event_ex(xfc->common.context.input, FALSE, FALSE,
|
|
|
|
rdp_scancode);
|
2016-01-14 01:05:32 +03:00
|
|
|
xfc->KeyboardState[keycode] = FALSE;
|
2012-04-11 08:37:47 +04:00
|
|
|
}
|
|
|
|
}
|
2020-06-29 09:39:09 +03:00
|
|
|
xf_sync_kbd_state(xfc);
|
2012-04-11 08:37:47 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
BOOL xf_keyboard_key_pressed(xfContext* xfc, KeySym keysym)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2013-06-13 02:57:25 +04:00
|
|
|
KeyCode keycode = XKeysymToKeycode(xfc->display, keysym);
|
2024-09-12 01:34:55 +03:00
|
|
|
WINPR_ASSERT(keycode < ARRAYSIZE(xfc->KeyboardState));
|
2016-01-14 01:05:32 +03:00
|
|
|
return xfc->KeyboardState[keycode];
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2022-12-12 12:42:40 +03:00
|
|
|
void xf_keyboard_send_key(xfContext* xfc, BOOL down, BOOL repeat, const XKeyEvent* event)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
DWORD rdp_scancode = 0;
|
|
|
|
rdpInput* input = NULL;
|
2021-09-10 16:46:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
WINPR_ASSERT(event);
|
|
|
|
|
2022-01-19 11:27:39 +03:00
|
|
|
input = xfc->common.context.input;
|
2021-09-10 16:46:33 +03:00
|
|
|
WINPR_ASSERT(input);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2021-09-10 16:46:33 +03:00
|
|
|
rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(event->keycode);
|
|
|
|
if (rdp_scancode == RDP_SCANCODE_PAUSE && !xf_keyboard_key_pressed(xfc, XK_Control_L) &&
|
|
|
|
!xf_keyboard_key_pressed(xfc, XK_Control_R))
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2014-06-05 01:41:17 +04:00
|
|
|
/* Pause without Ctrl has to be sent as a series of keycodes
|
|
|
|
* in a single input PDU. Pause only happens on "press";
|
|
|
|
* no code is sent on "release".
|
|
|
|
*/
|
2011-08-07 21:41:54 +04:00
|
|
|
if (down)
|
|
|
|
{
|
2014-06-05 01:41:17 +04:00
|
|
|
freerdp_input_send_keyboard_pause_event(input);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-19 11:27:39 +03:00
|
|
|
if (freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_UnicodeInput))
|
2021-09-10 16:46:33 +03:00
|
|
|
{
|
|
|
|
wchar_t buffer[32] = { 0 };
|
|
|
|
int xwc = -1;
|
|
|
|
|
|
|
|
switch (rdp_scancode)
|
|
|
|
{
|
|
|
|
case RDP_SCANCODE_RETURN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
XIM xim = XOpenIM(xfc->display, 0, 0, 0);
|
|
|
|
XIC xic =
|
|
|
|
XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, NULL);
|
|
|
|
|
|
|
|
KeySym ignore = { 0 };
|
2024-01-23 18:49:54 +03:00
|
|
|
Status return_status = 0;
|
2021-09-10 16:46:33 +03:00
|
|
|
XKeyEvent ev = *event;
|
|
|
|
ev.type = KeyPress;
|
|
|
|
xwc = XwcLookupString(xic, &ev, buffer, ARRAYSIZE(buffer), &ignore,
|
|
|
|
&return_status);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xwc < 1)
|
|
|
|
{
|
|
|
|
if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
|
|
|
|
WLog_ERR(TAG, "Unknown key with X keycode 0x%02" PRIx8 "", event->keycode);
|
|
|
|
else
|
2022-12-12 12:42:40 +03:00
|
|
|
freerdp_input_send_keyboard_event_ex(input, down, repeat, rdp_scancode);
|
2021-09-10 16:46:33 +03:00
|
|
|
}
|
|
|
|
else
|
2023-06-30 16:07:48 +03:00
|
|
|
freerdp_input_send_unicode_keyboard_event(input, down ? 0 : KBD_FLAGS_RELEASE,
|
2022-04-28 11:49:42 +03:00
|
|
|
buffer[0]);
|
2021-09-10 16:46:33 +03:00
|
|
|
}
|
|
|
|
else if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
|
|
|
|
WLog_ERR(TAG, "Unknown key with X keycode 0x%02" PRIx8 "", event->keycode);
|
|
|
|
else
|
2022-12-12 12:42:40 +03:00
|
|
|
freerdp_input_send_keyboard_event_ex(input, down, repeat, rdp_scancode);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
if ((rdp_scancode == RDP_SCANCODE_CAPSLOCK) && (down == FALSE))
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2020-06-29 09:39:09 +03:00
|
|
|
xf_sync_kbd_state(xfc);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
int xf_keyboard_read_keyboard_state(xfContext* xfc)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int dummy = 0;
|
|
|
|
Window wdummy = 0;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 state = 0;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2023-01-09 10:33:05 +03:00
|
|
|
if (!xfc->remote_app && xfc->window)
|
2011-08-18 09:16:49 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
XQueryPointer(xfc->display, xfc->window->handle, &wdummy, &wdummy, &dummy, &dummy, &dummy,
|
|
|
|
&dummy, &state);
|
2011-08-18 09:16:49 +04:00
|
|
|
}
|
2012-02-28 03:04:11 +04:00
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
XQueryPointer(xfc->display, DefaultRootWindow(xfc->display), &wdummy, &wdummy, &dummy,
|
|
|
|
&dummy, &dummy, &dummy, &state);
|
2016-08-03 15:16:20 +03:00
|
|
|
}
|
2014-03-14 05:10:22 +04:00
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2014-10-06 12:37:37 +04:00
|
|
|
static int xf_keyboard_get_keymask(xfContext* xfc, int keysym)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2023-06-05 13:16:57 +03:00
|
|
|
int keysymMask = 0;
|
2013-06-13 02:57:25 +04:00
|
|
|
KeyCode keycode = XKeysymToKeycode(xfc->display, keysym);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
|
|
|
if (keycode == NoSymbol)
|
2014-10-06 12:37:37 +04:00
|
|
|
return 0;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2022-11-28 08:22:32 +03:00
|
|
|
WINPR_ASSERT(xfc->modifierMap);
|
2023-06-05 13:16:57 +03:00
|
|
|
for (int modifierpos = 0; modifierpos < 8; modifierpos++)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2014-10-06 12:37:37 +04:00
|
|
|
int offset = xfc->modifierMap->max_keypermod * modifierpos;
|
2013-02-10 22:17:08 +04:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
for (int key = 0; key < xfc->modifierMap->max_keypermod; key++)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2014-03-14 05:10:22 +04:00
|
|
|
if (xfc->modifierMap->modifiermap[offset + key] == keycode)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
keysymMask |= 1 << modifierpos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2014-10-06 12:37:37 +04:00
|
|
|
return keysymMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL xf_keyboard_get_key_state(xfContext* xfc, int state, int keysym)
|
|
|
|
{
|
|
|
|
int keysymMask = xf_keyboard_get_keymask(xfc, keysym);
|
|
|
|
|
|
|
|
if (!keysymMask)
|
|
|
|
return FALSE;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return (state & keysymMask) ? TRUE : FALSE;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-06 12:37:37 +04:00
|
|
|
static BOOL xf_keyboard_set_key_state(xfContext* xfc, BOOL on, int keysym)
|
|
|
|
{
|
|
|
|
if (!xfc->xkbAvailable)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
const int keysymMask = xf_keyboard_get_keymask(xfc, keysym);
|
2014-11-12 06:27:33 +03:00
|
|
|
|
2014-10-06 12:37:37 +04:00
|
|
|
if (!keysymMask)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-12 06:27:33 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return XkbLockModifiers(xfc->display, XkbUseCoreKbd, keysymMask, on ? keysymMask : 0);
|
2014-10-06 12:37:37 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
UINT32 xf_keyboard_get_toggle_keys_state(xfContext* xfc)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2014-03-14 05:10:22 +04:00
|
|
|
UINT32 toggleKeysState = 0;
|
2023-06-05 13:16:57 +03:00
|
|
|
const int state = xf_keyboard_read_keyboard_state(xfc);
|
2013-02-12 05:38:19 +04:00
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
if (xf_keyboard_get_key_state(xfc, state, XK_Scroll_Lock))
|
|
|
|
toggleKeysState |= KBD_SYNC_SCROLL_LOCK;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
if (xf_keyboard_get_key_state(xfc, state, XK_Num_Lock))
|
|
|
|
toggleKeysState |= KBD_SYNC_NUM_LOCK;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
if (xf_keyboard_get_key_state(xfc, state, XK_Caps_Lock))
|
|
|
|
toggleKeysState |= KBD_SYNC_CAPS_LOCK;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
if (xf_keyboard_get_key_state(xfc, state, XK_Kana_Lock))
|
|
|
|
toggleKeysState |= KBD_SYNC_KANA_LOCK;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
return toggleKeysState;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2018-07-10 21:22:18 +03:00
|
|
|
static void xk_keyboard_update_modifier_keys(xfContext* xfc)
|
|
|
|
{
|
2023-06-05 13:16:57 +03:00
|
|
|
const int keysyms[] = { XK_Shift_L, XK_Shift_R, XK_Alt_L, XK_Alt_R,
|
|
|
|
XK_Control_L, XK_Control_R, XK_Super_L, XK_Super_R };
|
2019-02-25 14:44:51 +03:00
|
|
|
|
|
|
|
xf_keyboard_clear(xfc);
|
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
const int state = xf_keyboard_read_keyboard_state(xfc);
|
2018-07-10 21:22:18 +03:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
for (size_t i = 0; i < ARRAYSIZE(keysyms); i++)
|
2018-07-10 21:22:18 +03:00
|
|
|
{
|
|
|
|
if (xf_keyboard_get_key_state(xfc, state, keysyms[i]))
|
|
|
|
{
|
2023-06-05 13:16:57 +03:00
|
|
|
const KeyCode keycode = XKeysymToKeycode(xfc->display, keysyms[i]);
|
2024-09-12 01:34:55 +03:00
|
|
|
WINPR_ASSERT(keycode < ARRAYSIZE(xfc->KeyboardState));
|
2018-07-10 21:22:18 +03:00
|
|
|
xfc->KeyboardState[keycode] = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
void xf_keyboard_focus_in(xfContext* xfc)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2023-06-05 13:16:57 +03:00
|
|
|
UINT32 state = 0;
|
|
|
|
Window w = None;
|
2024-01-23 18:49:54 +03:00
|
|
|
int d = 0;
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2022-01-19 11:27:39 +03:00
|
|
|
WINPR_ASSERT(xfc);
|
2015-01-16 20:40:57 +03:00
|
|
|
if (!xfc->display || !xfc->window)
|
|
|
|
return;
|
2014-11-12 06:27:33 +03:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
rdpInput* input = xfc->common.context.input;
|
2022-01-19 11:27:39 +03:00
|
|
|
WINPR_ASSERT(input);
|
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
const UINT32 syncFlags = xf_keyboard_get_toggle_keys_state(xfc);
|
2020-06-29 09:39:09 +03:00
|
|
|
freerdp_input_send_focus_in_event(input, syncFlags);
|
2018-07-10 21:22:18 +03:00
|
|
|
xk_keyboard_update_modifier_keys(xfc);
|
2015-01-16 20:40:57 +03:00
|
|
|
|
|
|
|
/* finish with a mouse pointer position like mstsc.exe if required */
|
|
|
|
|
2023-01-09 10:33:05 +03:00
|
|
|
if (xfc->remote_app || !xfc->window)
|
2015-01-16 20:40:57 +03:00
|
|
|
return;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state))
|
2015-01-16 20:40:57 +03:00
|
|
|
{
|
2022-01-26 16:21:53 +03:00
|
|
|
if ((x >= 0) && (x < xfc->window->width) && (y >= 0) && (y < xfc->window->height))
|
2014-11-12 06:27:33 +03:00
|
|
|
{
|
2015-01-16 20:40:57 +03:00
|
|
|
xf_event_adjust_coordinates(xfc, &x, &y);
|
2022-01-19 15:11:34 +03:00
|
|
|
freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y);
|
2014-11-12 06:27:33 +03:00
|
|
|
}
|
2013-05-15 12:42:21 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
static BOOL action_script_run(xfContext* xfc, const char* buffer, size_t size, void* user,
|
|
|
|
const char* what, const char* arg)
|
|
|
|
{
|
|
|
|
WINPR_UNUSED(xfc);
|
|
|
|
WINPR_UNUSED(what);
|
|
|
|
WINPR_UNUSED(arg);
|
|
|
|
WINPR_ASSERT(user);
|
|
|
|
int* pstatus = user;
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "ActionScript key: script did not return data");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(buffer, "key-local") == 0)
|
|
|
|
*pstatus = 0;
|
|
|
|
else if (winpr_PathFileExists(buffer))
|
|
|
|
{
|
|
|
|
FILE* fp = popen(buffer, "w");
|
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to execute '%s'", buffer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pstatus = pclose(fp);
|
|
|
|
if (*pstatus < 0)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Command '%s' returned %d", buffer, *pstatus);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "ActionScript key: no such file '%s'", buffer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static int xf_keyboard_execute_action_script(xfContext* xfc, XF_MODIFIER_KEYS* mod, KeySym keysym)
|
2014-03-14 08:11:44 +04:00
|
|
|
{
|
|
|
|
int status = 1;
|
2014-03-22 22:40:52 +04:00
|
|
|
BOOL match = FALSE;
|
2018-08-24 10:54:25 +03:00
|
|
|
char command[2048] = { 0 };
|
2014-03-22 22:40:52 +04:00
|
|
|
char combination[1024] = { 0 };
|
|
|
|
|
2017-02-06 07:54:54 +03:00
|
|
|
if (!xfc->actionScriptExists)
|
2014-03-22 22:40:52 +04:00
|
|
|
return 1;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R) || (keysym == XK_Alt_L) ||
|
|
|
|
(keysym == XK_Alt_R) || (keysym == XK_Control_L) || (keysym == XK_Control_R))
|
2014-03-22 22:40:52 +04:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2014-03-14 08:11:44 +04:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
const char* keyStr = XKeysymToString(keysym);
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-09-23 21:40:34 +03:00
|
|
|
if (keyStr == 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2014-03-14 08:11:44 +04:00
|
|
|
|
|
|
|
if (mod->Shift)
|
2022-06-03 11:25:30 +03:00
|
|
|
winpr_str_append("Shift", combination, sizeof(combination), "+");
|
2014-03-14 08:11:44 +04:00
|
|
|
|
|
|
|
if (mod->Ctrl)
|
2022-06-03 11:25:30 +03:00
|
|
|
winpr_str_append("Ctrl", combination, sizeof(combination), "+");
|
2014-03-14 08:11:44 +04:00
|
|
|
|
|
|
|
if (mod->Alt)
|
2022-06-03 11:25:30 +03:00
|
|
|
winpr_str_append("Alt", combination, sizeof(combination), "+");
|
2014-03-14 08:11:44 +04:00
|
|
|
|
2018-07-10 21:22:18 +03:00
|
|
|
if (mod->Super)
|
2022-06-03 11:25:30 +03:00
|
|
|
winpr_str_append("Super", combination, sizeof(combination), "+");
|
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
winpr_str_append(keyStr, combination, sizeof(combination), "+");
|
|
|
|
|
|
|
|
for (size_t i = 0; i < strnlen(combination, sizeof(combination)); i++)
|
|
|
|
combination[i] = tolower(combination[i]);
|
2018-07-10 21:22:18 +03:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
const size_t count = ArrayList_Count(xfc->keyCombinations);
|
2014-03-22 22:40:52 +04:00
|
|
|
|
2023-06-05 13:16:57 +03:00
|
|
|
for (size_t index = 0; index < count; index++)
|
2014-03-22 22:40:52 +04:00
|
|
|
{
|
2023-06-05 13:16:57 +03:00
|
|
|
const char* keyCombination = (const char*)ArrayList_GetItem(xfc->keyCombinations, index);
|
2014-03-22 22:40:52 +04:00
|
|
|
|
|
|
|
if (_stricmp(keyCombination, combination) == 0)
|
|
|
|
{
|
|
|
|
match = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!match)
|
2014-03-23 01:12:50 +04:00
|
|
|
return 1;
|
2014-03-14 08:11:44 +04:00
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(command, sizeof(command), "key %s", combination);
|
2024-07-24 16:38:43 +03:00
|
|
|
if (!run_action_script(xfc, command, NULL, action_script_run, &status))
|
2014-03-14 08:11:44 +04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static int xk_keyboard_get_modifier_keys(xfContext* xfc, XF_MODIFIER_KEYS* mod)
|
2014-03-14 08:11:44 +04:00
|
|
|
{
|
|
|
|
mod->LeftShift = xf_keyboard_key_pressed(xfc, XK_Shift_L);
|
|
|
|
mod->RightShift = xf_keyboard_key_pressed(xfc, XK_Shift_R);
|
|
|
|
mod->Shift = mod->LeftShift || mod->RightShift;
|
|
|
|
mod->LeftAlt = xf_keyboard_key_pressed(xfc, XK_Alt_L);
|
|
|
|
mod->RightAlt = xf_keyboard_key_pressed(xfc, XK_Alt_R);
|
|
|
|
mod->Alt = mod->LeftAlt || mod->RightAlt;
|
|
|
|
mod->LeftCtrl = xf_keyboard_key_pressed(xfc, XK_Control_L);
|
|
|
|
mod->RightCtrl = xf_keyboard_key_pressed(xfc, XK_Control_R);
|
|
|
|
mod->Ctrl = mod->LeftCtrl || mod->RightCtrl;
|
|
|
|
mod->LeftSuper = xf_keyboard_key_pressed(xfc, XK_Super_L);
|
|
|
|
mod->RightSuper = xf_keyboard_key_pressed(xfc, XK_Super_R);
|
|
|
|
mod->Super = mod->LeftSuper || mod->RightSuper;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-14 05:10:22 +04:00
|
|
|
BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2014-03-14 08:11:44 +04:00
|
|
|
XF_MODIFIER_KEYS mod = { 0 };
|
|
|
|
xk_keyboard_get_modifier_keys(xfc, &mod);
|
|
|
|
|
2016-12-20 12:59:45 +03:00
|
|
|
// remember state of RightCtrl to ungrab keyboard if next action is release of RightCtrl
|
|
|
|
// do not return anything such that the key could be used by client if ungrab is not the goal
|
|
|
|
if (keysym == XK_Control_R)
|
|
|
|
{
|
2024-03-11 10:58:59 +03:00
|
|
|
if (mod.RightCtrl && !xfc->wasRightCtrlAlreadyPressed)
|
2016-12-20 12:59:45 +03:00
|
|
|
{
|
|
|
|
// Right Ctrl is pressed, getting ready to ungrab
|
2020-06-29 09:39:09 +03:00
|
|
|
xfc->ungrabKeyboardWithRightCtrl = TRUE;
|
2024-03-11 10:58:59 +03:00
|
|
|
xfc->wasRightCtrlAlreadyPressed = TRUE;
|
2016-12-20 12:59:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// some other key has been pressed, abort ungrabbing
|
2020-06-29 09:39:09 +03:00
|
|
|
if (xfc->ungrabKeyboardWithRightCtrl)
|
|
|
|
xfc->ungrabKeyboardWithRightCtrl = FALSE;
|
2016-12-20 12:59:45 +03:00
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2024-07-24 16:38:43 +03:00
|
|
|
const int rc = xf_keyboard_execute_action_script(xfc, &mod, keysym);
|
|
|
|
if (rc < 0)
|
|
|
|
return FALSE;
|
|
|
|
if (rc == 0)
|
2014-03-14 08:11:44 +04:00
|
|
|
return TRUE;
|
|
|
|
|
2016-08-03 15:16:20 +03:00
|
|
|
if (!xfc->remote_app && xfc->fullscreen_toggle)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2024-09-10 12:52:15 +03:00
|
|
|
switch (keysym)
|
2014-12-01 13:56:44 +03:00
|
|
|
{
|
2024-09-10 12:52:15 +03:00
|
|
|
case XK_Return:
|
|
|
|
if (mod.Ctrl && mod.Alt)
|
|
|
|
{
|
|
|
|
/* Ctrl-Alt-Enter: toggle full screen */
|
|
|
|
xf_toggle_fullscreen(xfc);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-12-01 13:56:44 +03:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
2014-03-14 05:10:22 +04:00
|
|
|
|
2024-09-10 12:52:15 +03:00
|
|
|
if (mod.Ctrl && mod.Alt)
|
2014-07-01 01:17:06 +04:00
|
|
|
{
|
2024-09-10 12:52:15 +03:00
|
|
|
switch (keysym)
|
2014-07-01 01:17:06 +04:00
|
|
|
{
|
2024-09-10 12:52:15 +03:00
|
|
|
case XK_m:
|
|
|
|
case XK_M:
|
|
|
|
xf_minimize(xfc);
|
2019-08-22 23:17:35 +03:00
|
|
|
return TRUE;
|
2024-09-10 12:52:15 +03:00
|
|
|
case XK_c:
|
|
|
|
case XK_C:
|
|
|
|
/* Ctrl-Alt-C: toggle control */
|
|
|
|
if (freerdp_client_encomsp_toggle_control(xfc->common.encomsp))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-01 01:17:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
#if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */
|
|
|
|
#ifdef WITH_XRENDER
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!xfc->remote_app && freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MultiTouchGestures))
|
2013-05-05 05:23:24 +04:00
|
|
|
{
|
2022-01-19 11:27:39 +03:00
|
|
|
rdpContext* ctx = &xfc->common.context;
|
2018-08-23 13:45:36 +03:00
|
|
|
|
2014-03-14 08:11:44 +04:00
|
|
|
if (mod.Ctrl && mod.Alt)
|
2013-05-30 17:27:20 +04:00
|
|
|
{
|
2014-12-01 13:56:44 +03:00
|
|
|
int pdx = 0;
|
|
|
|
int pdy = 0;
|
|
|
|
int zdx = 0;
|
|
|
|
int zdy = 0;
|
2014-12-01 13:17:16 +03:00
|
|
|
|
2016-08-03 15:16:20 +03:00
|
|
|
switch (keysym)
|
2013-06-27 03:16:28 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */{
|
|
|
|
const UINT32 sessionWidth = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopWidth);
|
|
|
|
const UINT32 sessionHeight = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopHeight);
|
|
|
|
|
|
|
|
xfc->scaledWidth = sessionWidth;
|
|
|
|
xfc->scaledHeight = sessionHeight;
|
2014-12-01 13:56:44 +03:00
|
|
|
xfc->offset_x = 0;
|
|
|
|
xfc->offset_y = 0;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!xfc->fullscreen && (sessionWidth != xfc->window->width ||
|
|
|
|
sessionHeight != xfc->window->height))
|
2014-12-01 13:56:44 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
xf_ResizeDesktopWindow(xfc, xfc->window, sessionWidth, sessionHeight);
|
2014-12-01 13:56:44 +03:00
|
|
|
}
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
xf_draw_screen(xfc, 0, 0, sessionWidth, sessionHeight);
|
2014-12-01 13:56:44 +03:00
|
|
|
return TRUE;
|
2023-10-13 10:48:44 +03:00
|
|
|
}
|
2014-12-01 13:56:44 +03:00
|
|
|
|
|
|
|
case XK_1: /* Ctrl-Alt-1: Zoom in */
|
|
|
|
zdx = zdy = 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_2: /* Ctrl-Alt-2: Zoom out */
|
|
|
|
zdx = zdy = -10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_3: /* Ctrl-Alt-3: Pan left */
|
|
|
|
pdx = -10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_4: /* Ctrl-Alt-4: Pan right */
|
|
|
|
pdx = 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_5: /* Ctrl-Alt-5: Pan up */
|
|
|
|
pdy = -10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_6: /* Ctrl-Alt-6: Pan up */
|
|
|
|
pdy = 10;
|
|
|
|
break;
|
2013-06-27 03:16:28 +04:00
|
|
|
}
|
2014-12-01 13:17:16 +03:00
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
if (pdx != 0 || pdy != 0)
|
2013-06-27 03:16:28 +04:00
|
|
|
{
|
2013-06-27 11:59:49 +04:00
|
|
|
PanningChangeEventArgs e;
|
2013-06-27 03:16:28 +04:00
|
|
|
EventArgsInit(&e, "xfreerdp");
|
2014-12-01 13:56:44 +03:00
|
|
|
e.dx = pdx;
|
|
|
|
e.dy = pdy;
|
2018-02-14 12:14:33 +03:00
|
|
|
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
2014-12-01 13:56:44 +03:00
|
|
|
return TRUE;
|
2013-06-27 03:16:28 +04:00
|
|
|
}
|
2014-12-01 13:56:44 +03:00
|
|
|
|
|
|
|
if (zdx != 0 || zdy != 0)
|
2013-06-27 03:16:28 +04:00
|
|
|
{
|
2014-12-01 13:56:44 +03:00
|
|
|
ZoomingChangeEventArgs e;
|
2013-06-27 03:16:28 +04:00
|
|
|
EventArgsInit(&e, "xfreerdp");
|
2014-12-01 13:56:44 +03:00
|
|
|
e.dx = zdx;
|
|
|
|
e.dy = zdy;
|
2018-02-14 12:14:33 +03:00
|
|
|
PubSub_OnZoomingChange(ctx->pubSub, xfc, &e);
|
2014-12-01 13:56:44 +03:00
|
|
|
return TRUE;
|
2013-06-27 03:16:28 +04:00
|
|
|
}
|
2013-05-30 17:27:20 +04:00
|
|
|
}
|
2013-05-15 00:18:57 +04:00
|
|
|
}
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
#endif /* WITH_XRENDER defined */
|
|
|
|
#endif /* pinch/zoom/pan simulation */
|
2015-04-17 17:21:55 +03:00
|
|
|
return FALSE;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2016-12-20 12:59:45 +03:00
|
|
|
void xf_keyboard_handle_special_keys_release(xfContext* xfc, KeySym keysym)
|
|
|
|
{
|
|
|
|
if (keysym != XK_Control_R)
|
|
|
|
return;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2024-03-11 10:58:59 +03:00
|
|
|
xfc->wasRightCtrlAlreadyPressed = FALSE;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2020-06-29 09:39:09 +03:00
|
|
|
if (!xfc->ungrabKeyboardWithRightCtrl)
|
2016-12-20 12:59:45 +03:00
|
|
|
return;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2016-12-20 12:59:45 +03:00
|
|
|
// all requirements for ungrab are fulfilled, ungrabbing now
|
|
|
|
XF_MODIFIER_KEYS mod = { 0 };
|
|
|
|
xk_keyboard_get_modifier_keys(xfc, &mod);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2016-12-20 12:59:45 +03:00
|
|
|
if (!mod.RightCtrl)
|
|
|
|
{
|
|
|
|
if (!xfc->fullscreen)
|
|
|
|
{
|
2022-09-12 14:23:06 +03:00
|
|
|
freerdp_client_encomsp_toggle_control(xfc->common.encomsp);
|
2016-12-20 12:59:45 +03:00
|
|
|
}
|
2018-08-23 13:45:36 +03:00
|
|
|
|
2018-06-08 12:35:02 +03:00
|
|
|
xfc->mouse_active = FALSE;
|
2022-01-22 15:29:28 +03:00
|
|
|
xf_ungrab(xfc);
|
2016-12-20 12:59:45 +03:00
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2016-12-20 12:59:45 +03:00
|
|
|
// ungrabbed
|
2020-06-29 09:39:09 +03:00
|
|
|
xfc->ungrabKeyboardWithRightCtrl = FALSE;
|
2016-12-20 12:59:45 +03:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL xf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
|
2014-10-06 12:37:37 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
xfContext* xfc = (xfContext*)context;
|
|
|
|
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_SCROLL_LOCK, XK_Scroll_Lock);
|
2014-10-06 12:37:37 +04:00
|
|
|
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_NUM_LOCK, XK_Num_Lock);
|
|
|
|
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_CAPS_LOCK, XK_Caps_Lock);
|
|
|
|
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_KANA_LOCK, XK_Kana_Lock);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-10-06 12:37:37 +04:00
|
|
|
}
|
2017-05-12 10:43:58 +03:00
|
|
|
|
2018-02-14 12:14:33 +03:00
|
|
|
BOOL xf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
|
|
|
|
UINT32 imeConvMode)
|
2017-05-12 10:43:58 +03:00
|
|
|
{
|
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
2018-02-14 12:14:33 +03:00
|
|
|
WLog_WARN(TAG,
|
2019-11-06 17:24:51 +03:00
|
|
|
"KeyboardSetImeStatus(unitId=%04" PRIx16 ", imeState=%08" PRIx32
|
|
|
|
", imeConvMode=%08" PRIx32 ") ignored",
|
2017-05-12 10:43:58 +03:00
|
|
|
imeId, imeState, imeConvMode);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-22 15:29:28 +03:00
|
|
|
|
|
|
|
BOOL xf_ungrab(xfContext* xfc)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(xfc);
|
|
|
|
XUngrabKeyboard(xfc->display, CurrentTime);
|
|
|
|
XUngrabPointer(xfc->display, CurrentTime);
|
2022-01-26 16:21:53 +03:00
|
|
|
xfc->common.mouse_grabbed = FALSE;
|
2022-02-22 13:18:43 +03:00
|
|
|
return TRUE;
|
2022-01-22 15:29:28 +03:00
|
|
|
}
|