diff --git a/src/viewport.cpp b/src/viewport.cpp index 84ae0c6e3e..d2e6f1b2c2 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1951,6 +1951,8 @@ static void PlaceObject() bool HandleViewportClicked(const ViewPort *vp, int x, int y) { + if (_move_pressed) return false; + const Vehicle *v = CheckClickOnVehicle(vp, x, y); if (_thd.place_mode & HT_VEHICLE) { @@ -2923,7 +2925,6 @@ EventState VpHandlePlaceSizingDrag() place_mouseup: w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); - return ES_HANDLED; } diff --git a/src/window.cpp b/src/window.cpp index 6fd8cf3377..905c2fa7d7 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2437,7 +2437,9 @@ static EventState HandleViewportScroll() * outside of the window and should not left-mouse scroll anymore. */ if (_last_scroll_window == NULL) _last_scroll_window = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); - if (_last_scroll_window == NULL || !(_right_button_down || scrollwheel_scrolling || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down))) { + + if (_last_scroll_window == NULL || !(_right_button_down || scrollwheel_scrolling || + (_left_button_down && (_move_pressed || _settings_client.gui.left_mouse_btn_scrolling)))) { _cursor.fix_at = false; _scrolling_viewport = false; _last_scroll_window = NULL; @@ -2827,6 +2829,12 @@ static void MouseLoop(MouseClick click, int mousewheel) * But there is no company related window open anyway, so _current_company is not used. */ assert(HasModalProgress() || IsLocalCompany()); + int x = _cursor.pos.x; + int y = _cursor.pos.y; + Window *w = FindWindowFromPt(x, y); + if (w == NULL) return; + ViewPort *vp = IsPtInWindowViewport(w, x, y); + HandlePlacePresize(); UpdateTileSelection(); @@ -2841,13 +2849,9 @@ static void MouseLoop(MouseClick click, int mousewheel) bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling) return; - int x = _cursor.pos.x; - int y = _cursor.pos.y; - Window *w = FindWindowFromPt(x, y); if (w == NULL) return; - if (click != MC_HOVER && !MaybeBringWindowToFront(w)) return; - ViewPort *vp = IsPtInWindowViewport(w, x, y); + if (click != MC_NONE && click != MC_HOVER && !MaybeBringWindowToFront(w)) return; /* Don't allow any action in a viewport if either in menu or when having a modal progress window */ if (vp != NULL && (_game_mode == GM_MENU || HasModalProgress())) return; @@ -2868,7 +2872,7 @@ static void MouseLoop(MouseClick click, int mousewheel) DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); if (!HandleViewportClicked(vp, x, y) && !(w->flags & WF_DISABLE_VP_SCROLL) && - _settings_client.gui.left_mouse_btn_scrolling) { + (_settings_client.gui.left_mouse_btn_scrolling || _move_pressed)) { _scrolling_viewport = true; _cursor.fix_at = false; }