[PATCH v7 0/5] MR11173: server: Update window zorder directly in queue_mouse_message.
Instead of using an extra request on every mouse motion event. -- v7: winex11: Remove now unnecessary update_window_zorder call. winemac: Remove now unnecessary update_window_zorder call. wineandroid: Remove now unnecessary update_window_zorder call. server: Update window zorder directly in queue_mouse_message. server: Map update_window_zorder rect from raw to virtual coordinates. https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
From: Rémi Bernon <rbernon@codeweavers.com> --- server/window.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/window.c b/server/window.c index 6bff48e7a22..059f9be1e09 100644 --- a/server/window.c +++ b/server/window.c @@ -3038,6 +3038,11 @@ DECL_HANDLER(update_window_zorder) if (!win || !win->parent || !is_visible( win )) return; /* nothing to do */ + map_point_raw_to_virt( win->desktop, &rect.left, &rect.top ); + map_point_raw_to_virt( win->desktop, &rect.right, &rect.bottom ); + rect.right = max( rect.left + 1, rect.right ); + rect.bottom = max( rect.top + 1, rect.bottom ); + LIST_FOR_EACH_ENTRY( ptr, &win->parent->children, struct window, entry ) { if (ptr == win) break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
From: Rémi Bernon <rbernon@codeweavers.com> --- server/queue.c | 10 ++++++++++ server/user.h | 1 + server/window.c | 12 ++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/server/queue.c b/server/queue.c index a04b53b70de..b23298e3d5f 100644 --- a/server/queue.c +++ b/server/queue.c @@ -2250,6 +2250,16 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons time = input->mouse.time; if (!time) time = desktop_shm->cursor.last_change; + if (win && origin == IMO_HARDWARE && flags == (MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE)) + { + struct rectangle rect = { input->mouse.x, input->mouse.y, input->mouse.x + 1, input->mouse.y + 1 }; + unsigned char state = (desktop_shm->keystate[VK_LBUTTON] | desktop_shm->keystate[VK_MBUTTON] | + desktop_shm->keystate[VK_RBUTTON] | desktop_shm->keystate[VK_XBUTTON1] | + desktop_shm->keystate[VK_XBUTTON2]) & 0x80; + input_shm_t *input_shm = sender && sender->input ? sender->input->shared : NULL; + if (!state && input_shm && !input_shm->capture) set_window_rect_visible( win, rect ); + } + if (flags & MOUSEEVENTF_MOVE) { if (flags & MOUSEEVENTF_ABSOLUTE) diff --git a/server/user.h b/server/user.h index 1d16e2aab95..1997029b0e9 100644 --- a/server/user.h +++ b/server/user.h @@ -184,6 +184,7 @@ extern user_handle_t shallow_window_from_point( struct desktop *desktop, int x, extern struct thread *window_thread_from_point( user_handle_t scope, int x, int y ); extern user_handle_t find_window_to_repaint( user_handle_t parent, struct thread *thread ); extern struct window_class *get_window_class( user_handle_t window ); +extern void set_window_rect_visible( user_handle_t window, struct rectangle rect ); /* window class functions */ diff --git a/server/window.c b/server/window.c index 059f9be1e09..e6d5a6d377b 100644 --- a/server/window.c +++ b/server/window.c @@ -3031,12 +3031,12 @@ DECL_HANDLER(get_update_region) /* update the z order of a window so that a given rectangle is fully visible */ -DECL_HANDLER(update_window_zorder) +void set_window_rect_visible( user_handle_t window, struct rectangle rect ) { - struct rectangle tmp, rect = req->rect; - struct window *ptr, *win = get_window( req->window ); + struct window *ptr, *win; + struct rectangle tmp; - if (!win || !win->parent || !is_visible( win )) return; /* nothing to do */ + if (!(win = get_window( window )) || !win->parent || !is_visible( win )) return; /* nothing to do */ map_point_raw_to_virt( win->desktop, &rect.left, &rect.top ); map_point_raw_to_virt( win->desktop, &rect.right, &rect.bottom ); @@ -3068,6 +3068,10 @@ DECL_HANDLER(update_window_zorder) } } +DECL_HANDLER(update_window_zorder) +{ + set_window_rect_visible( req->window, req->rect ); +} /* mark parts of a window as needing a redraw */ DECL_HANDLER(redraw_window) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/wineandroid.drv/android.h | 1 - dlls/wineandroid.drv/device.c | 9 --------- dlls/wineandroid.drv/window.c | 21 +++------------------ 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 1d3df21d10f..3e69e52c736 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -132,7 +132,6 @@ enum android_window_messages WM_ANDROID_REFRESH = WM_WINE_FIRST_DRIVER_MSG, }; -extern HWND get_capture_window(void); extern void init_monitors( int width, int height ); extern void set_screen_dpi( DWORD dpi ); extern void update_keyboard_lock_state( WORD vkey, UINT state ); diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index c660c656776..c1071eff4a6 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -79,7 +79,6 @@ static jobject java_object; #define SYNC_IOC_WAIT _IOW('>', 0, __s32) #endif -static HWND capture_window; static HWND desktop_window; int event_sink = -1; @@ -401,7 +400,6 @@ static void free_native_win_data( struct native_win_data *data ) { unsigned int idx = data_map_idx( data->hwnd, data->opengl ); - InterlockedCompareExchangePointer( (void **)&capture_window, 0, data->hwnd ); release_native_window( data ); free( data ); data_map[idx] = NULL; @@ -455,12 +453,6 @@ end: pthread_mutex_unlock(&dispatch_ioctl_lock); } -/* get the capture window stored in the desktop process */ -HWND get_capture_window(void) -{ - return capture_window; -} - static jobject load_java_method( JNIEnv* env, jmethodID *method, const char *name, const char *args ) { if (!*method) @@ -809,7 +801,6 @@ static int setCapture_ioctl( JNIEnv* env, void *data, DWORD in_size, DWORD out_s LOG( TRACE, "hwnd %08x\n", res->hdr.hwnd ); - InterlockedExchangePointer( (void **)&capture_window, LongToHandle( res->hdr.hwnd )); return 0; } diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 3cc971558ff..0d47b240632 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -459,8 +459,6 @@ static int process_events( DWORD mask ) case MOTION_EVENT: { - HWND capture = get_capture_window(); - if (event->data.motion.input.mi.dwFlags & (MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_RIGHTDOWN|MOUSEEVENTF_MIDDLEDOWN)) TRACE( "BUTTONDOWN pos %d,%d hwnd %p flags %x\n", event->data.motion.input.mi.dx, event->data.motion.input.mi.dy, @@ -472,22 +470,9 @@ static int process_events( DWORD mask ) else TRACE( "MOUSEMOVE pos %d,%d hwnd %p flags %x\n", event->data.motion.input.mi.dx, event->data.motion.input.mi.dy, - event->data.motion.hwnd, event->data.motion.input.mi.dwFlags ); - if (!capture && (event->data.motion.input.mi.dwFlags & MOUSEEVENTF_ABSOLUTE)) - { - RECT rect; - SetRect( &rect, event->data.motion.input.mi.dx, event->data.motion.input.mi.dy, - event->data.motion.input.mi.dx + 1, event->data.motion.input.mi.dy + 1 ); - - SERVER_START_REQ( update_window_zorder ) - { - req->window = wine_server_user_handle( event->data.motion.hwnd ); - req->rect = wine_server_rectangle( rect ); - wine_server_call( req ); - } - SERVER_END_REQ; - } - NtUserSendHardwareInput( capture ? capture : event->data.motion.hwnd, 0, &event->data.motion.input, 0 ); + hwnd, event->data.motion.input.mi.dwFlags ); + + NtUserSendHardwareInput( hwnd, 0, &event->data.motion.input, 0 ); } break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winemac.drv/mouse.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 19674b2d099..2c15fe7cfd1 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -130,25 +130,6 @@ static void send_mouse_input(HWND hwnd, macdrv_window cocoa_window, UINT flags, DWORD mouse_data, BOOL drag, unsigned long time) { INPUT input; - HWND top_level_hwnd; - - top_level_hwnd = NtUserGetAncestor(hwnd, GA_ROOT); - - if ((flags & MOUSEEVENTF_MOVE) && (flags & MOUSEEVENTF_ABSOLUTE) && !drag && - cocoa_window != macdrv_thread_data()->capture_window) - { - /* update the wine server Z-order */ - SERVER_START_REQ(update_window_zorder) - { - req->window = wine_server_user_handle(top_level_hwnd); - req->rect.left = x; - req->rect.top = y; - req->rect.right = x + 1; - req->rect.bottom = y + 1; - wine_server_call(req); - } - SERVER_END_REQ; - } input.type = INPUT_MOUSE; input.mi.dx = x; @@ -158,7 +139,7 @@ static void send_mouse_input(HWND hwnd, macdrv_window cocoa_window, UINT flags, input.mi.time = time; input.mi.dwExtraInfo = 0; - NtUserSendHardwareInput(top_level_hwnd, 0, &input, 0); + NtUserSendHardwareInput(hwnd, 0, &input, 0); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winex11.drv/mouse.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 5b36def3f17..9baccb55f83 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -531,30 +531,13 @@ static void map_event_coords( HWND hwnd, Window window, Window event_root, int x * * Update the various window states on a mouse event. */ -static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPUT *input ) +static void send_mouse_input( HWND hwnd, Window window, INPUT *input ) { struct x11drv_thread_data *thread_data = x11drv_thread_data(); /* ignore clipping window input when not clipping or wrong clipping window */ if (!hwnd && (!thread_data->clipping_cursor || thread_data->clip_window != window)) return; - /* update the wine server Z-order */ - - if (hwnd && hwnd != NtUserGetAncestor( get_capture_window(), GA_ROOT ) && - /* ignore event if a button is pressed, since the mouse is then grabbed too */ - !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask))) - { - RECT rect = { input->mi.dx, input->mi.dy, input->mi.dx + 1, input->mi.dy + 1 }; - - SERVER_START_REQ( update_window_zorder ) - { - req->window = wine_server_user_handle( hwnd ); - req->rect = wine_server_rectangle( rect ); - wine_server_call( req ); - } - SERVER_END_REQ; - } - input->type = INPUT_MOUSE; NtUserSendHardwareInput( hwnd, 0, input, 0 ); } @@ -1544,7 +1527,7 @@ BOOL X11DRV_ButtonPress( HWND hwnd, XEvent *xev ) } map_event_coords( hwnd, event->window, event->root, event->x_root, event->y_root, &input ); - send_mouse_input( hwnd, event->window, event->state, &input ); + send_mouse_input( hwnd, event->window, &input ); return TRUE; } @@ -1570,7 +1553,7 @@ BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *xev ) input.mi.dwExtraInfo = 0; map_event_coords( hwnd, event->window, event->root, event->x_root, event->y_root, &input ); - send_mouse_input( hwnd, event->window, event->state, &input ); + send_mouse_input( hwnd, event->window, &input ); return TRUE; } @@ -1599,7 +1582,7 @@ BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *xev ) return FALSE; } map_event_coords( hwnd, event->window, event->root, event->x_root, event->y_root, &input ); - send_mouse_input( hwnd, event->window, event->state, &input ); + send_mouse_input( hwnd, event->window, &input ); return TRUE; } @@ -1632,7 +1615,7 @@ BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *xev ) return FALSE; } map_event_coords( hwnd, event->window, event->root, event->x_root, event->y_root, &input ); - send_mouse_input( hwnd, event->window, event->state, &input ); + send_mouse_input( hwnd, event->window, &input ); return TRUE; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11173
participants (2)
-
Rémi Bernon -
Rémi Bernon (@rbernon)