diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c index 53bb5b44f5e..686dade4103 100644 --- a/dlls/user32/caret.c +++ b/dlls/user32/caret.c @@ -86,7 +86,7 @@ static void CALLBACK CARET_Callback( HWND hwnd, UINT msg, UINT_PTR id, DWORD cti req->x = 0; req->y = 0; req->hide = 0; - req->state = -1; /* toggle current state */ + req->state = CARET_STATE_TOGGLE; if ((ret = !wine_server_call( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); @@ -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 = CARET_STATE_ON_IF_MOVED; if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); @@ -300,7 +300,7 @@ BOOL WINAPI HideCaret( HWND hwnd ) req->x = 0; req->y = 0; req->hide = 1; - req->state = 0; + req->state = CARET_STATE_OFF; if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); @@ -339,7 +339,7 @@ BOOL WINAPI ShowCaret( HWND hwnd ) req->x = 0; req->y = 0; req->hide = -1; - req->state = 1; + req->state = CARET_STATE_ON; if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 61e6d3f0362..a8708749663 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -4222,6 +4222,13 @@ struct set_caret_info_reply #define SET_CARET_POS 0x01 #define SET_CARET_HIDE 0x02 #define SET_CARET_STATE 0x04 +enum caret_state +{ + CARET_STATE_OFF, + CARET_STATE_ON, + CARET_STATE_TOGGLE, + CARET_STATE_ON_IF_MOVED +}; @@ -6157,6 +6164,6 @@ union generic_reply struct terminate_job_reply terminate_job_reply; }; -#define SERVER_PROTOCOL_VERSION 500 +#define SERVER_PROTOCOL_VERSION 501 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/protocol.def b/server/protocol.def index 2819382413a..cde8f6356aa 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2968,7 +2968,7 @@ 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 (see below) */ @REPLY user_handle_t full_handle; /* handle to the current caret window */ rectangle_t old_rect; /* previous caret rectangle */ @@ -2978,6 +2978,13 @@ enum coords_relative #define SET_CARET_POS 0x01 /* set the caret position from x,y */ #define SET_CARET_HIDE 0x02 /* increment the caret hide count */ #define SET_CARET_STATE 0x04 /* set the caret on/off state */ +enum caret_state +{ + CARET_STATE_OFF, /* off */ + CARET_STATE_ON, /* on */ + CARET_STATE_TOGGLE, /* toggle current state */ + CARET_STATE_ON_IF_MOVED /* on if the position differs, unchanged otherwise */ +}; /* Set a window hook */ diff --git a/server/queue.c b/server/queue.c index 3099e129612..7fe0d03cdf2 100644 --- a/server/queue.c +++ b/server/queue.c @@ -3039,8 +3039,15 @@ DECL_HANDLER(set_caret_info) } if (req->flags & SET_CARET_STATE) { - if (req->state == -1) input->caret_state = !input->caret_state; - else input->caret_state = !!req->state; + switch (req->state) + { + case CARET_STATE_OFF: input->caret_state = 0; break; + case CARET_STATE_ON: input->caret_state = 1; break; + case CARET_STATE_TOGGLE: input->caret_state = !input->caret_state; break; + case CARET_STATE_ON_IF_MOVED: + if (req->x != reply->old_rect.left || req->y != reply->old_rect.top) input->caret_state = 1; + break; + } } }