user32: Set correct caret state in the server in SetCaretPos

Anton Baskanov baskanov at gmail.com
Sun Dec 20 03:07:59 CST 2015


Signed-off-by: Anton Baskanov <baskanov at gmail.com>

The code in SetCaretPos doesn't change the caret state if it's position is unchanged.
Reflect this at the server side to avoid caret corruption.
---
 dlls/user32/caret.c | 2 +-
 server/protocol.def | 3 ++-
 server/queue.c      | 4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c
index 53bb5b4..e34d264 100644
--- a/dlls/user32/caret.c
+++ b/dlls/user32/caret.c
@@ -256,7 +256,7 @@ BOOL WINAPI SetCaretPos( INT x, INT y )
         req->x      = x;
         req->y      = y;
         req->hide   = 0;
-        req->state  = 1;
+        req->state  = -2; /* set to 'on' only if the position has changed */
         if ((ret = !wine_server_call_err( req )))
         {
             hwnd      = wine_server_ptr_handle( reply->full_handle );
diff --git a/server/protocol.def b/server/protocol.def
index 04814c9..6b03e36 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2977,7 +2977,8 @@ enum coords_relative
     int            x;             /* caret x position */
     int            y;             /* caret y position */
     int            hide;          /* increment for hide count (can be negative to show it) */
-    int            state;         /* caret state (1=on, 0=off, -1=toggle current state) */
+    int            state;         /* caret state (1=on, 0=off, -1=toggle current state,
+                                   * -2=on if the position differs, unchanged otherwise) */
 @REPLY
     user_handle_t  full_handle;   /* handle to the current caret window */
     rectangle_t    old_rect;      /* previous caret rectangle */
diff --git a/server/queue.c b/server/queue.c
index 3099e12..6d86d94 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -3040,6 +3040,10 @@ DECL_HANDLER(set_caret_info)
     if (req->flags & SET_CARET_STATE)
     {
         if (req->state == -1) input->caret_state = !input->caret_state;
+        else if (req->state == -2 &&
+            (req->x != reply->old_rect.left ||
+            req->y != reply->old_rect.top))
+            input->caret_state = 1;
         else input->caret_state = !!req->state;
     }
 }
-- 
2.1.0




More information about the wine-patches mailing list