2022-02-15 15:21:38 -08:00
|
|
|
From 19a4bd8f76819adf43158402935a3b49f37d946e Mon Sep 17 00:00:00 2001
|
2014-09-21 22:47:26 -07:00
|
|
|
From: Felix Yan <felixonmars@gmail.com>
|
2014-09-23 08:30:26 -07:00
|
|
|
Date: Tue, 23 Sep 2014 23:22:17 +0800
|
2021-05-06 16:40:21 -07:00
|
|
|
Subject: [PATCH] winex11.drv: Update a candidate window's position with
|
|
|
|
over-the-spot style. (try 2)
|
2014-09-21 22:47:26 -07:00
|
|
|
|
|
|
|
In the current implementation, the candidate window position of a input
|
|
|
|
method is fixed because XNSpotLocation isn't updated after an input
|
|
|
|
context (XIC) is created in X11DRV_CreateIC().
|
|
|
|
X11DRV_UpdateCandidatePos() in this patch updates the position. You can
|
2014-09-23 08:30:26 -07:00
|
|
|
see the change of a position with ibus, scim or fcitx when input style
|
|
|
|
is set to "over the spot" in the registry key:
|
2014-09-21 22:47:26 -07:00
|
|
|
|
|
|
|
[HKEY_CURRENT_USER\Software\Wine\X11 Driver]
|
|
|
|
"InputStyle"="OverTheSpot"
|
|
|
|
|
2014-09-23 08:30:26 -07:00
|
|
|
This patch was based on the original work by Muneyuki Noguchi, and
|
|
|
|
received a lot of help from Sebastian Lackner.
|
2014-09-21 22:47:26 -07:00
|
|
|
---
|
2021-11-11 22:54:41 -08:00
|
|
|
dlls/user32/caret.c | 4 +++
|
|
|
|
dlls/user32/driver.c | 7 ++++
|
2021-12-08 14:43:18 -08:00
|
|
|
dlls/win32u/driver.c | 7 ++++
|
2021-11-11 22:54:41 -08:00
|
|
|
dlls/winex11.drv/init.c | 1 +
|
|
|
|
dlls/winex11.drv/x11drv.h | 1 +
|
|
|
|
dlls/winex11.drv/xim.c | 72 ++++++++++++++++++++++++++++++++++++++-
|
2021-12-08 14:43:18 -08:00
|
|
|
include/wine/gdi_driver.h | 5 +++
|
|
|
|
7 files changed, 96 insertions(+), 1 deletion(-)
|
2014-09-21 22:47:26 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c
|
2021-05-06 16:40:21 -07:00
|
|
|
index 2da7e02ca1a..1dd3ff29de4 100644
|
2014-09-21 22:47:26 -07:00
|
|
|
--- a/dlls/user32/caret.c
|
|
|
|
+++ b/dlls/user32/caret.c
|
2021-05-06 16:40:21 -07:00
|
|
|
@@ -27,6 +27,8 @@
|
2014-09-23 08:30:26 -07:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
+#include "user_private.h"
|
|
|
|
+
|
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2021-05-06 16:40:21 -07:00
|
|
|
@@ -274,6 +276,7 @@ BOOL WINAPI SetCaretPos( INT x, INT y )
|
2014-09-23 08:30:26 -07:00
|
|
|
r.left = x;
|
|
|
|
r.top = y;
|
|
|
|
CARET_DisplayCaret( hwnd, &r );
|
|
|
|
+ USER_Driver->pUpdateCandidatePos( hwnd, &r );
|
|
|
|
SetSystemTimer( hwnd, TIMERID, Caret.timeout, CARET_Callback );
|
|
|
|
}
|
|
|
|
return ret;
|
2021-05-06 16:40:21 -07:00
|
|
|
@@ -352,6 +355,7 @@ BOOL WINAPI ShowCaret( HWND hwnd )
|
2014-09-23 08:30:26 -07:00
|
|
|
if (ret && (hidden == 1)) /* hidden was 1 so it's now 0 */
|
|
|
|
{
|
|
|
|
CARET_DisplayCaret( hwnd, &r );
|
|
|
|
+ USER_Driver->pUpdateCandidatePos( hwnd, &r );
|
|
|
|
SetSystemTimer( hwnd, TIMERID, Caret.timeout, CARET_Callback );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
|
2022-02-15 15:21:38 -08:00
|
|
|
index 7e9f63ad1c7..1a144bb78c9 100644
|
2014-09-23 08:30:26 -07:00
|
|
|
--- a/dlls/user32/driver.c
|
|
|
|
+++ b/dlls/user32/driver.c
|
2022-02-15 15:21:38 -08:00
|
|
|
@@ -341,6 +341,11 @@ static BOOL CDECL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDW
|
2021-11-11 22:54:41 -08:00
|
|
|
return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
|
2014-09-23 08:30:26 -07:00
|
|
|
}
|
2014-09-21 22:47:26 -07:00
|
|
|
|
2021-11-11 22:54:41 -08:00
|
|
|
+static void CDECL loaderdrv_UpdateCandidatePos( HWND hwnd, const RECT *caret_rect )
|
2014-09-21 22:47:26 -07:00
|
|
|
+{
|
2021-11-11 22:54:41 -08:00
|
|
|
+ load_driver()->pUpdateCandidatePos( hwnd, caret_rect );
|
2014-09-21 22:47:26 -07:00
|
|
|
+}
|
|
|
|
+
|
2021-11-11 22:54:41 -08:00
|
|
|
static struct user_driver_funcs lazy_load_driver =
|
2014-09-23 08:30:26 -07:00
|
|
|
{
|
2021-11-11 22:54:41 -08:00
|
|
|
{ NULL },
|
2022-02-15 15:21:38 -08:00
|
|
|
@@ -393,6 +398,8 @@ static struct user_driver_funcs lazy_load_driver =
|
2021-12-08 14:43:18 -08:00
|
|
|
NULL,
|
|
|
|
/* vulkan support */
|
2021-12-06 19:08:29 -08:00
|
|
|
NULL,
|
2014-09-23 08:30:26 -07:00
|
|
|
+ /* candidate pos functions */
|
2021-11-11 22:54:41 -08:00
|
|
|
+ loaderdrv_UpdateCandidatePos,
|
2016-08-29 09:29:37 -07:00
|
|
|
/* thread management */
|
2022-02-15 15:21:38 -08:00
|
|
|
NULL
|
2014-09-23 08:30:26 -07:00
|
|
|
};
|
2021-11-11 22:54:41 -08:00
|
|
|
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c
|
2022-02-15 15:21:38 -08:00
|
|
|
index b3a3e70f83f..3f8542e3b20 100644
|
2021-11-11 22:54:41 -08:00
|
|
|
--- a/dlls/win32u/driver.c
|
|
|
|
+++ b/dlls/win32u/driver.c
|
2022-02-15 15:21:38 -08:00
|
|
|
@@ -931,11 +931,17 @@ static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, voi
|
2021-11-11 22:54:41 -08:00
|
|
|
return FALSE;
|
2014-09-23 08:30:26 -07:00
|
|
|
}
|
2014-09-21 22:47:26 -07:00
|
|
|
|
2021-12-08 14:43:18 -08:00
|
|
|
+
|
|
|
|
static const struct vulkan_funcs * CDECL nulldrv_wine_get_vulkan_driver( UINT version )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-11-11 22:54:41 -08:00
|
|
|
+static void CDECL nulldrv_UpdateCandidatePos( HWND hwnd, const RECT *caret_rect )
|
2014-09-23 08:30:26 -07:00
|
|
|
+{
|
2021-12-08 14:43:18 -08:00
|
|
|
+
|
2014-09-23 08:30:26 -07:00
|
|
|
+}
|
|
|
|
+
|
2021-11-11 22:54:41 -08:00
|
|
|
static void CDECL nulldrv_ThreadDetach( void )
|
2014-09-23 08:30:26 -07:00
|
|
|
{
|
2021-11-11 22:54:41 -08:00
|
|
|
}
|
2022-02-15 15:21:38 -08:00
|
|
|
@@ -1133,6 +1139,7 @@ void CDECL __wine_set_display_driver( struct user_driver_funcs *driver, UINT ver
|
2021-11-11 22:54:41 -08:00
|
|
|
SET_USER_FUNC(WindowPosChanged);
|
|
|
|
SET_USER_FUNC(SystemParametersInfo);
|
2021-12-08 14:43:18 -08:00
|
|
|
SET_USER_FUNC(wine_get_vulkan_driver);
|
2021-11-11 22:54:41 -08:00
|
|
|
+ SET_USER_FUNC(UpdateCandidatePos);
|
|
|
|
SET_USER_FUNC(ThreadDetach);
|
|
|
|
#undef SET_USER_FUNC
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c
|
2021-12-08 14:43:18 -08:00
|
|
|
index 1f0549e4d39..7ed3ef7183c 100644
|
2021-11-11 22:54:41 -08:00
|
|
|
--- a/dlls/winex11.drv/init.c
|
|
|
|
+++ b/dlls/winex11.drv/init.c
|
2021-12-08 14:43:18 -08:00
|
|
|
@@ -422,6 +422,7 @@ static const struct user_driver_funcs x11drv_funcs =
|
2021-11-11 22:54:41 -08:00
|
|
|
.pWindowPosChanged = X11DRV_WindowPosChanged,
|
|
|
|
.pSystemParametersInfo = X11DRV_SystemParametersInfo,
|
2021-12-08 14:43:18 -08:00
|
|
|
.pwine_get_vulkan_driver = X11DRV_wine_get_vulkan_driver,
|
2021-11-11 22:54:41 -08:00
|
|
|
+ .pUpdateCandidatePos = X11DRV_UpdateCandidatePos,
|
|
|
|
.pThreadDetach = X11DRV_ThreadDetach,
|
2014-09-23 08:30:26 -07:00
|
|
|
};
|
2014-09-21 22:47:26 -07:00
|
|
|
|
2021-11-11 22:54:41 -08:00
|
|
|
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
|
2021-11-30 15:27:42 -08:00
|
|
|
index ce9a254fb5b..9b6d83ae4f3 100644
|
2021-11-11 22:54:41 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv.h
|
|
|
|
+++ b/dlls/winex11.drv/x11drv.h
|
2021-11-30 15:27:42 -08:00
|
|
|
@@ -242,6 +242,7 @@ extern void CDECL X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT sw
|
2021-11-11 22:54:41 -08:00
|
|
|
struct window_surface *surface ) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL CDECL X11DRV_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param,
|
|
|
|
UINT flags ) DECLSPEC_HIDDEN;
|
|
|
|
+extern void CDECL X11DRV_UpdateCandidatePos( HWND hwnd, const RECT *caret_rect ) DECLSPEC_HIDDEN;
|
|
|
|
extern void CDECL X11DRV_ThreadDetach(void) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
/* X11 driver internal functions */
|
2014-09-21 22:47:26 -07:00
|
|
|
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
|
2021-11-11 22:54:41 -08:00
|
|
|
index 3994c2106cc..ec943dcd623 100644
|
2014-09-21 22:47:26 -07:00
|
|
|
--- a/dlls/winex11.drv/xim.c
|
|
|
|
+++ b/dlls/winex11.drv/xim.c
|
2021-11-11 22:54:41 -08:00
|
|
|
@@ -30,6 +30,7 @@
|
2014-09-23 08:30:26 -07:00
|
|
|
#include "x11drv.h"
|
|
|
|
#include "imm.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
+#include "wine/server.h"
|
2014-09-21 22:47:26 -07:00
|
|
|
|
2014-09-23 08:30:26 -07:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(xim);
|
2014-09-21 22:47:26 -07:00
|
|
|
|
2021-11-11 22:54:41 -08:00
|
|
|
@@ -456,6 +457,48 @@ static BOOL X11DRV_DestroyIC(XIC xic, XPointer p, XPointer data)
|
2014-09-23 08:30:26 -07:00
|
|
|
return TRUE;
|
2014-09-21 22:47:26 -07:00
|
|
|
}
|
2014-09-23 08:30:26 -07:00
|
|
|
|
|
|
|
+/***********************************************************************
|
|
|
|
+ * X11DRV_UpdateCandidatePos
|
|
|
|
+ */
|
2021-11-11 22:54:41 -08:00
|
|
|
+void CDECL X11DRV_UpdateCandidatePos( HWND hwnd, const RECT *caret_rect )
|
2014-09-21 22:47:26 -07:00
|
|
|
+{
|
|
|
|
+ if (ximStyle & XIMPreeditPosition)
|
|
|
|
+ {
|
2014-09-23 08:30:26 -07:00
|
|
|
+ struct x11drv_win_data *data;
|
|
|
|
+ HWND parent;
|
2014-09-21 22:47:26 -07:00
|
|
|
+
|
2014-09-23 08:30:26 -07:00
|
|
|
+ for (parent = hwnd; parent && parent != GetDesktopWindow(); parent = GetAncestor( parent, GA_PARENT ))
|
|
|
|
+ {
|
|
|
|
+ if (!(data = get_win_data( parent ))) continue;
|
|
|
|
+ if (data->xic)
|
|
|
|
+ {
|
|
|
|
+ XVaNestedList preedit;
|
|
|
|
+ XPoint xpoint;
|
|
|
|
+ POINT pt;
|
|
|
|
+
|
|
|
|
+ pt.x = caret_rect->left;
|
|
|
|
+ pt.y = caret_rect->bottom;
|
|
|
|
+
|
|
|
|
+ if (hwnd != data->hwnd)
|
|
|
|
+ MapWindowPoints( hwnd, data->hwnd, &pt, 1 );
|
|
|
|
+
|
|
|
|
+ if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
|
|
|
|
+ pt.x = data->client_rect.right - data->client_rect.left - 1 - pt.x;
|
|
|
|
+
|
|
|
|
+ xpoint.x = pt.x + data->client_rect.left - data->whole_rect.left;
|
|
|
|
+ xpoint.y = pt.y + data->client_rect.top - data->whole_rect.top;
|
|
|
|
+
|
|
|
|
+ preedit = XVaCreateNestedList( 0, XNSpotLocation, &xpoint, NULL );
|
|
|
|
+ if (preedit)
|
|
|
|
+ {
|
|
|
|
+ XSetICValues( data->xic, XNPreeditAttributes, preedit, NULL );
|
|
|
|
+ XFree( preedit );
|
|
|
|
+ }
|
2014-09-21 22:47:26 -07:00
|
|
|
+ }
|
2014-09-23 08:30:26 -07:00
|
|
|
+ release_win_data( data );
|
2014-09-21 22:47:26 -07:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
2014-09-23 08:30:26 -07:00
|
|
|
|
|
|
|
XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
|
|
|
|
{
|
2021-11-11 22:54:41 -08:00
|
|
|
@@ -483,7 +526,7 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
|
2014-09-23 08:30:26 -07:00
|
|
|
XNDestroyCallback, &destroy,
|
|
|
|
NULL);
|
|
|
|
data->xic = xic;
|
|
|
|
- return xic;
|
|
|
|
+ goto return_xic;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create callbacks */
|
2021-11-11 22:54:41 -08:00
|
|
|
@@ -581,5 +624,32 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
|
2014-09-23 08:30:26 -07:00
|
|
|
if (status != NULL)
|
|
|
|
XFree(status);
|
|
|
|
|
|
|
|
+return_xic:
|
|
|
|
+ if (xic != NULL && (ximStyle & XIMPreeditPosition))
|
|
|
|
+ {
|
|
|
|
+ SERVER_START_REQ( set_caret_info )
|
|
|
|
+ {
|
|
|
|
+ req->flags = 0; /* don't set anything */
|
|
|
|
+ req->handle = 0;
|
|
|
|
+ req->x = 0;
|
|
|
|
+ req->y = 0;
|
|
|
|
+ req->hide = 0;
|
|
|
|
+ req->state = 0;
|
|
|
|
+ if (!wine_server_call_err( req ))
|
|
|
|
+ {
|
|
|
|
+ HWND hwnd;
|
|
|
|
+ RECT r;
|
|
|
|
+
|
|
|
|
+ hwnd = wine_server_ptr_handle( reply->full_handle );
|
|
|
|
+ r.left = reply->old_rect.left;
|
|
|
|
+ r.top = reply->old_rect.top;
|
|
|
|
+ r.right = reply->old_rect.right;
|
|
|
|
+ r.bottom = reply->old_rect.bottom;
|
|
|
|
+ X11DRV_UpdateCandidatePos( hwnd, &r );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SERVER_END_REQ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return xic;
|
|
|
|
}
|
2021-11-11 22:54:41 -08:00
|
|
|
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
|
2021-12-08 14:43:18 -08:00
|
|
|
index 567a6c21608..ff92d097f7d 100644
|
2021-11-11 22:54:41 -08:00
|
|
|
--- a/include/wine/gdi_driver.h
|
|
|
|
+++ b/include/wine/gdi_driver.h
|
2021-12-08 14:43:18 -08:00
|
|
|
@@ -319,8 +319,13 @@ struct user_driver_funcs
|
2021-11-11 22:54:41 -08:00
|
|
|
const RECT *,struct window_surface*);
|
|
|
|
/* system parameters */
|
|
|
|
BOOL (CDECL *pSystemParametersInfo)(UINT,UINT,void*,UINT);
|
2021-12-08 14:43:18 -08:00
|
|
|
+
|
|
|
|
/* vulkan support */
|
|
|
|
const struct vulkan_funcs * (CDECL *pwine_get_vulkan_driver)(UINT);
|
|
|
|
+
|
2021-11-11 22:54:41 -08:00
|
|
|
+ /* IME functions */
|
|
|
|
+ void (CDECL *pUpdateCandidatePos)(HWND, const RECT *);
|
2021-12-08 14:43:18 -08:00
|
|
|
+
|
2021-11-11 22:54:41 -08:00
|
|
|
/* thread management */
|
|
|
|
void (CDECL *pThreadDetach)(void);
|
|
|
|
};
|
2014-09-21 22:47:26 -07:00
|
|
|
--
|
2022-02-15 15:21:38 -08:00
|
|
|
2.34.1
|
2014-09-21 22:47:26 -07:00
|
|
|
|