Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to let the wheel follow the selected editor #475

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading