summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2017-03-24 18:55:16 +0000
committerpeter1138 <peter1138@openttd.org>2017-03-24 18:55:16 +0000
commitd934ef9b003c3e084ab77acec554f4870c1a3727 (patch)
treed043baa6e1e6f62bbf696fd6c46b31620c11024f /src/window.cpp
parent2385f4adbc174f9e23ebffd828999f1b2b22424a (diff)
downloadopenttd-d934ef9b003c3e084ab77acec554f4870c1a3727.tar.xz
(svn r27825) -Feature [FS#4950]: Add option to close windows with right click (Flamefire)
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/window.cpp b/src/window.cpp
index f1c53f204..272361285 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -772,7 +772,15 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
if (w->OnRightClick(pt, wid->index)) return;
}
- if (_settings_client.gui.hover_delay_ms == 0 && wid->tool_tip != 0) GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
+ /* Right-click close is enabled and there is a closebox */
+ if (_settings_client.gui.right_mouse_wnd_close && w->nested_root->GetWidgetOfType(WWT_CLOSEBOX))
+ {
+ delete w;
+ }
+ else if (_settings_client.gui.hover_delay_ms == 0 && wid->tool_tip != 0)
+ {
+ GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
+ }
}
/**
@@ -2825,11 +2833,12 @@ static void MouseLoop(MouseClick click, int mousewheel)
switch (click) {
case MC_DOUBLE_LEFT:
case MC_LEFT:
- if (!HandleViewportClicked(vp, x, y) &&
- !(w->flags & WF_DISABLE_VP_SCROLL) &&
+ if (HandleViewportClicked(vp, x, y)) return;
+ if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
_settings_client.gui.left_mouse_btn_scrolling) {
_scrolling_viewport = true;
_cursor.fix_at = false;
+ return;
}
break;
@@ -2841,13 +2850,16 @@ static void MouseLoop(MouseClick click, int mousewheel)
/* clear 2D scrolling caches before we start a 2D scroll */
_cursor.h_wheel = 0;
_cursor.v_wheel = 0;
+ return;
}
break;
default:
break;
}
- } else {
+ }
+
+ if (vp == NULL || (w->flags & WF_DISABLE_VP_SCROLL)) {
switch (click) {
case MC_LEFT:
case MC_DOUBLE_LEFT: