Input server and preferences: clean up
Remove compatibility with legacy settings format. The preferences app doesn't need to read and save the settings file: devices are enumerated and their properties retrieved from the input_server. When something changes, the input_server updates the data. Change-Id: Id1ea6f2532a1c8a173e9ba9818dd911fd6f4aa10 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7877 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
f00e314e57
commit
85e84ddefb
@@ -32,6 +32,12 @@ typedef struct {
|
||||
bigtime_t click_speed;
|
||||
} mouse_settings;
|
||||
|
||||
static const bigtime_t kDefaultClickSpeed = 500000;
|
||||
static const int32 kDefaultMouseSpeed = 65536;
|
||||
static const int32 kDefaultMouseType = 3; // 3 button mouse
|
||||
static const int32 kDefaultAccelerationFactor = 65536;
|
||||
static const bool kDefaultAcceptFirstClick = true;
|
||||
|
||||
#define mouse_settings_file "Mouse_settings"
|
||||
|
||||
#endif /* _KB_MOUSE_SETTINGS_H */
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
#include <GroupLayoutBuilder.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputDeviceView.h"
|
||||
#include "InputTouchpadPrefView.h"
|
||||
#include "InputWindow.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "MouseView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
|
||||
#include "InputMouse.h"
|
||||
#include "InputIcons.h"
|
||||
#include "InputWindow.h"
|
||||
#include "MouseSettings.h"
|
||||
|
||||
|
||||
class SettingsView;
|
||||
class MouseSettings;
|
||||
|
||||
class InputApplication : public BApplication {
|
||||
public:
|
||||
InputApplication();
|
||||
|
||||
@@ -11,15 +11,10 @@
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <DateFormat.h>
|
||||
#include <Input.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ListView.h>
|
||||
#include <Locale.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringItem.h>
|
||||
|
||||
#include "InputIcons.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "DeviceList"
|
||||
|
||||
@@ -11,29 +11,16 @@
|
||||
#define _INPUT_DEVICE_VIEW_H
|
||||
|
||||
#include <ListItem.h>
|
||||
#include <ListView.h>
|
||||
#include <Message.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringItem.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "InputIcons.h"
|
||||
#include "InputTouchpadPref.h"
|
||||
#include "MouseSettings.h"
|
||||
|
||||
|
||||
#define ITEM_SELECTED 'I1s'
|
||||
|
||||
#define kITEM_MARGIN 1
|
||||
#define GREATER_THAN -1
|
||||
#define LESS_THAN 1
|
||||
|
||||
|
||||
class InputIcons;
|
||||
class TouchpadPref;
|
||||
class MouseSettings;
|
||||
|
||||
enum input_type {
|
||||
MOUSE_TYPE,
|
||||
|
||||
@@ -11,13 +11,11 @@
|
||||
#define INPUT_KEYBOARD_H
|
||||
|
||||
#include <Button.h>
|
||||
#include <Window.h>
|
||||
#include <Input.h>
|
||||
|
||||
#include "InputDeviceView.h"
|
||||
#include "KeyboardSettings.h"
|
||||
#include "KeyboardView.h"
|
||||
|
||||
class DeviceListView;
|
||||
|
||||
class InputKeyboard : public BView
|
||||
{
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
|
||||
#include "InputMouse.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
@@ -19,18 +16,10 @@
|
||||
#include <Debug.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Screen.h>
|
||||
#include <Slider.h>
|
||||
#include <StringView.h>
|
||||
#include <TabView.h>
|
||||
#include <SeparatorView.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "InputWindow.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "MouseView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
@@ -157,7 +146,7 @@ InputMouse::MessageReceived(BMessage* message)
|
||||
int32 value;
|
||||
if (message->FindInt32("be:value", &value) == B_OK) {
|
||||
// slow = 1000000, fast = 0
|
||||
fSettings->SetClickSpeed(value * 1000);
|
||||
fSettings->SetClickSpeed(1000000LL - value * 1000);
|
||||
fDefaultsButton->SetEnabled(fSettings->IsDefaultable());
|
||||
fRevertButton->SetEnabled(fSettings->IsRevertable());
|
||||
}
|
||||
|
||||
@@ -11,18 +11,11 @@
|
||||
#define INPUT_MOUSE_H
|
||||
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <ListView.h>
|
||||
#include <MenuField.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Slider.h>
|
||||
#include <TabView.h>
|
||||
#include <Input.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "InputDeviceView.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "MouseView.h"
|
||||
#include "SettingsView.h"
|
||||
|
||||
@@ -8,25 +8,22 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Alignment.h>
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <CardLayout.h>
|
||||
#include <CardView.h>
|
||||
#include <Catalog.h>
|
||||
#include <Control.h>
|
||||
#include <ControlLook.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Screen.h>
|
||||
#include <SplitView.h>
|
||||
#include <ScrollView.h>
|
||||
|
||||
#include <private/input/InputServerTypes.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "InputDeviceView.h"
|
||||
#include "InputKeyboard.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputTouchpadPref.h"
|
||||
#include "InputTouchpadPrefView.h"
|
||||
#include "InputWindow.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "SettingsView.h"
|
||||
|
||||
@@ -11,39 +11,13 @@
|
||||
#define INPUT_WINDOW_H
|
||||
|
||||
|
||||
#include <Box.h>
|
||||
#include <CardView.h>
|
||||
#include <Input.h>
|
||||
#include <ListItem.h>
|
||||
#include <ListView.h>
|
||||
#include <Message.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputDeviceView.h"
|
||||
#include "InputKeyboard.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputTouchpadPrefView.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "touchpad_settings.h"
|
||||
|
||||
|
||||
class BSplitView;
|
||||
class BCardView;
|
||||
class BCardLayout;
|
||||
|
||||
class SettingsView;
|
||||
class DeviceName;
|
||||
class InputDevices;
|
||||
class InputKeyboard;
|
||||
class InputMouse;
|
||||
class MultipleMouseSettings;
|
||||
class TouchpadPrefView;
|
||||
class TouchpadPref;
|
||||
class TouchpadView;
|
||||
|
||||
|
||||
class InputWindow : public BWindow
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
#include "KeyboardSettings.h"
|
||||
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -69,7 +66,7 @@ KeyboardSettings::Defaults()
|
||||
|
||||
|
||||
bool
|
||||
KeyboardSettings::IsDefaultable()
|
||||
KeyboardSettings::IsDefaultable() const
|
||||
{
|
||||
return fSettings.key_repeat_delay != kb_default_key_repeat_delay
|
||||
|| fSettings.key_repeat_rate != kb_default_key_repeat_rate;
|
||||
|
||||
@@ -23,7 +23,7 @@ public :
|
||||
|
||||
void Revert();
|
||||
void Defaults();
|
||||
bool IsDefaultable();
|
||||
bool IsDefaultable() const;
|
||||
|
||||
int32 KeyboardRepeatRate() const
|
||||
{ return fSettings.key_repeat_rate; }
|
||||
|
||||
@@ -12,17 +12,14 @@
|
||||
#include "KeyboardView.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <Slider.h>
|
||||
#include <TextControl.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "KeyboardSettings.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "KeyboardView"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define KEYBOARD_VIEW_H
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <GroupView.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Slider.h>
|
||||
|
||||
@@ -18,17 +18,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// The R5 settings file differs from that of Haiku;
|
||||
// the latter maps 16 different mouse buttons
|
||||
#define R5_COMPATIBLE 0
|
||||
|
||||
static const bigtime_t kDefaultClickSpeed = 500000;
|
||||
static const int32 kDefaultMouseSpeed = 65536;
|
||||
static const int32 kDefaultMouseType = 3; // 3 button mouse
|
||||
static const int32 kDefaultAccelerationFactor = 65536;
|
||||
static const bool kDefaultAcceptFirstClick = true;
|
||||
|
||||
|
||||
MouseSettings::MouseSettings(BString name)
|
||||
:
|
||||
fName(name)
|
||||
@@ -43,48 +32,11 @@ MouseSettings::MouseSettings(BString name)
|
||||
}
|
||||
|
||||
|
||||
MouseSettings::MouseSettings(mouse_settings settings, BString name)
|
||||
:
|
||||
fSettings(settings)
|
||||
{
|
||||
fName = name;
|
||||
|
||||
#ifdef DEBUG
|
||||
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;
|
||||
fOriginalAcceptFirstClick = fAcceptFirstClick;
|
||||
}
|
||||
|
||||
|
||||
MouseSettings::~MouseSettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::_GetSettingsPath(BPath& path)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
path.Append(mouse_settings_file);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::_RetrieveSettings()
|
||||
{
|
||||
@@ -108,73 +60,6 @@ MouseSettings::_RetrieveSettings()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::_LoadLegacySettings()
|
||||
{
|
||||
BPath path;
|
||||
if (_GetSettingsPath(path) < B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
if (file.InitCheck() < B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
// Read the settings from the file
|
||||
file.Read((void*)&fSettings, sizeof(mouse_settings));
|
||||
|
||||
#ifdef DEBUG
|
||||
Dump();
|
||||
#endif
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
MouseSettings::Dump()
|
||||
{
|
||||
printf("type:\t\t%" B_PRId32 " button mouse\n", fSettings.type);
|
||||
for (int i = 0; i < 5; i++)
|
||||
printf("button[%d]: %" B_PRId32 "\n", i, fSettings.map.button[i]);
|
||||
printf("click speed:\t%" B_PRId64 "\n", fSettings.click_speed);
|
||||
printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled");
|
||||
printf("accel factor:\t%" B_PRId32 "\n", fSettings.accel.accel_factor);
|
||||
printf("speed:\t\t%" B_PRId32 "\n", fSettings.accel.speed);
|
||||
|
||||
const char* mode = "unknown";
|
||||
switch (fMode) {
|
||||
case B_NORMAL_MOUSE:
|
||||
mode = "click to focus and raise";
|
||||
break;
|
||||
case B_CLICK_TO_FOCUS_MOUSE:
|
||||
mode = "click to focus";
|
||||
break;
|
||||
case B_FOCUS_FOLLOWS_MOUSE:
|
||||
mode = "focus follows mouse";
|
||||
break;
|
||||
}
|
||||
printf("mouse mode:\t%s\n", mode);
|
||||
|
||||
const char* focus_follows_mouse_mode = "unknown";
|
||||
switch (fFocusFollowsMouseMode) {
|
||||
case B_NORMAL_FOCUS_FOLLOWS_MOUSE:
|
||||
focus_follows_mouse_mode = "normal";
|
||||
break;
|
||||
case B_WARP_FOCUS_FOLLOWS_MOUSE:
|
||||
focus_follows_mouse_mode = "warp";
|
||||
break;
|
||||
case B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE:
|
||||
focus_follows_mouse_mode = "instant warp";
|
||||
break;
|
||||
}
|
||||
printf("focus follows mouse mode:\t%s\n", focus_follows_mouse_mode);
|
||||
printf("accept first click:\t%s\n",
|
||||
fAcceptFirstClick ? "enabled" : "disabled");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Resets the settings to the system defaults
|
||||
void
|
||||
MouseSettings::Defaults()
|
||||
@@ -203,7 +88,7 @@ MouseSettings::Defaults()
|
||||
|
||||
// Checks if the settings are different then the system defaults
|
||||
bool
|
||||
MouseSettings::IsDefaultable()
|
||||
MouseSettings::IsDefaultable() const
|
||||
{
|
||||
return fSettings.click_speed != kDefaultClickSpeed
|
||||
|| fSettings.accel.speed != kDefaultMouseSpeed
|
||||
@@ -239,7 +124,7 @@ MouseSettings::Revert()
|
||||
|
||||
// Checks if the settings are different then the original settings
|
||||
bool
|
||||
MouseSettings::IsRevertable()
|
||||
MouseSettings::IsRevertable() const
|
||||
{
|
||||
return fSettings.click_speed != fOriginalSettings.click_speed
|
||||
|| fSettings.accel.speed != fOriginalSettings.accel.speed
|
||||
@@ -268,16 +153,13 @@ MouseSettings::SetMouseType(int32 type)
|
||||
bigtime_t
|
||||
MouseSettings::ClickSpeed() const
|
||||
{
|
||||
return 1000000LL - fSettings.click_speed;
|
||||
// to correct the Sliders 0-100000 scale
|
||||
return fSettings.click_speed;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MouseSettings::SetClickSpeed(bigtime_t clickSpeed)
|
||||
{
|
||||
clickSpeed = 1000000LL - clickSpeed;
|
||||
|
||||
if (set_click_speed(clickSpeed) == B_OK)
|
||||
fSettings.click_speed = clickSpeed;
|
||||
}
|
||||
@@ -362,169 +244,27 @@ MouseSettings::GetSettings()
|
||||
|
||||
MultipleMouseSettings::MultipleMouseSettings()
|
||||
{
|
||||
fDeprecatedMouseSettings = NULL;
|
||||
RetrieveSettings();
|
||||
|
||||
#ifdef DEBUG
|
||||
Dump();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
MultipleMouseSettings::~MultipleMouseSettings()
|
||||
{
|
||||
SaveSettings();
|
||||
|
||||
#ifdef DEBUG
|
||||
Dump();
|
||||
#endif
|
||||
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end();
|
||||
++itr)
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
delete fDeprecatedMouseSettings;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MultipleMouseSettings::GetSettingsPath(BPath& path)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
path.Append(mouse_settings_file);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MultipleMouseSettings::RetrieveSettings()
|
||||
{
|
||||
// retrieve current values
|
||||
// also try to load the window position from disk
|
||||
|
||||
BPath path;
|
||||
if (GetSettingsPath(path) < B_OK)
|
||||
return;
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
if (file.InitCheck() < B_OK)
|
||||
return;
|
||||
|
||||
BMessage message;
|
||||
|
||||
if (message.Unflatten(&file) == B_OK) {
|
||||
int i = 0;
|
||||
BString deviceName;
|
||||
mouse_settings* settings;
|
||||
ssize_t size = 0;
|
||||
|
||||
while (message.FindString("mouseDevice", i, &deviceName) == B_OK) {
|
||||
message.FindData(
|
||||
"mouseSettings", B_ANY_TYPE, i, (const void**)&settings, &size);
|
||||
MouseSettings* mouseSettings
|
||||
= new MouseSettings(*settings, deviceName);
|
||||
fMouseSettingsObject.insert(
|
||||
std::pair<BString, MouseSettings*>(deviceName, mouseSettings));
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
// Does not look like a BMessage, try loading using the old format
|
||||
fDeprecatedMouseSettings = new MouseSettings("");
|
||||
if (fDeprecatedMouseSettings->_LoadLegacySettings() != B_OK) {
|
||||
delete fDeprecatedMouseSettings;
|
||||
fDeprecatedMouseSettings = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MultipleMouseSettings::Archive(BMessage* into, bool deep) const
|
||||
{
|
||||
std::map<BString, MouseSettings*>::const_iterator itr;
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end();
|
||||
++itr) {
|
||||
into->AddString("mouseDevice", itr->first);
|
||||
into->AddData("mouseSettings", B_ANY_TYPE, itr->second->GetSettings(),
|
||||
sizeof(*(itr->second->GetSettings())));
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MultipleMouseSettings::SaveSettings()
|
||||
{
|
||||
BPath path;
|
||||
status_t status = GetSettingsPath(path);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
status = file.InitCheck();
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
BMessage message;
|
||||
Archive(&message, true);
|
||||
message.Flatten(&file);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MultipleMouseSettings::Defaults()
|
||||
{
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end();
|
||||
++itr) {
|
||||
itr->second->Defaults();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
MultipleMouseSettings::Dump()
|
||||
{
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end();
|
||||
++itr) {
|
||||
printf("mouse_name:\t%s\n", itr->first.String());
|
||||
itr->second->Dump();
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
MouseSettings*
|
||||
MultipleMouseSettings::AddMouseSettings(BString mouse_name)
|
||||
{
|
||||
if (fDeprecatedMouseSettings != NULL) {
|
||||
MouseSettings* RetrievedSettings = new(std::nothrow) MouseSettings(
|
||||
*(fDeprecatedMouseSettings->GetSettings()), mouse_name);
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
itr = fMouseSettingsObject.find(mouse_name);
|
||||
|
||||
if (RetrievedSettings != NULL) {
|
||||
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*>(
|
||||
mouse_name, RetrievedSettings));
|
||||
if (itr != fMouseSettingsObject.end())
|
||||
return itr->second;
|
||||
|
||||
return RetrievedSettings;
|
||||
}
|
||||
}
|
||||
|
||||
MouseSettings* settings = GetMouseSettings(mouse_name);
|
||||
if (settings)
|
||||
return settings;
|
||||
|
||||
settings = new(std::nothrow) MouseSettings(mouse_name);
|
||||
MouseSettings* settings = new(std::nothrow) MouseSettings(mouse_name);
|
||||
if (settings == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -532,15 +272,3 @@ MultipleMouseSettings::AddMouseSettings(BString mouse_name)
|
||||
std::pair<BString, MouseSettings*>(mouse_name, settings));
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
MouseSettings*
|
||||
MultipleMouseSettings::GetMouseSettings(BString mouse_name)
|
||||
{
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
itr = fMouseSettingsObject.find(mouse_name);
|
||||
|
||||
if (itr != fMouseSettingsObject.end())
|
||||
return itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Archivable.h>
|
||||
#include <Input.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Point.h>
|
||||
#include <String.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
@@ -28,14 +24,12 @@ class BPath;
|
||||
class MouseSettings {
|
||||
public:
|
||||
MouseSettings(BString name);
|
||||
MouseSettings(mouse_settings settings, BString name);
|
||||
~MouseSettings();
|
||||
|
||||
void Revert();
|
||||
bool IsRevertable();
|
||||
bool IsRevertable() const;
|
||||
void Defaults();
|
||||
bool IsDefaultable();
|
||||
void Dump();
|
||||
bool IsDefaultable() const;
|
||||
|
||||
int32 MouseType() const { return fSettings.type; }
|
||||
void SetMouseType(int32 type);
|
||||
@@ -64,13 +58,11 @@ public:
|
||||
|
||||
bool AcceptFirstClick() const { return fAcceptFirstClick; }
|
||||
void SetAcceptFirstClick(bool accept_first_click);
|
||||
status_t _RetrieveSettings();
|
||||
status_t _LoadLegacySettings();
|
||||
|
||||
mouse_settings* GetSettings();
|
||||
|
||||
private:
|
||||
static status_t _GetSettingsPath(BPath &path);
|
||||
status_t _RetrieveSettings();
|
||||
|
||||
private:
|
||||
BString fName;
|
||||
@@ -84,30 +76,15 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class MultipleMouseSettings: public BArchivable
|
||||
class MultipleMouseSettings
|
||||
{
|
||||
public:
|
||||
MultipleMouseSettings();
|
||||
~MultipleMouseSettings();
|
||||
|
||||
status_t Archive(BMessage* into, bool deep = false) const;
|
||||
|
||||
void Defaults();
|
||||
void Dump();
|
||||
status_t SaveSettings();
|
||||
|
||||
/** Get or create settings for the given mouse */
|
||||
MouseSettings* AddMouseSettings(BString mouse_name);
|
||||
/** Get the existing settings, or return NULL */
|
||||
MouseSettings* GetMouseSettings(BString mouse_name);
|
||||
|
||||
private:
|
||||
static status_t GetSettingsPath(BPath &path);
|
||||
void RetrieveSettings();
|
||||
|
||||
private:
|
||||
MouseSettings* fDeprecatedMouseSettings;
|
||||
|
||||
typedef std::map<BString, MouseSettings*> mouse_settings_object;
|
||||
mouse_settings_object fMouseSettingsObject;
|
||||
};
|
||||
|
||||
@@ -7,25 +7,17 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "InputMouse.h"
|
||||
#include "SettingsView.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Debug.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <Slider.h>
|
||||
#include <TextControl.h>
|
||||
#include <TranslationUtils.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "MouseSettings.h"
|
||||
@@ -186,7 +178,7 @@ SettingsView::MouseMapUpdated()
|
||||
void
|
||||
SettingsView::UpdateFromSettings()
|
||||
{
|
||||
int32 value = int32(fSettings.ClickSpeed() / 1000);
|
||||
int32 value = int32((1000000LL - fSettings.ClickSpeed()) / 1000);
|
||||
// slow = 1000000, fast = 0
|
||||
fClickSpeedSlider->SetValue(value);
|
||||
|
||||
|
||||
@@ -11,12 +11,9 @@
|
||||
#define SETTINGS_VIEW_H
|
||||
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <OptionPopUp.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Slider.h>
|
||||
|
||||
|
||||
|
||||
@@ -19,14 +19,6 @@
|
||||
#include <View.h>
|
||||
|
||||
|
||||
static const bigtime_t kDefaultClickSpeed = 500000;
|
||||
static const int32 kDefaultMouseSpeed = 65536;
|
||||
static const int32 kDefaultMouseType = 3; // 3 button mouse
|
||||
static const int32 kDefaultAccelerationFactor = 65536;
|
||||
static const bool kDefaultAcceptFirstClick = true;
|
||||
|
||||
|
||||
|
||||
MouseSettings::MouseSettings()
|
||||
{
|
||||
Defaults();
|
||||
@@ -34,30 +26,24 @@ MouseSettings::MouseSettings()
|
||||
#ifdef DEBUG
|
||||
Dump();
|
||||
#endif
|
||||
|
||||
fOriginalSettings = fSettings;
|
||||
fOriginalMode = fMode;
|
||||
fOriginalFocusFollowsMouseMode = fFocusFollowsMouseMode;
|
||||
fOriginalAcceptFirstClick = fAcceptFirstClick;
|
||||
}
|
||||
|
||||
|
||||
MouseSettings::MouseSettings(mouse_settings* originalSettings)
|
||||
MouseSettings::MouseSettings(const mouse_settings* originalSettings)
|
||||
{
|
||||
Defaults();
|
||||
fMode = mouse_mode();
|
||||
fAcceptFirstClick = accept_first_click();
|
||||
|
||||
fOriginalSettings = *originalSettings;
|
||||
fSettings = *originalSettings;
|
||||
if (originalSettings != NULL) {
|
||||
fMode = mouse_mode();
|
||||
fFocusFollowsMouseMode = focus_follows_mouse_mode();
|
||||
fAcceptFirstClick = accept_first_click();
|
||||
|
||||
fSettings = *originalSettings;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Dump();
|
||||
#endif
|
||||
|
||||
fOriginalMode = fMode;
|
||||
fOriginalFocusFollowsMouseMode = fFocusFollowsMouseMode;
|
||||
fOriginalAcceptFirstClick = fAcceptFirstClick;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,49 +52,6 @@ MouseSettings::~MouseSettings()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::GetSettingsPath(BPath &path)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
path.Append(mouse_settings_file);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MouseSettings::RetrieveSettings()
|
||||
{
|
||||
// retrieve current values
|
||||
|
||||
fMode = mouse_mode();
|
||||
fAcceptFirstClick = accept_first_click();
|
||||
Defaults();
|
||||
|
||||
// also try to load the window position from disk
|
||||
|
||||
BPath path;
|
||||
if (GetSettingsPath(path) < B_OK)
|
||||
return;
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
if (file.InitCheck() < B_OK)
|
||||
return;
|
||||
|
||||
if (file.ReadAt(0, &fSettings, sizeof(mouse_settings))
|
||||
!= sizeof(mouse_settings)) {
|
||||
Defaults();
|
||||
}
|
||||
|
||||
if ((fSettings.click_speed == 0)
|
||||
|| (fSettings.type == 0)) {
|
||||
Defaults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
MouseSettings::Dump()
|
||||
@@ -264,7 +207,6 @@ MouseSettings::SetAcceptFirstClick(bool acceptFirstClick)
|
||||
|
||||
MultipleMouseSettings::MultipleMouseSettings()
|
||||
{
|
||||
fDeprecatedMouseSettings = NULL;
|
||||
RetrieveSettings();
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -282,11 +224,8 @@ MultipleMouseSettings::~MultipleMouseSettings()
|
||||
#endif
|
||||
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end();
|
||||
++itr)
|
||||
for (itr = fMouseSettingsObject.begin(); itr != fMouseSettingsObject.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
delete fDeprecatedMouseSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -329,9 +268,6 @@ MultipleMouseSettings::RetrieveSettings()
|
||||
(deviceName, mouseSettings));
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
fDeprecatedMouseSettings = new MouseSettings();
|
||||
fDeprecatedMouseSettings->RetrieveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,25 +338,11 @@ MultipleMouseSettings::Dump()
|
||||
MouseSettings*
|
||||
MultipleMouseSettings::AddMouseSettings(BString mouse_name)
|
||||
{
|
||||
if(fDeprecatedMouseSettings != NULL) {
|
||||
MouseSettings* RetrievedSettings = new (std::nothrow) MouseSettings
|
||||
(*fDeprecatedMouseSettings);
|
||||
MouseSettings* settings = GetMouseSettings(mouse_name);
|
||||
if (settings != NULL)
|
||||
return settings;
|
||||
|
||||
if (RetrievedSettings != NULL) {
|
||||
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*>
|
||||
(mouse_name, RetrievedSettings));
|
||||
|
||||
return RetrievedSettings;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<BString, MouseSettings*>::iterator itr;
|
||||
itr = fMouseSettingsObject.find(mouse_name);
|
||||
|
||||
if (itr != fMouseSettingsObject.end())
|
||||
return GetMouseSettings(mouse_name);
|
||||
|
||||
MouseSettings* settings = new (std::nothrow) MouseSettings();
|
||||
settings = new(std::nothrow) MouseSettings();
|
||||
|
||||
if(settings != NULL) {
|
||||
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
class MouseSettings {
|
||||
public:
|
||||
MouseSettings();
|
||||
MouseSettings(mouse_settings* originalSettings);
|
||||
MouseSettings(const mouse_settings* originalSettings);
|
||||
~MouseSettings();
|
||||
|
||||
void Defaults();
|
||||
@@ -65,23 +65,16 @@ class MouseSettings {
|
||||
bool AcceptFirstClick() const { return fAcceptFirstClick; }
|
||||
void SetAcceptFirstClick(bool acceptFirstClick);
|
||||
|
||||
void RetrieveSettings();
|
||||
status_t SaveSettings();
|
||||
|
||||
const mouse_settings* GetSettings() { return &fSettings; }
|
||||
|
||||
private:
|
||||
static status_t GetSettingsPath(BPath &path);
|
||||
|
||||
mouse_settings fSettings, fOriginalSettings;
|
||||
mouse_settings fSettings;
|
||||
|
||||
// FIXME all these extra settings are not specific to each mouse.
|
||||
// They should be moved into MultipleMouseSettings directly
|
||||
mode_mouse fMode, fOriginalMode;
|
||||
mode_mouse fMode;
|
||||
mode_focus_follows_mouse fFocusFollowsMouseMode;
|
||||
mode_focus_follows_mouse fOriginalFocusFollowsMouseMode;
|
||||
bool fAcceptFirstClick;
|
||||
bool fOriginalAcceptFirstClick;
|
||||
};
|
||||
|
||||
|
||||
@@ -104,8 +97,6 @@ class MultipleMouseSettings: public BArchivable {
|
||||
static status_t GetSettingsPath(BPath &path);
|
||||
void RetrieveSettings();
|
||||
|
||||
MouseSettings* fDeprecatedMouseSettings;
|
||||
|
||||
typedef std::map<BString, MouseSettings*> mouse_settings_object;
|
||||
mouse_settings_object fMouseSettingsObject;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user