Fixed mouse clipping bug when loading a new language.

This commit is contained in:
waltje
2018-10-26 19:47:54 -04:00
parent 28fa98e69d
commit 9f7c03482b
2 changed files with 22 additions and 30 deletions

View File

@@ -11,7 +11,7 @@
* This code is called by the UI frontend modules, and, also, * This code is called by the UI frontend modules, and, also,
* depends on those same modules for lower-level functions. * depends on those same modules for lower-level functions.
* *
* Version: @(#)ui_main.c 1.0.19 2018/10/16 * Version: @(#)ui_main.c 1.0.20 2018/10/26
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -346,8 +346,6 @@ main_reset_all(void)
void void
ui_reset(void) ui_reset(void)
{ {
int i;
/* Maybe the underlying (platform) UI has to rebuild. */ /* Maybe the underlying (platform) UI has to rebuild. */
ui_plat_reset(); ui_plat_reset();
@@ -358,9 +356,7 @@ ui_reset(void)
ui_sb_reset(); ui_sb_reset();
/* Reset the mouse-capture message. */ /* Reset the mouse-capture message. */
i = mouse_capture; ui_mouse_capture(-1);
mouse_capture = !mouse_capture;
ui_mouse_capture(i);
} }
@@ -673,40 +669,33 @@ void
ui_mouse_capture(int on) ui_mouse_capture(int on)
{ {
const wchar_t *str = NULL; const wchar_t *str = NULL;
int state = mouse_capture;
/* Do not try to capture the mouse if no mouse configured. */ /* Do not try to capture the mouse if no mouse configured. */
if (mouse_type == MOUSE_NONE) return; if (mouse_type == MOUSE_NONE) return;
if ((on == 1) && !mouse_capture) { if ((on == 1) && !mouse_capture) {
/* Disable the local cursor. */ state = 1;
ui_show_cursor(0); } else if (!on && mouse_capture) {
state = 0;
}
if (state != mouse_capture) {
/* State changed. */
plat_mouse_capture(state);
ui_show_cursor(!state);
mouse_capture = state;
}
if (state) {
if (mouse_get_buttons() > 2) if (mouse_get_buttons() > 2)
str = get_string(IDS_MSG_MRLS_1); str = get_string(IDS_MSG_MRLS_1);
else else
str = get_string(IDS_MSG_MRLS_2); str = get_string(IDS_MSG_MRLS_2);
} else {
/* Enable and clip the in-app mouse. */
plat_mouse_capture(1);
/* We got the mouse. */
mouse_capture = 1;
} else if ((on == -1) || (!on && mouse_capture)) {
/* Unclip the in-app mouse. */
if (! on) {
plat_mouse_capture(0);
/* Restore the local cursor. */
ui_show_cursor(1);
}
str = get_string(IDS_MSG_CAPTURE); str = get_string(IDS_MSG_CAPTURE);
/* We (no longer) have the mouse. */
mouse_capture = 0;
} }
/* Set the correct message on the status bar. */ /* Set the correct message on the status bar. */
if (str != NULL)
ui_sb_text_set_w(SB_TEXT, str); ui_sb_text_set_w(SB_TEXT, str);
} }

View File

@@ -8,7 +8,7 @@
* *
* Implementation of the Settings dialog. * Implementation of the Settings dialog.
* *
* Version: @(#)win_settings.c 1.0.37 2018/10/25 * Version: @(#)win_settings.c 1.0.38 2018/10/26
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -755,9 +755,12 @@ dlg_settings(int ask)
int i; int i;
#ifdef USE_MANAGER #ifdef USE_MANAGER
if (source_hwnd) if (source_hwnd) {
pc_pause(1);
PostMessage((HWND) (uintptr_t) source_hwnd, PostMessage((HWND) (uintptr_t) source_hwnd,
WM_SEND_SSTATUS, (WPARAM)1, (LPARAM)hwndMain; WM_SEND_SSTATUS, (WPARAM)1, (LPARAM)hwndMain;
}
#endif #endif
/* /*