2011-08-07 17:52:40 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* X11 Event 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.
|
|
|
|
*/
|
|
|
|
|
2011-10-27 21:29:16 +04:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2011-08-15 22:33:04 +04:00
|
|
|
#include <freerdp/kbd/kbd.h>
|
|
|
|
#include <freerdp/kbd/vkcodes.h>
|
2011-08-07 17:52:40 +04:00
|
|
|
|
2011-08-22 07:39:56 +04:00
|
|
|
#include "xf_rail.h"
|
2011-12-03 02:51:30 +04:00
|
|
|
#include "xf_window.h"
|
2011-09-23 07:37:17 +04:00
|
|
|
#include "xf_cliprdr.h"
|
2011-08-22 07:39:56 +04:00
|
|
|
|
2011-08-07 17:52:40 +04:00
|
|
|
#include "xf_event.h"
|
|
|
|
|
2011-12-01 04:21:04 +04:00
|
|
|
static const char* const X11_EVENT_STRINGS[] =
|
2011-08-19 19:12:30 +04:00
|
|
|
{
|
|
|
|
"", "",
|
|
|
|
"KeyPress",
|
|
|
|
"KeyRelease",
|
|
|
|
"ButtonPress",
|
|
|
|
"ButtonRelease",
|
|
|
|
"MotionNotify",
|
|
|
|
"EnterNotify",
|
|
|
|
"LeaveNotify",
|
|
|
|
"FocusIn",
|
|
|
|
"FocusOut",
|
|
|
|
"KeymapNotify",
|
|
|
|
"Expose",
|
|
|
|
"GraphicsExpose",
|
|
|
|
"NoExpose",
|
|
|
|
"VisibilityNotify",
|
|
|
|
"CreateNotify",
|
|
|
|
"DestroyNotify",
|
|
|
|
"UnmapNotify",
|
|
|
|
"MapNotify",
|
|
|
|
"MapRequest",
|
|
|
|
"ReparentNotify",
|
|
|
|
"ConfigureNotify",
|
|
|
|
"ConfigureRequest",
|
|
|
|
"GravityNotify",
|
|
|
|
"ResizeRequest",
|
|
|
|
"CirculateNotify",
|
|
|
|
"CirculateRequest",
|
|
|
|
"PropertyNotify",
|
|
|
|
"SelectionClear",
|
|
|
|
"SelectionRequest",
|
|
|
|
"SelectionNotify",
|
|
|
|
"ColormapNotify",
|
|
|
|
"ClientMessage",
|
|
|
|
"MappingNotify",
|
|
|
|
"GenericEvent",
|
|
|
|
};
|
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
void xf_send_mouse_motion_event(rdpInput* input, boolean down, uint32 button, uint16 x, uint16 y)
|
2011-08-07 17:52:40 +04:00
|
|
|
{
|
2011-08-07 21:41:54 +04:00
|
|
|
input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
|
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_Expose(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-08-18 09:16:49 +04:00
|
|
|
int x, y;
|
2011-09-23 05:23:01 +04:00
|
|
|
int w, h;
|
|
|
|
|
|
|
|
x = event->xexpose.x;
|
|
|
|
y = event->xexpose.y;
|
|
|
|
w = event->xexpose.width;
|
|
|
|
h = event->xexpose.height;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
if (app != true)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-09-23 05:23:01 +04:00
|
|
|
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y);
|
2011-08-18 09:16:49 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xfWindow* xfw;
|
|
|
|
rdpWindow* window;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
2011-08-18 09:16:49 +04:00
|
|
|
|
2011-10-16 08:50:10 +04:00
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window);
|
2011-08-18 09:16:49 +04:00
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
xfw = (xfWindow*) window->extra;
|
2011-09-23 05:23:01 +04:00
|
|
|
xf_UpdateWindowArea(xfi, xfw, x, y, w, h);
|
2011-08-18 09:16:49 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-08-19 19:12:30 +04:00
|
|
|
xfi->unobscured = event->xvisibility.state == VisibilityUnobscured;
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_MotionNotify(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
rdpInput* input;
|
2011-08-07 17:52:40 +04:00
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
input = xfi->instance->input;
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
if (app != true)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
if (xfi->mouse_motion != true)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
if ((event->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) == 0)
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
input->MouseEvent(input, PTR_FLAGS_MOVE, event->xmotion.x, event->xmotion.y);
|
|
|
|
|
2011-08-18 09:16:49 +04:00
|
|
|
if (xfi->fullscreen)
|
|
|
|
XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime);
|
|
|
|
}
|
2011-11-19 21:19:16 +04:00
|
|
|
else if (xfi->mouse_motion == true)
|
2011-08-25 01:41:45 +04:00
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
int x = event->xmotion.x;
|
|
|
|
int y = event->xmotion.y;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xmotion.window);
|
2011-08-25 01:41:45 +04:00
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
2011-09-23 05:23:01 +04:00
|
|
|
x += window->windowOffsetX;
|
|
|
|
y += window->windowOffsetY;
|
|
|
|
input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
|
2011-08-25 01:41:45 +04:00
|
|
|
}
|
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 17:52:40 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 17:52:40 +04:00
|
|
|
{
|
2011-08-07 21:41:54 +04:00
|
|
|
uint16 x, y;
|
2011-08-07 17:52:40 +04:00
|
|
|
uint16 flags;
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean wheel;
|
2011-08-07 21:41:54 +04:00
|
|
|
rdpInput* input;
|
|
|
|
|
|
|
|
input = xfi->instance->input;
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
flags = 0;
|
2011-11-19 21:19:16 +04:00
|
|
|
wheel = false;
|
2011-08-18 00:00:09 +04:00
|
|
|
|
|
|
|
switch (event->xbutton.button)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-08-18 00:00:09 +04:00
|
|
|
case 1:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2011-11-19 21:19:16 +04:00
|
|
|
wheel = true;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_WHEEL | 0x0078;
|
|
|
|
break;
|
2011-08-07 17:52:40 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
case 5:
|
2011-11-19 21:19:16 +04:00
|
|
|
wheel = true;
|
2011-08-23 05:22:05 +04:00
|
|
|
flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
|
2011-08-18 00:00:09 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
flags = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags != 0)
|
|
|
|
{
|
|
|
|
if (wheel)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-08-18 00:00:09 +04:00
|
|
|
input->MouseEvent(input, flags, 0, 0);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
2011-08-18 00:00:09 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (app)
|
|
|
|
{
|
2011-08-18 00:45:09 +04:00
|
|
|
rdpWindow* window;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xbutton.window);
|
2011-08-18 00:45:09 +04:00
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
2011-09-23 05:23:01 +04:00
|
|
|
x += window->windowOffsetX;
|
|
|
|
y += window->windowOffsetY;
|
2011-08-18 00:45:09 +04:00
|
|
|
}
|
2011-08-18 00:00:09 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
|
|
|
|
input->MouseEvent(input, flags, x, y);
|
2011-08-18 00:00:09 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 17:52:40 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 17:52:40 +04:00
|
|
|
{
|
2011-08-18 00:45:09 +04:00
|
|
|
uint16 x, y;
|
2011-08-07 17:52:40 +04:00
|
|
|
uint16 flags;
|
2011-08-07 21:41:54 +04:00
|
|
|
rdpInput* input;
|
|
|
|
|
|
|
|
input = xfi->instance->input;
|
|
|
|
|
2011-08-18 00:45:09 +04:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
switch (event->xbutton.button)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-08-18 00:00:09 +04:00
|
|
|
case 1:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_BUTTON1;
|
|
|
|
break;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
case 2:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_BUTTON3;
|
|
|
|
break;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
case 3:
|
2011-09-23 05:23:01 +04:00
|
|
|
x = event->xbutton.x;
|
|
|
|
y = event->xbutton.y;
|
2011-08-18 00:00:09 +04:00
|
|
|
flags = PTR_FLAGS_BUTTON2;
|
|
|
|
break;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
default:
|
|
|
|
flags = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags != 0)
|
|
|
|
{
|
|
|
|
if (app)
|
|
|
|
{
|
2011-08-18 00:45:09 +04:00
|
|
|
rdpWindow* window;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xbutton.window);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 00:45:09 +04:00
|
|
|
if (window != NULL)
|
|
|
|
{
|
2011-09-23 05:23:01 +04:00
|
|
|
x += window->windowOffsetX;
|
|
|
|
y += window->windowOffsetY;
|
2011-08-18 00:45:09 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:45:09 +04:00
|
|
|
input->MouseEvent(input, flags, x, y);
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_KeyPress(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
KeySym keysym;
|
|
|
|
char str[256];
|
|
|
|
|
|
|
|
XLookupString((XKeyEvent*) event, str, sizeof(str), &keysym, NULL);
|
|
|
|
|
|
|
|
xf_kbd_set_keypress(xfi, event->xkey.keycode, keysym);
|
|
|
|
|
|
|
|
if (xfi->fullscreen_toggle && xf_kbd_handle_special_keys(xfi, keysym))
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
xf_kbd_send_key(xfi, true, event->xkey.keycode);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_KeyRelease(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
XEvent next_event;
|
|
|
|
|
|
|
|
if (XPending(xfi->display))
|
|
|
|
{
|
|
|
|
memset(&next_event, 0, sizeof(next_event));
|
|
|
|
XPeekEvent(xfi->display, &next_event);
|
|
|
|
|
|
|
|
if (next_event.type == KeyPress)
|
|
|
|
{
|
|
|
|
if (next_event.xkey.keycode == event->xkey.keycode)
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xf_kbd_unset_keypress(xfi, event->xkey.keycode);
|
2011-11-19 21:19:16 +04:00
|
|
|
xf_kbd_send_key(xfi, false, event->xkey.keycode);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
2011-08-07 17:52:40 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_FocusIn(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
if (event->xfocus.mode == NotifyGrab)
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
xfi->focused = true;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
if (xfi->mouse_active && (app != true))
|
|
|
|
XGrabKeyboard(xfi->display, xfi->window->handle, true, GrabModeAsync, GrabModeAsync, CurrentTime);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
xf_rail_send_activate(xfi, event->xany.window, true);
|
2011-08-07 21:41:54 +04:00
|
|
|
xf_kbd_focus_in(xfi);
|
|
|
|
|
2011-12-03 02:51:30 +04:00
|
|
|
if (app != true)
|
2011-09-23 18:49:59 +04:00
|
|
|
xf_cliprdr_check_owner(xfi);
|
2011-09-23 07:37:17 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_FocusOut(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
if (event->xfocus.mode == NotifyUngrab)
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
xfi->focused = false;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
|
|
|
if (event->xfocus.mode == NotifyWhileGrabbed)
|
|
|
|
XUngrabKeyboard(xfi->display, CurrentTime);
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
xf_rail_send_activate(xfi, event->xany.window, false);
|
2011-08-25 02:22:06 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_MappingNotify(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
|
|
|
if (event->xmapping.request == MappingModifier)
|
|
|
|
{
|
|
|
|
XFreeModifiermap(xfi->modifier_map);
|
|
|
|
xfi->modifier_map = XGetModifierMapping(xfi->display);
|
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_ClientMessage(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-09-21 16:36:49 +04:00
|
|
|
if ((event->xclient.message_type == xfi->WM_PROTOCOLS)
|
|
|
|
&& ((Atom) event->xclient.data.l[0] == xfi->WM_DELETE_WINDOW))
|
|
|
|
{
|
|
|
|
if (app)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-10-16 08:50:10 +04:00
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xclient.window);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-09-21 16:36:49 +04:00
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
xf_rail_send_client_system_command(xfi, window->windowId, SC_CLOSE);
|
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-21 16:36:49 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-09-21 16:36:49 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 17:52:40 +04:00
|
|
|
}
|
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_EnterNotify(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 17:52:40 +04:00
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
if (app != true)
|
2011-08-18 09:16:49 +04:00
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
xfi->mouse_active = true;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 09:16:49 +04:00
|
|
|
if (xfi->fullscreen)
|
|
|
|
XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime);
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 09:16:49 +04:00
|
|
|
if (xfi->focused)
|
2011-11-19 21:19:16 +04:00
|
|
|
XGrabKeyboard(xfi->display, xfi->window->handle, true, GrabModeAsync, GrabModeAsync, CurrentTime);
|
2011-11-15 02:36:25 +04:00
|
|
|
} else {
|
|
|
|
// Keep track of which window has focus so that we can apply pointer updates
|
|
|
|
xfWindow* xfw;
|
|
|
|
rdpWindow* window;
|
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window);
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
xfw = (xfWindow*) window->extra;
|
|
|
|
xfi->window = xfw;
|
|
|
|
}
|
2011-08-18 09:16:49 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 17:52:40 +04:00
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-08-18 00:00:09 +04:00
|
|
|
boolean xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, boolean app)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
if (app != true)
|
2011-08-19 19:12:30 +04:00
|
|
|
{
|
2011-11-19 21:19:16 +04:00
|
|
|
xfi->mouse_active = false;
|
2011-08-19 19:12:30 +04:00
|
|
|
XUngrabKeyboard(xfi->display, CurrentTime);
|
|
|
|
}
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
2011-08-18 00:00:09 +04:00
|
|
|
|
2011-08-18 09:16:49 +04:00
|
|
|
boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
2011-11-19 03:46:22 +04:00
|
|
|
rdpWindow* window;
|
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window);
|
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
xfWindow* xfw;
|
|
|
|
xfw = (xfWindow*) window->extra;
|
|
|
|
|
|
|
|
// ConfigureNotify coordinates are expressed relative to the window parent.
|
|
|
|
// Translate these to root window coordinates.
|
|
|
|
Window childWindow;
|
|
|
|
XTranslateCoordinates(xfi->display, xfw->handle, DefaultRootWindow(xfi->display),
|
|
|
|
0, 0, &xfw->left, &xfw->top, &childWindow);
|
|
|
|
|
|
|
|
xfw->width = event->xconfigure.width;
|
|
|
|
xfw->height = event->xconfigure.height;
|
|
|
|
xfw->right = xfw->left + xfw->width - 1;
|
|
|
|
xfw->bottom = xfw->top + xfw->height - 1;
|
|
|
|
|
2011-11-29 01:50:08 +04:00
|
|
|
if (app)
|
2011-12-03 02:51:30 +04:00
|
|
|
xf_rail_adjust_position(xfi, window);
|
2011-11-29 01:50:08 +04:00
|
|
|
|
2011-11-19 03:46:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return True;
|
2011-08-18 09:16:49 +04:00
|
|
|
}
|
|
|
|
|
2011-08-22 07:15:19 +04:00
|
|
|
boolean xf_event_MapNotify(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
2011-08-22 07:15:19 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
if (app != true)
|
|
|
|
return true;
|
2011-08-22 07:15:19 +04:00
|
|
|
|
2011-10-16 08:50:10 +04:00
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xany.window);
|
2011-08-22 07:15:19 +04:00
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
2011-08-22 07:39:56 +04:00
|
|
|
/* local restore event */
|
|
|
|
xf_rail_send_client_system_command(xfi, window->windowId, SC_RESTORE);
|
2011-11-29 01:50:08 +04:00
|
|
|
xfWindow *xfw = (xfWindow*) window->extra;
|
2011-12-03 02:51:30 +04:00
|
|
|
xfw->is_mapped = true;
|
2011-11-29 01:50:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
|
|
|
|
if (app != true)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
window = window_list_get_by_extra_id(rail->list, (void*) event->xany.window);
|
|
|
|
|
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
xfWindow *xfw = (xfWindow*) window->extra;
|
2011-12-03 02:51:30 +04:00
|
|
|
xfw->is_mapped = false;
|
2011-08-22 07:15:19 +04:00
|
|
|
}
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-22 07:15:19 +04:00
|
|
|
}
|
|
|
|
|
2011-09-23 07:37:17 +04:00
|
|
|
boolean xf_event_SelectionNotify(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
2011-12-03 02:51:30 +04:00
|
|
|
if (app != true)
|
2011-09-23 18:49:59 +04:00
|
|
|
{
|
|
|
|
if (xf_cliprdr_process_selection_notify(xfi, event))
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 18:49:59 +04:00
|
|
|
}
|
2011-09-23 07:37:17 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 07:37:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean xf_event_SelectionRequest(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
2011-12-03 02:51:30 +04:00
|
|
|
if (app != true)
|
2011-09-23 18:49:59 +04:00
|
|
|
{
|
|
|
|
if (xf_cliprdr_process_selection_request(xfi, event))
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 18:49:59 +04:00
|
|
|
}
|
2011-09-23 07:37:17 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 07:37:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean xf_event_SelectionClear(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
2011-12-03 02:51:30 +04:00
|
|
|
if (app != true)
|
2011-09-23 18:49:59 +04:00
|
|
|
{
|
|
|
|
if (xf_cliprdr_process_selection_clear(xfi, event))
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 18:49:59 +04:00
|
|
|
}
|
2011-09-23 07:37:17 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 07:37:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, boolean app)
|
|
|
|
{
|
2011-12-03 02:51:30 +04:00
|
|
|
if (app != true)
|
2011-09-23 18:49:59 +04:00
|
|
|
{
|
|
|
|
if (xf_cliprdr_process_property_notify(xfi, event))
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 18:49:59 +04:00
|
|
|
}
|
2011-09-23 07:37:17 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-09-23 07:37:17 +04:00
|
|
|
}
|
|
|
|
|
2011-12-07 03:42:58 +04:00
|
|
|
boolean xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*event)
|
2011-08-07 21:41:54 +04:00
|
|
|
{
|
2011-12-07 03:42:58 +04:00
|
|
|
if (! xfi->remote_app)
|
|
|
|
return false;
|
2011-08-07 21:41:54 +04:00
|
|
|
|
2011-12-07 03:42:58 +04:00
|
|
|
switch (xfi->window->local_move.state)
|
2011-08-18 09:16:49 +04:00
|
|
|
{
|
2011-12-07 03:42:58 +04:00
|
|
|
case LMS_NOT_ACTIVE:
|
|
|
|
// No local move in progress, nothing to do
|
|
|
|
break;
|
|
|
|
case LMS_STARTING:
|
|
|
|
// Local move initiated by RDP server, but we
|
|
|
|
// have not yet seen any updates from the X server
|
|
|
|
switch(event->type)
|
2011-12-03 02:51:30 +04:00
|
|
|
{
|
2011-12-07 03:42:58 +04:00
|
|
|
case ConfigureNotify:
|
|
|
|
// Starting to see move events
|
|
|
|
// from the X server. Local
|
|
|
|
// move is now in progress.
|
|
|
|
xfi->window->local_move.state = LMS_ACTIVE;
|
|
|
|
|
|
|
|
// Allow these events to be processed during move to keep
|
|
|
|
// our state up to date.
|
|
|
|
break;
|
2011-12-03 02:51:30 +04:00
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
|
|
|
case UnmapNotify:
|
2011-12-07 03:42:58 +04:00
|
|
|
// A button release event means the X
|
|
|
|
// window server did not grab the
|
|
|
|
// mouse before the user released it.
|
|
|
|
// In this case we must cancel the
|
|
|
|
// local move. The event will be
|
|
|
|
// processed below as normal, below.
|
|
|
|
xf_rail_end_local_move(xfi, window);
|
|
|
|
break;
|
2011-12-03 02:51:30 +04:00
|
|
|
case VisibilityNotify:
|
2011-12-07 03:42:58 +04:00
|
|
|
case PropertyNotify:
|
|
|
|
// Allow these events to pass
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
// Eat any other events
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LMS_ACTIVE:
|
|
|
|
// Local move is in progress
|
|
|
|
switch(event->type)
|
|
|
|
{
|
2011-12-03 02:51:30 +04:00
|
|
|
case ConfigureNotify:
|
2011-12-07 03:42:58 +04:00
|
|
|
case VisibilityNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
case PropertyNotify:
|
2011-12-07 03:42:58 +04:00
|
|
|
// Keep us up to date on position
|
2011-12-03 02:51:30 +04:00
|
|
|
break;
|
2011-12-07 03:42:58 +04:00
|
|
|
case Expose:
|
|
|
|
return true;
|
2011-12-03 02:51:30 +04:00
|
|
|
default:
|
2011-12-07 03:42:58 +04:00
|
|
|
// Any other event terminates move
|
2011-12-03 02:51:30 +04:00
|
|
|
xf_rail_end_local_move(xfi, window);
|
2011-12-07 03:42:58 +04:00
|
|
|
break;
|
2011-12-03 02:51:30 +04:00
|
|
|
}
|
2011-12-07 03:42:58 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LMS_TERMINATING:
|
|
|
|
// Already sent RDP end move to sever
|
|
|
|
// Allow events to pass.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-03 02:51:30 +04:00
|
|
|
|
2011-12-07 03:42:58 +04:00
|
|
|
boolean xf_event_process(freerdp* instance, XEvent* event)
|
|
|
|
{
|
|
|
|
boolean status = true;
|
|
|
|
xfInfo* xfi = ((xfContext*) instance->context)->xfi;
|
|
|
|
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
|
|
|
|
rdpWindow* window;
|
|
|
|
|
|
|
|
if (xfi->remote_app)
|
|
|
|
{
|
|
|
|
window = window_list_get_by_extra_id(
|
|
|
|
rail->list, (void*) event->xexpose.window);
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
// Update "current" window for cursor change orders
|
|
|
|
xfi->window = (xfWindow *) window->extra;
|
|
|
|
|
|
|
|
if (xf_event_suppress_events(xfi, window, event))
|
|
|
|
return true;
|
2011-12-03 02:51:30 +04:00
|
|
|
}
|
|
|
|
}
|
2011-09-03 20:50:26 +04:00
|
|
|
|
2011-08-19 19:12:30 +04:00
|
|
|
if (event->type != MotionNotify)
|
2011-09-02 21:29:17 +04:00
|
|
|
DEBUG_X11("%s Event: wnd=0x%04X", X11_EVENT_STRINGS[event->type], (uint32) event->xany.window);
|
2011-08-19 19:12:30 +04:00
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case Expose:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_Expose(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VisibilityNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_VisibilityNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_MotionNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ButtonPress:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_ButtonPress(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ButtonRelease:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_ButtonRelease(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KeyPress:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_KeyPress(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KeyRelease:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_KeyRelease(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FocusIn:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_FocusIn(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FocusOut:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_FocusOut(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EnterNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_EnterNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LeaveNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_LeaveNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NoExpose:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GraphicsExpose:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ConfigureNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_ConfigureNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MapNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_MapNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
2011-11-29 01:50:08 +04:00
|
|
|
case UnmapNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_UnmapNotify(xfi, event, xfi->remote_app);
|
2011-11-29 01:50:08 +04:00
|
|
|
break;
|
|
|
|
|
2011-08-07 21:41:54 +04:00
|
|
|
case ReparentNotify:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MappingNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_MappingNotify(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ClientMessage:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_ClientMessage(xfi, event, xfi->remote_app);
|
2011-08-07 21:41:54 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-23 07:37:17 +04:00
|
|
|
case SelectionNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_SelectionNotify(xfi, event, xfi->remote_app);
|
2011-09-23 07:37:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionRequest:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_SelectionRequest(xfi, event, xfi->remote_app);
|
2011-09-23 07:37:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionClear:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_SelectionClear(xfi, event, xfi->remote_app);
|
2011-09-23 07:37:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PropertyNotify:
|
2011-12-03 02:51:30 +04:00
|
|
|
status = xf_event_PropertyNotify(xfi, event, xfi->remote_app);
|
2011-09-23 07:37:17 +04:00
|
|
|
break;
|
2011-08-07 21:41:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|