Input preferences: fix selection of focus mode
- Replace the popup menu with a BOptionPopUp to simplify the code - Remove an unused menu to select "warp mode" - The focus mode is not stored in the mouse settings file (config/settings_Mouse_settings), it is in another file (config/settings/system/app_server/mouse). This file is not read or written directly by mouse preferences, but we get the settings by asking app_server. However, the code to get these was missing in one place, resulting in these settings not being correctly initialized. Fixes #16524 Change-Id: Ia1efc235c9d1a5408e3c6abc2526da7a0a639fa4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3796 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
a59f6b7a8c
commit
ace584913d
@ -107,12 +107,10 @@ InputMouse::MessageReceived(BMessage* message)
|
||||
case kMsgMouseFocusMode:
|
||||
{
|
||||
int32 mode;
|
||||
if (message->FindInt32("mode", &mode) == B_OK) {
|
||||
if (message->FindInt32("be:value", &mode) == B_OK) {
|
||||
fSettings->SetMouseMode((mode_mouse)mode);
|
||||
fDefaultsButton->SetEnabled(fSettings->IsDefaultable());
|
||||
fRevertButton->SetEnabled(fSettings->IsRevertable());
|
||||
fSettingsView->fFocusFollowsMouseMenu->SetEnabled(
|
||||
mode == B_FOCUS_FOLLOWS_MOUSE);
|
||||
fSettingsView->fAcceptFirstClickBox->SetEnabled(
|
||||
mode != B_FOCUS_FOLLOWS_MOUSE);
|
||||
}
|
||||
|
@ -53,6 +53,14 @@ MouseSettings::MouseSettings(mouse_settings settings, BString name)
|
||||
Dump();
|
||||
#endif
|
||||
|
||||
// These are not stored in mouse_settings, get the current values from
|
||||
// app_server
|
||||
// FIXME these should be moved out of the MouseSettings class, since they
|
||||
// are not specific to each mouse, but are global settings.
|
||||
fMode = mouse_mode();
|
||||
fFocusFollowsMouseMode = focus_follows_mouse_mode();
|
||||
fAcceptFirstClick = accept_first_click();
|
||||
|
||||
fOriginalSettings = fSettings;
|
||||
fOriginalMode = fMode;
|
||||
fOriginalFocusFollowsMouseMode = fFocusFollowsMouseMode;
|
||||
|
@ -32,36 +32,6 @@
|
||||
#include "MouseView.h"
|
||||
|
||||
|
||||
static int32
|
||||
mouse_mode_to_index(mode_mouse mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case B_NORMAL_MOUSE:
|
||||
default:
|
||||
return 0;
|
||||
case B_CLICK_TO_FOCUS_MOUSE:
|
||||
return 1;
|
||||
case B_FOCUS_FOLLOWS_MOUSE:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
focus_follows_mouse_mode_to_index(mode_focus_follows_mouse mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case B_NORMAL_FOCUS_FOLLOWS_MOUSE:
|
||||
default:
|
||||
return 0;
|
||||
case B_WARP_FOCUS_FOLLOWS_MOUSE:
|
||||
return 1;
|
||||
case B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
@ -115,48 +85,20 @@ SettingsView::SettingsView(MouseSettings& settings)
|
||||
BSize(StringWidth(label), B_SIZE_UNSET));
|
||||
|
||||
// Add the "Mouse focus mode" pop up menu
|
||||
fFocusMenu = new BPopUpMenu(B_TRANSLATE("Click to focus and raise"));
|
||||
fFocusMenu = new BOptionPopUp("focus_mode", B_TRANSLATE("Focus mode:"),
|
||||
new BMessage(kMsgMouseFocusMode));
|
||||
|
||||
const char *focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"),
|
||||
B_TRANSLATE_MARK("Click to focus"),
|
||||
B_TRANSLATE_MARK("Focus follows mouse")};
|
||||
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE,
|
||||
B_FOCUS_FOLLOWS_MOUSE};
|
||||
B_FOCUS_FOLLOWS_MOUSE};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
BMessage* message = new BMessage(kMsgMouseFocusMode);
|
||||
message->AddInt32("mode", focusModes[i]);
|
||||
|
||||
fFocusMenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(focusLabels[i]),
|
||||
message));
|
||||
for (int i = 0; i < B_COUNT_OF(focusModes); i++) {
|
||||
fFocusMenu->AddOption(B_TRANSLATE_NOCOLLECT(focusLabels[i]),
|
||||
focusModes[i]);
|
||||
}
|
||||
|
||||
BMenuField* focusField = new BMenuField(B_TRANSLATE("Focus mode:"),
|
||||
fFocusMenu);
|
||||
focusField->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
// Add the "Focus follows mouse mode" pop up menu
|
||||
fFocusFollowsMouseMenu = new BPopUpMenu(B_TRANSLATE("Normal"));
|
||||
|
||||
const char *focusFollowsMouseLabels[] = {B_TRANSLATE_MARK("Normal"),
|
||||
B_TRANSLATE_MARK("Warp"), B_TRANSLATE_MARK("Instant warp")};
|
||||
const mode_focus_follows_mouse focusFollowsMouseModes[]
|
||||
= {B_NORMAL_FOCUS_FOLLOWS_MOUSE, B_WARP_FOCUS_FOLLOWS_MOUSE,
|
||||
B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
BMessage* message = new BMessage(kMsgFollowsMouseMode);
|
||||
message->AddInt32("mode_focus_follows_mouse",
|
||||
focusFollowsMouseModes[i]);
|
||||
|
||||
fFocusFollowsMouseMenu->AddItem(new BMenuItem(
|
||||
B_TRANSLATE_NOCOLLECT(focusFollowsMouseLabels[i]), message));
|
||||
}
|
||||
|
||||
BMenuField* focusFollowsMouseField = new BMenuField(
|
||||
"Focus follows mouse mode:", fFocusFollowsMouseMenu);
|
||||
focusFollowsMouseField->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
// Add the "Click-through" check box
|
||||
fAcceptFirstClickBox = new BCheckBox(B_TRANSLATE("Accept first click"),
|
||||
new BMessage(kMsgAcceptFirstClick));
|
||||
@ -202,7 +144,7 @@ SettingsView::SettingsView(MouseSettings& settings)
|
||||
|
||||
// Horizontal Block C: focus mode
|
||||
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
|
||||
.Add(focusField)
|
||||
.Add(fFocusMenu)
|
||||
.AddGlue()
|
||||
.AddGroup(B_VERTICAL, 0)
|
||||
.Add(fAcceptFirstClickBox)
|
||||
@ -260,18 +202,7 @@ SettingsView::UpdateFromSettings()
|
||||
fTypeMenu->SelectOptionFor(fSettings.MouseType());
|
||||
fMouseView->SetMouseType(fSettings.MouseType());
|
||||
|
||||
BMenuItem* item = fFocusMenu->ItemAt(
|
||||
mouse_mode_to_index(fSettings.MouseMode()));
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
|
||||
item = fFocusFollowsMouseMenu->ItemAt(
|
||||
focus_follows_mouse_mode_to_index(fSettings.FocusFollowsMouseMode()));
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
|
||||
fFocusFollowsMouseMenu->SetEnabled(fSettings.MouseMode()
|
||||
== B_FOCUS_FOLLOWS_MOUSE);
|
||||
fFocusMenu->SelectOptionFor(fSettings.MouseMode());
|
||||
|
||||
fAcceptFirstClickBox->SetValue(fSettings.AcceptFirstClick()
|
||||
? B_CONTROL_ON : B_CONTROL_OFF);
|
||||
|
@ -37,7 +37,6 @@ class SettingsView : public BBox {
|
||||
|
||||
public:
|
||||
// FIXME use proper getters/setters for this?
|
||||
BPopUpMenu* fFocusFollowsMouseMenu;
|
||||
BCheckBox* fAcceptFirstClickBox;
|
||||
|
||||
private:
|
||||
@ -46,7 +45,7 @@ class SettingsView : public BBox {
|
||||
const MouseSettings& fSettings;
|
||||
|
||||
BOptionPopUp* fTypeMenu;
|
||||
BPopUpMenu* fFocusMenu;
|
||||
BOptionPopUp* fFocusMenu;
|
||||
MouseView* fMouseView;
|
||||
BSlider* fClickSpeedSlider;
|
||||
BSlider* fMouseSpeedSlider;
|
||||
|
Loading…
Reference in New Issue
Block a user