From 6c70cf2d82cac252b9e48d53e70aaeb15f7b9ad6 Mon Sep 17 00:00:00 2001 From: belugas Date: Thu, 6 Dec 2007 15:58:39 +0000 Subject: (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly. A better solution will be deviced, but not now. Let's not cause a ton of bug reports --- src/console.cpp | 2 +- src/genworld_gui.cpp | 6 +++--- src/misc_gui.cpp | 6 +++--- src/network/network_gui.cpp | 4 ++-- src/newgrf_gui.cpp | 2 +- src/signs_gui.cpp | 2 +- src/window.cpp | 24 ++++++++++++++++++++++-- src/window.h | 2 +- 8 files changed, 34 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/console.cpp b/src/console.cpp index 5af02f243..78f6f1143 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -202,7 +202,7 @@ static const Widget _iconsole_window_widgets[] = { static const WindowDesc _iconsole_window_desc = { 0, 0, 2, 2, 2, 2, WC_CONSOLE, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _iconsole_window_widgets, IConsoleWndProc, }; diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index f5088cd27..4da42dab7 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -512,7 +512,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e) static const WindowDesc _generate_landscape_desc = { WDP_CENTER, WDP_CENTER, 338, 268, 338, 268, WC_GENERATE_LANDSCAPE, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _generate_landscape_widgets, GenerateLandscapeWndProc, }; @@ -520,7 +520,7 @@ static const WindowDesc _generate_landscape_desc = { static const WindowDesc _heightmap_load_desc = { WDP_CENTER, WDP_CENTER, 338, 236, 338, 236, WC_GENERATE_LANDSCAPE, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, _heightmap_load_widgets, GenerateLandscapeWndProc, }; @@ -745,7 +745,7 @@ static const Widget _create_scenario_widgets[] = { static const WindowDesc _create_scenario_desc = { WDP_CENTER, WDP_CENTER, 338, 170, 338, 170, WC_GENERATE_LANDSCAPE, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, _create_scenario_widgets, CreateScenarioWndProc, }; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 0c4fae48b..b6b698cfb 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1180,7 +1180,7 @@ static const Widget _query_string_widgets[] = { static const WindowDesc _query_string_desc = { 190, 219, 260, 42, 260, 42, WC_QUERY_STRING, WC_NONE, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, _query_string_widgets, QueryStringWndProc }; @@ -1648,7 +1648,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) static const WindowDesc _load_dialog_desc = { WDP_CENTER, WDP_CENTER, 257, 154, 257, 294, WC_SAVELOAD, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, _load_dialog_widgets, SaveLoadDlgWndProc, }; @@ -1656,7 +1656,7 @@ static const WindowDesc _load_dialog_desc = { static const WindowDesc _save_dialog_desc = { WDP_CENTER, WDP_CENTER, 257, 180, 257, 320, WC_SAVELOAD, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, _save_dialog_widgets, SaveLoadDlgWndProc, }; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index f4ab5747f..5e5cdfb9c 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1852,7 +1852,7 @@ static const Widget _chat_window_widgets[] = { static const WindowDesc _chat_window_desc = { WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height WC_SEND_NETWORK_MSG, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, _chat_window_widgets, ChatWindowWndProc }; @@ -1951,7 +1951,7 @@ static const Widget _ncp_window_widgets[] = { static const WindowDesc _ncp_window_desc = { WDP_AUTO, WDP_AUTO, 300, 63, 300, 63, WC_COMPANY_PASSWORD_WINDOW, WC_NONE, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _ncp_window_widgets, NetworkCompanyPasswordWindowWndProc }; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index a58ee4096..cc731e7c1 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -235,7 +235,7 @@ static const Widget _newgrf_add_dlg_widgets[] = { static const WindowDesc _newgrf_add_dlg_desc = { WDP_CENTER, WDP_CENTER, 307, 237, 307, 337, WC_SAVELOAD, WC_NONE, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, _newgrf_add_dlg_widgets, NewGRFAddDlgWndProc, }; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index e148ccf28..81b7abd93 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -298,7 +298,7 @@ static const Widget _query_sign_edit_widgets[] = { static const WindowDesc _query_sign_edit_desc = { 190, 170, 260, 42, 260, 42, WC_QUERY_STRING, WC_NONE, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_TEXTENTRY, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, _query_sign_edit_widgets, QuerySignEditWndProc }; diff --git a/src/window.cpp b/src/window.cpp index b20ae4b68..33063fbeb 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1676,6 +1676,10 @@ void HandleKeypress(uint32 key) { Window* const *wz; WindowEvent e; + /* Stores if a window with a textfield for typing is open + * If this is the case, keypress events are only passed to windows with text fields and + * to thein this main toolbar. */ + bool query_open = false; /* * During the generation of the world, there might be @@ -1694,12 +1698,28 @@ void HandleKeypress(uint32 key) e.we.keypress.keycode = GB(key, 16, 16); e.we.keypress.cont = true; + /* check if we have a query string window open before allowing hotkeys */ + if (FindWindowById(WC_QUERY_STRING, 0) != NULL || + FindWindowById(WC_SEND_NETWORK_MSG, 0) != NULL || + FindWindowById(WC_GENERATE_LANDSCAPE, 0) != NULL || + FindWindowById(WC_CONSOLE, 0) != NULL || + FindWindowById(WC_SAVELOAD, 0) != NULL || + FindWindowById(WC_COMPANY_PASSWORD_WINDOW, 0) != NULL) { + query_open = true; + } + /* Call the event, start with the uppermost window. */ for (wz = _last_z_window; wz != _z_windows;) { Window *w = *--wz; - /* Only call the event for the windows declared as been text entry enabled */ - if (!(w->desc_flags & WDF_TEXTENTRY)) { + /* if a query window is open, only call the event for certain window types */ + if (query_open && + w->window_class != WC_QUERY_STRING && + w->window_class != WC_SEND_NETWORK_MSG && + w->window_class != WC_GENERATE_LANDSCAPE && + w->window_class != WC_CONSOLE && + w->window_class != WC_SAVELOAD && + w->window_class != WC_COMPANY_PASSWORD_WINDOW) { continue; } w->wndproc(w, &e); diff --git a/src/window.h b/src/window.h index a84943d21..e98d99d24 100644 --- a/src/window.h +++ b/src/window.h @@ -208,7 +208,7 @@ enum WindowDefaultFlag { WDF_STD_TOOLTIPS = 1 << 0, ///< use standard routine when displaying tooltips WDF_DEF_WIDGET = 1 << 1, ///< default widget control for some widgets in the on click event WDF_STD_BTN = 1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1) - WDF_TEXTENTRY = 1 << 3, ///< This window is authorized to receive keyboard events + WDF_UNCLICK_BUTTONS = 1 << 4, ///< Unclick buttons when the window event times out */ WDF_STICKY_BUTTON = 1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) WDF_RESIZABLE = 1 << 6, ///< A window can be resized -- cgit v1.2.3-54-g00ecf