Skip to content

Commit

Permalink
Fix to let the wheel follow the selected editor (#475)
Browse files Browse the repository at this point in the history
* Fix to let the wheel follow the selected editor

* Fix spacing, cast

---------

Co-authored-by: Jackburton79 <stefano.ceccherini@gmail.com>
  • Loading branch information
Freaxed and jackburton79 authored Jan 28, 2025
1 parent bb1ac98 commit 14e195e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ LIBS += git2
LIBS += src/scintilla/bin/libscintilla.a
LIBS += yaml-cpp
LIBS += editorconfig
LIBS += game

SYSTEM_INCLUDE_PATHS = $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface)
SYSTEM_INCLUDE_PATHS += $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/shared)
Expand Down
26 changes: 23 additions & 3 deletions src/helpers/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Resources.h>
#include <Roster.h>
#include <SystemCatalog.h>
#include <WindowScreen.h>

#include <algorithm>
#include <string>
Expand All @@ -34,6 +35,24 @@ using BPrivate::gSystemCatalog;
#define B_TRANSLATION_CONTEXT "Utilities"


void
FakeMouseMovement(BView* view)
{
// This is mostly due to a limition of the app_server:
// the wheel mouse message is always target to the view with the last mouse movement.
// in case a view appear under the mouse without any movement (ALT+TAB on a .cpp to open the .h)
// the wheel is moving the wrong scrollbars (no matter of the focus).
// the workaround is to fake a mouse movement to update the view under the cursor when an
// Editor is selected.
//
BPoint location;
uint32 buttons = 0;
view->GetMouse(&location, &buttons);
view->ConvertToScreen(&location);
set_mouse_position(location.x, location.y);
}


std::string
GetFileName(const std::string filename)
{
Expand Down Expand Up @@ -64,8 +83,8 @@ GetVectorIcon(const std::string icon, BBitmap* bitmap)

BResources* resources = BApplication::AppResources();
size_t size;
const uint8* rawIcon;
rawIcon = (const uint8*)resources->LoadResource(B_VECTOR_ICON_TYPE, icon.c_str(), &size);
const uint8* rawIcon = reinterpret_cast<const uint8*>(
resources->LoadResource(B_VECTOR_ICON_TYPE, icon.c_str(), &size));
if (rawIcon == nullptr)
return B_ERROR;

Expand Down Expand Up @@ -206,7 +225,8 @@ KeyDownMessageFilter::Filter(BMessage* message, BHandler** target)

template<>
entry_ref
find_value<B_REF_TYPE>(BMessage* message, std::string name, int index) {
find_value<B_REF_TYPE>(BMessage* message, std::string name, int index)
{
entry_ref ref;
status_t status = message->FindRef(name.c_str(), index, &ref);
if(status == B_OK) {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BRadioButton;

struct entry_ref;

void FakeMouseMovement(BView* view);

std::string GetFileName(const std::string filename);
std::string GetFileExtension(const std::string filename);
Expand Down
1 change: 1 addition & 0 deletions src/ui/GenioWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ GenioWindow::MessageReceived(BMessage* message)
}

editor->GrabFocus();
FakeMouseMovement(editor);
_UpdateTabChange(editor, "TABMANAGER_TAB_SELECTED");

BMessage tabSelectedNotice(MSG_NOTIFY_EDITOR_FILE_SELECTED);
Expand Down

0 comments on commit 14e195e

Please sign in to comment.