Index: src/console_gui.cpp =================================================================== --- src/console_gui.cpp (revision 14250) +++ src/console_gui.cpp (working copy) @@ -165,6 +165,11 @@ ClrBit(_no_scroll, SCROLL_CON); } + virtual bool IsQueryWindow() + { + return true; + } + virtual void OnPaint() { int max = (this->height / ICON_LINE_HEIGHT) - 1; Index: src/genworld_gui.cpp =================================================================== --- src/genworld_gui.cpp (revision 14250) +++ src/genworld_gui.cpp (working copy) @@ -265,6 +265,11 @@ this->FindWindowPlacementAndResize(desc); } + virtual bool IsQueryWindow() + { + return true; + } + virtual void OnPaint() { /* You can't select smoothness if not terragenesis */ Index: src/misc_gui.cpp =================================================================== --- src/misc_gui.cpp (revision 14250) +++ src/misc_gui.cpp (working copy) @@ -1487,6 +1487,11 @@ ClrBit(_no_scroll, SCROLL_SAVE); } + virtual bool IsQueryWindow() + { + return true; + } + virtual void OnPaint() { int y; Index: src/network/network_chat_gui.cpp =================================================================== --- src/network/network_chat_gui.cpp (revision 14250) +++ src/network/network_chat_gui.cpp (working copy) @@ -425,6 +425,11 @@ free(pre_buf); } + virtual bool IsQueryWindow() + { + return true; + } + virtual void OnPaint() { static const StringID chat_captions[] = { Index: src/network/network_gui.cpp =================================================================== --- src/network/network_gui.cpp (revision 14250) +++ src/network/network_gui.cpp (working copy) @@ -1767,6 +1767,11 @@ this->FindWindowPlacementAndResize(desc); } + virtual bool IsQueryWindow() + { + return true; + } + void OnOk() { if (this->IsWidgetLowered(NCPWW_SAVE_AS_DEFAULT_PASSWORD)) { Index: src/signs_gui.cpp =================================================================== --- src/signs_gui.cpp (revision 14250) +++ src/signs_gui.cpp (working copy) @@ -223,6 +223,11 @@ this->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT); } + virtual bool IsQueryWindow() + { + return true; + } + virtual void OnPaint() { SetDParam(0, this->caption); Index: src/window.cpp =================================================================== --- src/window.cpp (revision 14250) +++ src/window.cpp (working copy) @@ -1654,27 +1654,21 @@ if (key == 0 && keycode == 0) return; /* 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; + Window* const *wz; + FOR_ALL_WINDOWS(wz) { + Window *w = *wz; + if(w->IsQueryWindow()) { + query_open = true; + break; + } } /* Call the event, start with the uppermost window. */ - for (Window* const *wz = _last_z_window; wz != _z_windows;) { + for (wz = _last_z_window; wz != _z_windows;) { Window *w = *--wz; /* 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) { + if (query_open && !w->IsQueryWindow()) { continue; } if (w->OnKeyPress(key, keycode) == Window::ES_HANDLED) return; Index: src/window_gui.h =================================================================== --- src/window_gui.h (revision 14250) +++ src/window_gui.h (working copy) @@ -256,6 +256,16 @@ /*** Event handling ***/ /** + * Tell key input loop if we are a query window or not. Query + * windows get all keyboard input events so that not other + * windows can steal them such as the main toolbar etc. + * @return true if the window wants to steal key inptut focus, + * false if the window don't want to steal key input focus. + */ + virtual bool IsQueryWindow() { return false; } + + + /** * This window is currently being repainted. */ virtual void OnPaint() {}