diff --git a/src/preferences/input/InputMouse.cpp b/src/preferences/input/InputMouse.cpp index 26cda7ead9..1cbf2dcdb4 100644 --- a/src/preferences/input/InputMouse.cpp +++ b/src/preferences/input/InputMouse.cpp @@ -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); } diff --git a/src/preferences/input/MouseSettings.cpp b/src/preferences/input/MouseSettings.cpp index 1212ef262e..fe69a69346 100644 --- a/src/preferences/input/MouseSettings.cpp +++ b/src/preferences/input/MouseSettings.cpp @@ -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; diff --git a/src/preferences/input/SettingsView.cpp b/src/preferences/input/SettingsView.cpp index 53426079b1..b6a3210e98 100644 --- a/src/preferences/input/SettingsView.cpp +++ b/src/preferences/input/SettingsView.cpp @@ -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); diff --git a/src/preferences/input/SettingsView.h b/src/preferences/input/SettingsView.h index 1c5115aa08..ee3e97dde5 100644 --- a/src/preferences/input/SettingsView.h +++ b/src/preferences/input/SettingsView.h @@ -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;