X11 XEvent handling use const arguments

This commit is contained in:
Armin Novak 2020-02-27 09:02:41 +01:00 committed by akallabeth
parent f32a46370c
commit 032574cc8f
2 changed files with 101 additions and 89 deletions

View File

@ -209,7 +209,8 @@ void xf_event_action_script_free(xfContext* xfc)
xfc->xevents = NULL;
}
}
static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event)
{
int index;
int count;
@ -258,6 +259,7 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
pclose(actionScript);
return TRUE;
}
void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
{
rdpSettings* settings;
@ -284,7 +286,7 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
CLAMP_COORDINATES(*x, *y);
}
static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
{
int x, y;
int w, h;
@ -299,10 +301,10 @@ static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app)
}
else
{
x = event->xexpose.x;
y = event->xexpose.y;
w = event->xexpose.width;
h = event->xexpose.height;
x = event->x;
y = event->y;
w = event->width;
h = event->height;
}
if (!app)
@ -317,7 +319,7 @@ static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app)
else
{
xfAppWindow* appWindow;
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (appWindow)
{
@ -327,12 +329,14 @@ static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_VisibilityNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_VisibilityNotify(xfContext* xfc, const XVisibilityEvent* event, BOOL app)
{
WINPR_UNUSED(app);
xfc->unobscured = event->xvisibility.state == VisibilityUnobscured;
xfc->unobscured = event->state == VisibilityUnobscured;
return TRUE;
}
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app)
{
rdpInput* input;
@ -366,16 +370,15 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win
return TRUE;
}
static BOOL xf_event_MotionNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOOL app)
{
if (xfc->use_xinput)
return TRUE;
if (xfc->window)
xf_floatbar_set_root_y(xfc->window->floatbar, event->xmotion.y);
xf_floatbar_set_root_y(xfc->window->floatbar, event->y);
return xf_generic_MotionNotify(xfc, event->xmotion.x, event->xmotion.y, event->xmotion.state,
event->xmotion.window, app);
return xf_generic_MotionNotify(xfc, event->x, event->y, event->state, event->window, app);
}
BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app,
@ -445,44 +448,46 @@ BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window win
return TRUE;
}
static BOOL xf_event_ButtonPress(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_ButtonPress(xfContext* xfc, const XButtonEvent* event, BOOL app)
{
if (xfc->use_xinput)
return TRUE;
return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y, event->xbutton.button,
event->xbutton.window, app, TRUE);
return xf_generic_ButtonEvent(xfc, event->x, event->y, event->button, event->window, app, TRUE);
}
static BOOL xf_event_ButtonRelease(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_ButtonRelease(xfContext* xfc, const XButtonEvent* event, BOOL app)
{
if (xfc->use_xinput)
return TRUE;
return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y, event->xbutton.button,
event->xbutton.window, app, FALSE);
return xf_generic_ButtonEvent(xfc, event->x, event->y, event->button, event->window, app,
FALSE);
}
static BOOL xf_event_KeyPress(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_KeyPress(xfContext* xfc, const XKeyEvent* event, BOOL app)
{
KeySym keysym;
char str[256];
WINPR_UNUSED(app);
XLookupString((XKeyEvent*)event, str, sizeof(str), &keysym, NULL);
xf_keyboard_key_press(xfc, event->xkey.keycode, keysym);
xf_keyboard_key_press(xfc, event->keycode, keysym);
return TRUE;
}
static BOOL xf_event_KeyRelease(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_KeyRelease(xfContext* xfc, const XKeyEvent* event, BOOL app)
{
KeySym keysym;
char str[256];
WINPR_UNUSED(app);
XLookupString((XKeyEvent*)event, str, sizeof(str), &keysym, NULL);
xf_keyboard_key_release(xfc, event->xkey.keycode, keysym);
xf_keyboard_key_release(xfc, event->keycode, keysym);
return TRUE;
}
static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_FocusIn(xfContext* xfc, const XFocusInEvent* event, BOOL app)
{
if (event->xfocus.mode == NotifyGrab)
if (event->mode == NotifyGrab)
return TRUE;
xfc->focused = TRUE;
@ -499,8 +504,8 @@ static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app)
if (app)
{
xfAppWindow* appWindow;
xf_rail_send_activate(xfc, event->xany.window, TRUE);
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
xf_rail_send_activate(xfc, event->window, TRUE);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
/* Update the server with any window changes that occurred while the window was not focused.
*/
@ -513,29 +518,31 @@ static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app)
xf_keyboard_focus_in(xfc);
return TRUE;
}
static BOOL xf_event_FocusOut(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_FocusOut(xfContext* xfc, const XFocusOutEvent* event, BOOL app)
{
if (event->xfocus.mode == NotifyUngrab)
if (event->mode == NotifyUngrab)
return TRUE;
xfc->focused = FALSE;
if (event->xfocus.mode == NotifyWhileGrabbed)
if (event->mode == NotifyWhileGrabbed)
XUngrabKeyboard(xfc->display, CurrentTime);
xf_keyboard_release_all_keypress(xfc);
xf_keyboard_clear(xfc);
if (app)
xf_rail_send_activate(xfc, event->xany.window, FALSE);
xf_rail_send_activate(xfc, event->window, FALSE);
return TRUE;
}
static BOOL xf_event_MappingNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_MappingNotify(xfContext* xfc, const XMappingEvent* event, BOOL app)
{
WINPR_UNUSED(app);
if (event->xmapping.request == MappingModifier)
if (event->request == MappingModifier)
{
if (xfc->modifierMap)
XFreeModifiermap(xfc->modifierMap);
@ -545,15 +552,16 @@ static BOOL xf_event_MappingNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_ClientMessage(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_ClientMessage(xfContext* xfc, const XClientMessageEvent* event, BOOL app)
{
if ((event->xclient.message_type == xfc->WM_PROTOCOLS) &&
((Atom)event->xclient.data.l[0] == xfc->WM_DELETE_WINDOW))
if ((event->message_type == xfc->WM_PROTOCOLS) &&
((Atom)event->data.l[0] == xfc->WM_DELETE_WINDOW))
{
if (app)
{
xfAppWindow* appWindow;
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (appWindow)
{
@ -571,7 +579,8 @@ static BOOL xf_event_ClientMessage(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_EnterNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_EnterNotify(xfContext* xfc, const XEnterWindowEvent* event, BOOL app)
{
if (!app)
{
@ -590,7 +599,7 @@ static BOOL xf_event_EnterNotify(xfContext* xfc, XEvent* event, BOOL app)
else
{
xfAppWindow* appWindow;
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
/* keep track of which window has focus so that we can apply pointer updates */
@ -602,7 +611,8 @@ static BOOL xf_event_EnterNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_LeaveNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_LeaveNotify(xfContext* xfc, const XLeaveWindowEvent* event, BOOL app)
{
WINPR_UNUSED(event);
@ -614,7 +624,8 @@ static BOOL xf_event_LeaveNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* event, BOOL app)
{
Window childWindow;
xfAppWindow* appWindow;
@ -626,17 +637,16 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
if (!xfc->window)
return FALSE;
if (xfc->window->left != event->xconfigure.x)
xfc->window->left = event->xconfigure.x;
if (xfc->window->left != event->x)
xfc->window->left = event->x;
if (xfc->window->top != event->xconfigure.y)
xfc->window->top = event->xconfigure.y;
if (xfc->window->top != event->y)
xfc->window->top = event->y;
if (xfc->window->width != event->xconfigure.width ||
xfc->window->height != event->xconfigure.height)
if (xfc->window->width != event->width || xfc->window->height != event->height)
{
xfc->window->width = event->xconfigure.width;
xfc->window->height = event->xconfigure.height;
xfc->window->width = event->width;
xfc->window->height = event->height;
#ifdef WITH_XRENDER
xfc->offset_x = 0;
xfc->offset_y = 0;
@ -668,7 +678,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (appWindow)
{
@ -678,8 +688,8 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
*/
XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen), 0,
0, &appWindow->x, &appWindow->y, &childWindow);
appWindow->width = event->xconfigure.width;
appWindow->height = event->xconfigure.height;
appWindow->width = event->width;
appWindow->height = event->height;
/*
* Additional checks for not in a local move and not ignoring configure to send
@ -694,7 +704,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
}
else
{
if ((!event->xconfigure.send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
if ((!event->send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
!appWindow->rail_ignore_configure && xfc->focused)
xf_rail_adjust_position(xfc, appWindow);
}
@ -702,7 +712,8 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_MapNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_MapNotify(xfContext* xfc, const XMapEvent* event, BOOL app)
{
xfAppWindow* appWindow;
@ -710,7 +721,7 @@ static BOOL xf_event_MapNotify(xfContext* xfc, XEvent* event, BOOL app)
gdi_send_suppress_output(xfc->context.gdi, FALSE);
else
{
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (appWindow)
{
@ -726,7 +737,8 @@ static BOOL xf_event_MapNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_UnmapNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL app)
{
xfAppWindow* appWindow;
xf_keyboard_release_all_keypress(xfc);
@ -735,7 +747,7 @@ static BOOL xf_event_UnmapNotify(xfContext* xfc, XEvent* event, BOOL app)
gdi_send_suppress_output(xfc->context.gdi, TRUE);
else
{
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (appWindow)
{
@ -745,17 +757,16 @@ static BOOL xf_event_UnmapNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, BOOL app)
{
/*
* This section handles sending the appropriate commands to the rail server
* when the window has been minimized, maximized, restored locally
* ie. not using the buttons on the rail window itself
*/
if ((((Atom)event->xproperty.atom == xfc->_NET_WM_STATE) &&
(event->xproperty.state != PropertyDelete)) ||
(((Atom)event->xproperty.atom == xfc->WM_STATE) &&
(event->xproperty.state != PropertyDelete)))
if ((((Atom)event->atom == xfc->_NET_WM_STATE) && (event->state != PropertyDelete)) ||
(((Atom)event->atom == xfc->WM_STATE) && (event->state != PropertyDelete)))
{
unsigned long i;
BOOL status;
@ -770,16 +781,16 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
if (app)
{
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
if (!appWindow)
return TRUE;
}
if ((Atom)event->xproperty.atom == xfc->_NET_WM_STATE)
if ((Atom)event->atom == xfc->_NET_WM_STATE)
{
status = xf_GetWindowProperty(xfc, event->xproperty.window, xfc->_NET_WM_STATE, 12,
&nitems, &bytes, &prop);
status = xf_GetWindowProperty(xfc, event->window, xfc->_NET_WM_STATE, 12, &nitems,
&bytes, &prop);
if (status)
{
@ -802,10 +813,10 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
}
}
if ((Atom)event->xproperty.atom == xfc->WM_STATE)
if ((Atom)event->atom == xfc->WM_STATE)
{
status = xf_GetWindowProperty(xfc, event->xproperty.window, xfc->WM_STATE, 1, &nitems,
&bytes, &prop);
status =
xf_GetWindowProperty(xfc, event->window, xfc->WM_STATE, 1, &nitems, &bytes, &prop);
if (status)
{
@ -846,7 +857,8 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, XEvent* event)
static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, const XEvent* event)
{
if (!xfc->remote_app)
return FALSE;
@ -935,7 +947,7 @@ static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, XEv
return FALSE;
}
BOOL xf_event_process(freerdp* instance, XEvent* event)
BOOL xf_event_process(freerdp* instance, const XEvent* event)
{
BOOL status = TRUE;
xfAppWindow* appWindow;
@ -976,47 +988,47 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
switch (event->type)
{
case Expose:
status = xf_event_Expose(xfc, event, xfc->remote_app);
status = xf_event_Expose(xfc, &event->xexpose, xfc->remote_app);
break;
case VisibilityNotify:
status = xf_event_VisibilityNotify(xfc, event, xfc->remote_app);
status = xf_event_VisibilityNotify(xfc, &event->xvisibility, xfc->remote_app);
break;
case MotionNotify:
status = xf_event_MotionNotify(xfc, event, xfc->remote_app);
status = xf_event_MotionNotify(xfc, &event->xmotion, xfc->remote_app);
break;
case ButtonPress:
status = xf_event_ButtonPress(xfc, event, xfc->remote_app);
status = xf_event_ButtonPress(xfc, &event->xbutton, xfc->remote_app);
break;
case ButtonRelease:
status = xf_event_ButtonRelease(xfc, event, xfc->remote_app);
status = xf_event_ButtonRelease(xfc, &event->xbutton, xfc->remote_app);
break;
case KeyPress:
status = xf_event_KeyPress(xfc, event, xfc->remote_app);
status = xf_event_KeyPress(xfc, &event->xkey, xfc->remote_app);
break;
case KeyRelease:
status = xf_event_KeyRelease(xfc, event, xfc->remote_app);
status = xf_event_KeyRelease(xfc, &event->xkey, xfc->remote_app);
break;
case FocusIn:
status = xf_event_FocusIn(xfc, event, xfc->remote_app);
status = xf_event_FocusIn(xfc, &event->xfocus, xfc->remote_app);
break;
case FocusOut:
status = xf_event_FocusOut(xfc, event, xfc->remote_app);
status = xf_event_FocusOut(xfc, &event->xfocus, xfc->remote_app);
break;
case EnterNotify:
status = xf_event_EnterNotify(xfc, event, xfc->remote_app);
status = xf_event_EnterNotify(xfc, &event->xcrossing, xfc->remote_app);
break;
case LeaveNotify:
status = xf_event_LeaveNotify(xfc, event, xfc->remote_app);
status = xf_event_LeaveNotify(xfc, &event->xcrossing, xfc->remote_app);
break;
case NoExpose:
@ -1026,30 +1038,30 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
break;
case ConfigureNotify:
status = xf_event_ConfigureNotify(xfc, event, xfc->remote_app);
status = xf_event_ConfigureNotify(xfc, &event->xconfigure, xfc->remote_app);
break;
case MapNotify:
status = xf_event_MapNotify(xfc, event, xfc->remote_app);
status = xf_event_MapNotify(xfc, &event->xmap, xfc->remote_app);
break;
case UnmapNotify:
status = xf_event_UnmapNotify(xfc, event, xfc->remote_app);
status = xf_event_UnmapNotify(xfc, &event->xunmap, xfc->remote_app);
break;
case ReparentNotify:
break;
case MappingNotify:
status = xf_event_MappingNotify(xfc, event, xfc->remote_app);
status = xf_event_MappingNotify(xfc, &event->xmapping, xfc->remote_app);
break;
case ClientMessage:
status = xf_event_ClientMessage(xfc, event, xfc->remote_app);
status = xf_event_ClientMessage(xfc, &event->xclient, xfc->remote_app);
break;
case PropertyNotify:
status = xf_event_PropertyNotify(xfc, event, xfc->remote_app);
status = xf_event_PropertyNotify(xfc, &event->xproperty, xfc->remote_app);
break;
default:

View File

@ -28,7 +28,7 @@
BOOL xf_event_action_script_init(xfContext* xfc);
void xf_event_action_script_free(xfContext* xfc);
BOOL xf_event_process(freerdp* instance, XEvent* event);
BOOL xf_event_process(freerdp* instance, const XEvent* event);
void xf_event_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned int numArgs,
...);