* added click to focus mouse mode; right-click for bring-to-front and send-to-back

(might cause some regressions in FFM)
* made accept first click user configurable
* updated the Mouse preflet to use the layout kit
* removed the warp and instant warp modes from the Mouse preflet
* changed internal representation of mouse modes (warp modes moved)
* coding style fixes



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Brecht Machiels
2009-10-22 21:10:19 +00:00
parent 9c90fc59d2
commit 926e63c885
27 changed files with 1033 additions and 611 deletions
+14 -3
View File
@@ -160,9 +160,14 @@ struct mouse_map {
enum mode_mouse { enum mode_mouse {
B_NORMAL_MOUSE = 0, B_NORMAL_MOUSE = 0,
B_FOCUS_FOLLOWS_MOUSE = 1, B_CLICK_TO_FOCUS_MOUSE = -1,
B_WARP_MOUSE = 3, B_FOCUS_FOLLOWS_MOUSE = 1
B_INSTANT_WARP_MOUSE = 7 };
enum mode_focus_follows_mouse {
B_NORMAL_FOCUS_FOLLOWS_MOUSE = 0,
B_WARP_FOCUS_FOLLOWS_MOUSE = 1,
B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE = 2
}; };
@@ -372,6 +377,12 @@ bool focus_follows_mouse();
void set_mouse_mode(mode_mouse mode); void set_mouse_mode(mode_mouse mode);
mode_mouse mouse_mode(); mode_mouse mouse_mode();
void set_focus_follows_mouse_mode(mode_focus_follows_mouse mode);
mode_focus_follows_mouse focus_follows_mouse_mode();
void set_accept_first_click(bool acceptFirstClick);
bool accept_first_click();
rgb_color ui_color(color_which which); rgb_color ui_color(color_which which);
void set_ui_color(const color_which& which, const rgb_color& color); void set_ui_color(const color_which& which, const rgb_color& color);
rgb_color tint_color(rgb_color color, float tint); rgb_color tint_color(rgb_color color, float tint);
+4
View File
@@ -195,6 +195,10 @@ enum {
AS_IDLE_TIME, AS_IDLE_TIME,
AS_SET_MOUSE_MODE, AS_SET_MOUSE_MODE,
AS_GET_MOUSE_MODE, AS_GET_MOUSE_MODE,
AS_SET_FOCUS_FOLLOWS_MOUSE_MODE,
AS_GET_FOCUS_FOLLOWS_MOUSE_MODE,
AS_SET_ACCEPT_FIRST_CLICK,
AS_GET_ACCEPT_FIRST_CLICK,
AS_GET_MOUSE, AS_GET_MOUSE,
AS_SET_DECORATOR_SETTINGS, AS_SET_DECORATOR_SETTINGS,
AS_GET_DECORATOR_SETTINGS, AS_GET_DECORATOR_SETTINGS,
+80 -17
View File
@@ -100,7 +100,8 @@ namespace BPrivate {
Returns \c true if the mode is known. Returns \c true if the mode is known.
*/ */
bool bool
get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace) get_mode_parameter(uint32 mode, int32& width, int32& height,
uint32& colorSpace)
{ {
switch (mode) { switch (mode) {
case B_8_BIT_640x480: case B_8_BIT_640x480:
@@ -456,7 +457,8 @@ set_mouse_map(mouse_map *map)
BMessage command(IS_SET_MOUSE_MAP); BMessage command(IS_SET_MOUSE_MAP);
BMessage reply; BMessage reply;
status_t err = command.AddData("mousemap", B_RAW_TYPE, map, sizeof(mouse_map)); status_t err = command.AddData("mousemap", B_RAW_TYPE, map,
sizeof(mouse_map));
if (err != B_OK) if (err != B_OK)
return err; return err;
return _control_input_server_(&command, &reply); return _control_input_server_(&command, &reply);
@@ -652,12 +654,14 @@ _get_key_map(key_map **map, char **key_buffer, ssize_t *key_buffer_size)
_control_input_server_(&command, &reply); _control_input_server_(&command, &reply);
if (reply.FindData("keymap", B_ANY_TYPE, &map_array, &map_count) != B_OK) { if (reply.FindData("keymap", B_ANY_TYPE, &map_array, &map_count)
!= B_OK) {
*map = 0; *key_buffer = 0; *map = 0; *key_buffer = 0;
return; return;
} }
if (reply.FindData("key_buffer", B_ANY_TYPE, &key_array, key_buffer_size) != B_OK) { if (reply.FindData("key_buffer", B_ANY_TYPE, &key_array, key_buffer_size)
!= B_OK) {
*map = 0; *key_buffer = 0; *map = 0; *key_buffer = 0;
return; return;
} }
@@ -852,14 +856,14 @@ void
set_focus_follows_mouse(bool follow) set_focus_follows_mouse(bool follow)
{ {
// obviously deprecated API // obviously deprecated API
set_mouse_mode(B_WARP_MOUSE); set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE);
} }
bool bool
focus_follows_mouse() focus_follows_mouse()
{ {
return mouse_mode() != B_NORMAL_MOUSE; return mouse_mode() == B_FOCUS_FOLLOWS_MOUSE;
} }
@@ -876,7 +880,8 @@ set_mouse_mode(mode_mouse mode)
mode_mouse mode_mouse
mouse_mode() mouse_mode()
{ {
// Gets the focus-follows-mouse style, such as normal, B_WARP_MOUSE, etc. // Gets the mouse focus style, such as activate to click,
// focus to click, ...
mode_mouse mode = B_NORMAL_MOUSE; mode_mouse mode = B_NORMAL_MOUSE;
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
@@ -890,6 +895,58 @@ mouse_mode()
} }
void
set_focus_follows_mouse_mode(mode_focus_follows_mouse mode)
{
BPrivate::AppServerLink link;
link.StartMessage(AS_SET_FOCUS_FOLLOWS_MOUSE_MODE);
link.Attach<mode_focus_follows_mouse>(mode);
link.Flush();
}
mode_focus_follows_mouse
focus_follows_mouse_mode()
{
mode_focus_follows_mouse mode = B_NORMAL_FOCUS_FOLLOWS_MOUSE;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FOCUS_FOLLOWS_MOUSE_MODE);
int32 code;
if (link.FlushWithReply(code) == B_OK && code == B_OK)
link.Read<mode_focus_follows_mouse>(&mode);
return mode;
}
void
set_accept_first_click(bool acceptFirstClick)
{
BPrivate::AppServerLink link;
link.StartMessage(AS_SET_ACCEPT_FIRST_CLICK);
link.Attach<bool>(acceptFirstClick);
link.Flush();
}
bool
accept_first_click()
{
// Gets the accept first click status
bool acceptFirstClick = false;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_ACCEPT_FIRST_CLICK);
int32 code;
if (link.FlushWithReply(code) == B_OK && code == B_OK)
link.Read<bool>(&acceptFirstClick);
return accept_first_click;
}
rgb_color rgb_color
ui_color(color_which which) ui_color(color_which which)
{ {
@@ -900,7 +957,8 @@ ui_color(color_which which)
} }
if (be_app) { if (be_app) {
server_read_only_memory* shared = BApplication::Private::ServerReadOnlyMemory(); server_read_only_memory* shared
= BApplication::Private::ServerReadOnlyMemory();
return shared->colors[index]; return shared->colors[index];
} }
@@ -1079,7 +1137,8 @@ get_decorator(void)
/*! /*!
\brief queries the server for the name of the decorator with a certain index \brief queries the server for the name of the decorator with a certain
index
\param index The index of the decorator to get the name for \param index The index of the decorator to get the name for
\param name BString to receive the name of the decorator \param name BString to receive the name of the decorator
\return B_OK if successful, B_ERROR if not \return B_OK if successful, B_ERROR if not
@@ -1323,8 +1382,8 @@ truncate_end(const char* source, char* dest, uint32 numChars,
const float* escapementArray, float width, float ellipsisWidth, float size) const float* escapementArray, float width, float ellipsisWidth, float size)
{ {
float currentWidth = 0.0; float currentWidth = 0.0;
ellipsisWidth /= size; // test if this is as accurate as escapementArray * size ellipsisWidth /= size; // test if this is as accurate
width /= size; width /= size; // as escapementArray * size
uint32 lastFit = 0, c; uint32 lastFit = 0, c;
for (c = 0; c < numChars; c++) { for (c = 0; c < numChars; c++) {
@@ -1378,7 +1437,8 @@ copy_from_end(const char* src, char* dst, uint32 numChars, uint32 length,
currentWidth += ellipsisWidth; currentWidth += ellipsisWidth;
// go forward again until ellipsis fits (already beyond the target) // go forward again until ellipsis fits (already beyond the target)
for (uint32 c2 = c; c2 < numChars; c2++) { for (uint32 c2 = c; c2 < numChars; c2++) {
//printf(" backward: %c (%ld) (%.1f - %.1f = %.1f)\n", *dst, c2, currentWidth, escapementArray[c2] * size, currentWidth - escapementArray[c2] * size); //printf(" backward: %c (%ld) (%.1f - %.1f = %.1f)\n", *dst, c2, currentWidth, escapementArray[c2] * size,
// currentWidth - escapementArray[c2] * size);
currentWidth -= escapementArray[c2] * size; currentWidth -= escapementArray[c2] * size;
do { do {
src++; src++;
@@ -1411,7 +1471,8 @@ truncate_middle(const char* source, char* dest, uint32 numChars,
uint32 left = 0; uint32 left = 0;
float leftWidth = 0.0; float leftWidth = 0.0;
while (left < numChars && (leftWidth + (escapementArray[left] * size)) < mid) while (left < numChars && (leftWidth + (escapementArray[left] * size))
< mid)
leftWidth += (escapementArray[left++] * size); leftWidth += (escapementArray[left++] * size);
if (left == numChars) if (left == numChars)
@@ -1419,7 +1480,8 @@ truncate_middle(const char* source, char* dest, uint32 numChars,
float rightWidth = 0.0; float rightWidth = 0.0;
uint32 right = numChars; uint32 right = numChars;
while (right > left && (rightWidth + (escapementArray[right - 1] * size)) < mid) while (right > left && (rightWidth + (escapementArray[right - 1] * size))
< mid)
rightWidth += (escapementArray[--right] * size); rightWidth += (escapementArray[--right] * size);
if (left >= right) if (left >= right)
@@ -1490,7 +1552,8 @@ truncate_string(const char* string, uint32 mode, float width,
char* result, const float* escapementArray, float fontSize, char* result, const float* escapementArray, float fontSize,
float ellipsisWidth, int32 length, int32 numChars) float ellipsisWidth, int32 length, int32 numChars)
{ {
// TODO: that's actually not correct: the string could be smaller than ellipsisWidth // TODO: that's actually not correct: the string could be smaller than
// ellipsisWidth
if (string == NULL /*|| width < ellipsisWidth*/) { if (string == NULL /*|| width < ellipsisWidth*/) {
// we don't have room for a single glyph // we don't have room for a single glyph
strcpy(result, ""); strcpy(result, "");
@@ -1540,8 +1603,8 @@ truncate_string(const char* string, uint32 mode, float width,
// FALL THROUGH (at least do something) // FALL THROUGH (at least do something)
case B_TRUNCATE_MIDDLE: case B_TRUNCATE_MIDDLE:
default: default:
truncated = truncate_middle(source, dest, numChars, escapementArray, truncated = truncate_middle(source, dest, numChars,
width, ellipsisWidth, fontSize); escapementArray, width, ellipsisWidth, fontSize);
break; break;
} }
+12 -4
View File
@@ -24,6 +24,7 @@
#include <binary_compatibility/Interface.h> #include <binary_compatibility/Interface.h>
#include <MenuPrivate.h> #include <MenuPrivate.h>
#include <TokenSpace.h> #include <TokenSpace.h>
#include <InterfaceDefs.h>
#include "BMCPrivate.h" #include "BMCPrivate.h"
@@ -337,10 +338,17 @@ BMenuBar::MouseDown(BPoint where)
if (fTracking) if (fTracking)
return; return;
BWindow* window = Window(); uint32 buttons;
if (!window->IsActive() || !window->IsFront()) { GetMouse(&where, &buttons);
window->Activate();
window->UpdateIfNeeded(); BWindow* window = Window();
if (!window->IsActive() || !window->IsFront()) {
if ((mouse_mode() == B_FOCUS_FOLLOWS_MOUSE)
|| ((mouse_mode() == B_CLICK_TO_FOCUS_MOUSE)
&& ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0))) {
window->Activate();
window->UpdateIfNeeded();
}
} }
StartMenuBar(-1, false, false); StartMenuBar(-1, false, false);
+3
View File
@@ -6,6 +6,7 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#ifndef MOUSE_CONSTANTS_H #ifndef MOUSE_CONSTANTS_H
#define MOUSE_CONSTANTS_H #define MOUSE_CONSTANTS_H
@@ -17,6 +18,8 @@ const uint32 kMsgRevert = 'BTre';
const uint32 kMsgMouseType = 'PUmt'; const uint32 kMsgMouseType = 'PUmt';
const uint32 kMsgMouseFocusMode = 'PUmf'; const uint32 kMsgMouseFocusMode = 'PUmf';
const uint32 kMsgFollowsMouseMode = 'PUff';
const uint32 kMsgAcceptFirstClick = 'PUaf';
const uint32 kMsgMouseMap = 'PUmm'; const uint32 kMsgMouseMap = 'PUmm';
const uint32 kMsgDoubleClickSpeed = 'SLdc'; const uint32 kMsgDoubleClickSpeed = 'SLdc';
+48 -8
View File
@@ -6,9 +6,9 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#include <FindDirectory.h> #include <FindDirectory.h>
#include <File.h> #include <File.h>
#include <Path.h> #include <Path.h>
@@ -18,7 +18,6 @@
#include "MouseSettings.h" #include "MouseSettings.h"
// The R5 settings file differs from that of OpenBeOS; // The R5 settings file differs from that of OpenBeOS;
// the latter maps 16 different mouse buttons // the latter maps 16 different mouse buttons
#define R5_COMPATIBLE 1 #define R5_COMPATIBLE 1
@@ -27,6 +26,7 @@ static const bigtime_t kDefaultClickSpeed = 500000;
static const int32 kDefaultMouseSpeed = 65536; static const int32 kDefaultMouseSpeed = 65536;
static const int32 kDefaultMouseType = 3; // 3 button mouse static const int32 kDefaultMouseType = 3; // 3 button mouse
static const int32 kDefaultAccelerationFactor = 65536; static const int32 kDefaultAccelerationFactor = 65536;
static const bool kDefaultAcceptFirstClick = false;
MouseSettings::MouseSettings() MouseSettings::MouseSettings()
@@ -37,6 +37,8 @@ MouseSettings::MouseSettings()
fOriginalSettings = fSettings; fOriginalSettings = fSettings;
fOriginalMode = fMode; fOriginalMode = fMode;
fOriginalFocusFollowsMouseMode = fFocusFollowsMouseMode;
fOriginalAcceptFirstClick = fAcceptFirstClick;
} }
@@ -75,6 +77,8 @@ MouseSettings::_RetrieveSettings()
fprintf(stderr, "error when get_mouse_type\n"); fprintf(stderr, "error when get_mouse_type\n");
fMode = mouse_mode(); fMode = mouse_mode();
fFocusFollowsMouseMode = focus_follows_mouse_mode();
fAcceptFirstClick = accept_first_click();
// also try to load the window position from disk // also try to load the window position from disk
@@ -151,19 +155,32 @@ MouseSettings::Dump()
char *mode = "unknown"; char *mode = "unknown";
switch (fMode) { switch (fMode) {
case B_NORMAL_MOUSE: case B_NORMAL_MOUSE:
mode = "normal"; mode = "click to activate";
break;
case B_CLICK_TO_FOCUS_MOUSE:
mode = "click to focus";
break; break;
case B_FOCUS_FOLLOWS_MOUSE: case B_FOCUS_FOLLOWS_MOUSE:
mode = "focus follows mouse"; mode = "focus follows mouse";
break; break;
case B_WARP_MOUSE: }
mode = "warp mouse"; printf("mouse mode:\t%s\n", mode);
char *focus_follows_mouse_mode = "unknown";
switch (fMode) {
case B_NORMAL_FOCUS_FOLLOWS_MOUSE:
focus_follows_mouse_mode = "normal";
break; break;
case B_INSTANT_WARP_MOUSE: case B_WARP_FOCUS_FOLLOWS_MOUSE:
mode = "instant warp mouse"; focus_follows_mouse_mode = "warp";
break;
case B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE:
focus_follows_mouse_mode = "instant warp";
break; break;
} }
printf("mode:\t\t%s\n", mode); printf("focus follows mouse mode:\t%s\n", focus_follows_mouse_mode);
printf("accept first click:\t%s\n",
fAcceptFirstClick ? "enabled" : "disabled");
} }
#endif #endif
@@ -177,6 +194,8 @@ MouseSettings::Defaults()
SetMouseType(kDefaultMouseType); SetMouseType(kDefaultMouseType);
SetAccelerationFactor(kDefaultAccelerationFactor); SetAccelerationFactor(kDefaultAccelerationFactor);
SetMouseMode(B_NORMAL_MOUSE); SetMouseMode(B_NORMAL_MOUSE);
SetFocusFollowsMouseMode(B_NORMAL_FOCUS_FOLLOWS_MOUSE);
SetAcceptFirstClick(kDefaultAcceptFirstClick);
mouse_map map; mouse_map map;
if (get_mouse_map(&map) == B_OK) { if (get_mouse_map(&map) == B_OK) {
@@ -197,6 +216,8 @@ MouseSettings::IsDefaultable()
|| fSettings.type != kDefaultMouseType || fSettings.type != kDefaultMouseType
|| fSettings.accel.accel_factor != kDefaultAccelerationFactor || fSettings.accel.accel_factor != kDefaultAccelerationFactor
|| fMode != B_NORMAL_MOUSE || fMode != B_NORMAL_MOUSE
|| fFocusFollowsMouseMode != B_NORMAL_FOCUS_FOLLOWS_MOUSE
|| fAcceptFirstClick != kDefaultAcceptFirstClick
|| fSettings.map.button[0] != B_PRIMARY_MOUSE_BUTTON || fSettings.map.button[0] != B_PRIMARY_MOUSE_BUTTON
|| fSettings.map.button[1] != B_SECONDARY_MOUSE_BUTTON || fSettings.map.button[1] != B_SECONDARY_MOUSE_BUTTON
|| fSettings.map.button[2] != B_TERTIARY_MOUSE_BUTTON; || fSettings.map.button[2] != B_TERTIARY_MOUSE_BUTTON;
@@ -212,6 +233,9 @@ MouseSettings::Revert()
SetMouseType(fOriginalSettings.type); SetMouseType(fOriginalSettings.type);
SetAccelerationFactor(fOriginalSettings.accel.accel_factor); SetAccelerationFactor(fOriginalSettings.accel.accel_factor);
SetMouseMode(fOriginalMode); SetMouseMode(fOriginalMode);
SetFocusFollowsMouseMode(fOriginalFocusFollowsMouseMode);
SetAcceptFirstClick(fOriginalAcceptFirstClick);
SetMapping(fOriginalSettings.map); SetMapping(fOriginalSettings.map);
} }
@@ -313,3 +337,19 @@ MouseSettings::SetMouseMode(mode_mouse mode)
fMode = mode; fMode = mode;
} }
void
MouseSettings::SetFocusFollowsMouseMode(mode_focus_follows_mouse mode)
{
set_focus_follows_mouse_mode(mode);
fFocusFollowsMouseMode = mode;
}
void
MouseSettings::SetAcceptFirstClick(bool accept_first_click)
{
set_accept_first_click(accept_first_click);
fAcceptFirstClick = accept_first_click;
}
+16 -3
View File
@@ -6,19 +6,21 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#ifndef MOUSE_SETTINGS_H #ifndef MOUSE_SETTINGS_H
#define MOUSE_SETTINGS_H #define MOUSE_SETTINGS_H
#include <InterfaceDefs.h>
#include <Point.h>
#include <SupportDefs.h>
#include "kb_mouse_settings.h" #include "kb_mouse_settings.h"
#include <SupportDefs.h>
#include <InterfaceDefs.h>
class BPath; class BPath;
class MouseSettings { class MouseSettings {
public: public:
MouseSettings(); MouseSettings();
@@ -52,6 +54,14 @@ public:
mode_mouse MouseMode() const { return fMode; } mode_mouse MouseMode() const { return fMode; }
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
mode_focus_follows_mouse FocusFollowsMouseMode() const {
return fFocusFollowsMouseMode;
}
void SetFocusFollowsMouseMode(mode_focus_follows_mouse mode);
bool AcceptFirstClick() const { return fAcceptFirstClick; }
void SetAcceptFirstClick(bool accept_first_click);
private: private:
static status_t _GetSettingsPath(BPath &path); static status_t _GetSettingsPath(BPath &path);
void _RetrieveSettings(); void _RetrieveSettings();
@@ -59,6 +69,9 @@ private:
mouse_settings fSettings, fOriginalSettings; mouse_settings fSettings, fOriginalSettings;
mode_mouse fMode, fOriginalMode; mode_mouse fMode, fOriginalMode;
mode_focus_follows_mouse fFocusFollowsMouseMode;
mode_focus_follows_mouse fOriginalFocusFollowsMouseMode;
bool fAcceptFirstClick, fOriginalAcceptFirstClick;
BPoint fWindowPosition; BPoint fWindowPosition;
}; };
+2 -3
View File
@@ -30,7 +30,6 @@
#include "MouseSettings.h" #include "MouseSettings.h"
#include "MouseWindow.h" #include "MouseWindow.h"
static const int32 kButtonTop = 6; static const int32 kButtonTop = 6;
static const int32 kMouseDownWidth = 72; static const int32 kMouseDownWidth = 72;
static const int32 kMouseDownHeight = 30; static const int32 kMouseDownHeight = 30;
@@ -86,9 +85,9 @@ getMappingNumber(int32 mapping)
// #pragma mark - // #pragma mark -
MouseView::MouseView(BRect rect, const MouseSettings &settings) MouseView::MouseView(const MouseSettings &settings)
: :
BView(rect, "mouse_view", B_FOLLOW_ALL, B_PULSE_NEEDED | B_WILL_DRAW), BView("mouse_view", B_PULSE_NEEDED | B_WILL_DRAW),
fSettings(settings), fSettings(settings),
fType(-1), fType(-1),
fButtons(0), fButtons(0),
+18 -16
View File
@@ -11,38 +11,40 @@
#define MOUSE_VIEW_H #define MOUSE_VIEW_H
#include <View.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <View.h>
class MouseSettings; class MouseSettings;
class MouseView : public BView { class MouseView : public BView {
public: public:
MouseView(BRect frame, const MouseSettings &settings); MouseView(const MouseSettings &settings);
virtual ~MouseView(); virtual ~MouseView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void Draw(BRect frame); virtual void Draw(BRect frame);
virtual void GetPreferredSize(float *_width, float *_height); virtual void GetPreferredSize(float *_width, float *_height);
void SetMouseType(int32 type); void SetMouseType(int32 type);
void MouseMapUpdated(); void MouseMapUpdated();
void UpdateFromSettings(); void UpdateFromSettings();
private: private:
int32 _ConvertFromVisualOrder(int32 button); int32 _ConvertFromVisualOrder(int32 button);
typedef BView inherited; typedef BView inherited;
const MouseSettings &fSettings; const MouseSettings &fSettings;
BBitmap *fMouseBitmap, *fMouseDownBitmap;
BRect fMouseDownBounds;
int32 fType; int32 fType;
uint32 fButtons; uint32 fButtons;
uint32 fOldButtons; uint32 fOldButtons;
}; };
#endif /* MOUSE_VIEW_H */ #endif /* MOUSE_VIEW_H */
+64 -30
View File
@@ -6,20 +6,22 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Button.h>
#include <CheckBox.h>
#include <Debug.h>
#include <Menu.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <Screen.h> #include <Screen.h>
#include <Slider.h> #include <Slider.h>
#include <Button.h>
#include <Menu.h>
#include <MenuItem.h>
#include <MenuField.h>
#include <Debug.h>
#include <string.h>
#include "MouseWindow.h" #include "MouseWindow.h"
#include "MouseConstants.h" #include "MouseConstants.h"
@@ -29,44 +31,41 @@
MouseWindow::MouseWindow(BRect _rect) MouseWindow::MouseWindow(BRect _rect)
: :
BWindow(_rect, "Mouse", B_TITLED_WINDOW, BWindow(_rect, "Mouse", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
B_AUTO_UPDATE_SIZE_LIMITS)
{ {
BView* view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view);
// Add the main settings view // Add the main settings view
fSettingsView = new SettingsView(Bounds().InsetBySelf(kBorderSpace, fSettingsView = new SettingsView(fSettings);
kBorderSpace), fSettings); fSettingsBox = new BBox("main box");
view->AddChild(fSettingsView); fSettingsBox->AddChild(fSettingsView);
// Add the "Default" button // Add the "Default" button
BRect rect(kBorderSpace, fSettingsView->Frame().bottom + kItemSpace + 2, fDefaultsButton = new BButton("Defaults", new BMessage(kMsgDefaults));
kBorderSpace + 75, fSettingsView->Frame().bottom + 20);
fDefaultsButton = new BButton(rect, "defaults", "Defaults",
new BMessage(kMsgDefaults));
fDefaultsButton->ResizeToPreferred();
fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
view->AddChild(fDefaultsButton);
// Add the "Revert" button // Add the "Revert" button
rect.OffsetBy(fDefaultsButton->Bounds().Width() + kItemSpace, 0); fRevertButton = new BButton("Revert", new BMessage(kMsgRevert));
fRevertButton = new BButton(rect, "revert", "Revert",
new BMessage(kMsgRevert));
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
fRevertButton->ResizeToPreferred();
view->AddChild(fRevertButton);
SetPulseRate(100000); SetPulseRate(100000);
// we are using the pulse rate to scan pressed mouse // we are using the pulse rate to scan pressed mouse
// buttons and draw the selected imagery // buttons and draw the selected imagery
ResizeTo(fSettingsView->Frame().right + kBorderSpace, // Build the layout
fRevertButton->Frame().bottom + kBorderSpace - 1); SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(fSettingsBox)
.AddGroup(B_HORIZONTAL, 5)
.Add(fDefaultsButton)
.Add(fRevertButton)
.AddGlue()
.End()
.SetInsets(10, 10, 10, 10)
);
// check if the window is on screen // check if the window is on screen
BRect rect = BScreen().Frame();
rect = BScreen().Frame();
rect.InsetBySelf(20, 20); rect.InsetBySelf(20, 20);
BPoint position = fSettings.WindowPosition(); BPoint position = fSettings.WindowPosition();
@@ -137,6 +136,41 @@ MouseWindow::MessageReceived(BMessage* message)
fSettings.SetMouseMode((mode_mouse)mode); fSettings.SetMouseMode((mode_mouse)mode);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(true); fRevertButton->SetEnabled(true);
fSettingsView->fFocusFollowsMouseMenu->SetEnabled(
mode == B_FOCUS_FOLLOWS_MOUSE);
fSettingsView->fAcceptFirstClickBox->SetEnabled(
mode != B_FOCUS_FOLLOWS_MOUSE);
}
break;
}
case kMsgFollowsMouseMode:
{
int32 mode;
if (message->FindInt32("mode_focus_follows_mouse", &mode)
== B_OK) {
fSettings.SetFocusFollowsMouseMode(
(mode_focus_follows_mouse)mode);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(true);
}
break;
}
case kMsgAcceptFirstClick:
{
BHandler *handler;
if (message->FindPointer("source",
reinterpret_cast<void**>(&handler)) == B_OK) {
bool acceptFirstClick = false;
BCheckBox *acceptFirstClickBox =
dynamic_cast<BCheckBox*>(handler);
if (acceptFirstClickBox)
acceptFirstClick = acceptFirstClickBox->Value()
== B_CONTROL_ON;
fSettings.SetAcceptFirstClick(acceptFirstClick);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(true);
} }
break; break;
} }
+5 -2
View File
@@ -6,18 +6,20 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#ifndef MOUSE_WINDOW_H #ifndef MOUSE_WINDOW_H
#define MOUSE_WINDOW_H #define MOUSE_WINDOW_H
#include <Window.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Window.h>
#include "MouseSettings.h" #include "MouseSettings.h"
class SettingsView;
class SettingsView;
class MouseWindow : public BWindow { class MouseWindow : public BWindow {
public: public:
@@ -31,6 +33,7 @@ private:
BButton *fDefaultsButton; BButton *fDefaultsButton;
BButton *fRevertButton; BButton *fRevertButton;
SettingsView *fSettingsView; SettingsView *fSettingsView;
BBox *fSettingsBox;
}; };
#endif /* MOUSE_WINDOW_H */ #endif /* MOUSE_WINDOW_H */
+145 -179
View File
@@ -6,23 +6,26 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#include "SettingsView.h"
#include <InterfaceDefs.h>
#include <Button.h>
#include <Box.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <TranslationUtils.h> #include <Box.h>
#include <TextControl.h> #include <Button.h>
#include <Slider.h> #include <Debug.h>
#include <PopUpMenu.h> #include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <InterfaceDefs.h>
#include <MenuField.h> #include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Debug.h> #include <PopUpMenu.h>
#include <Slider.h>
#include <TextControl.h>
#include <TranslationUtils.h>
#include <Window.h> #include <Window.h>
#include "SettingsView.h"
#include "MouseConstants.h" #include "MouseConstants.h"
#include "MouseSettings.h" #include "MouseSettings.h"
#include "MouseView.h" #include "MouseView.h"
@@ -35,12 +38,24 @@ mouse_mode_to_index(mode_mouse mode)
case B_NORMAL_MOUSE: case B_NORMAL_MOUSE:
default: default:
return 0; return 0;
case B_FOCUS_FOLLOWS_MOUSE: case B_CLICK_TO_FOCUS_MOUSE:
return 1; return 1;
case B_WARP_MOUSE: 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; return 2;
case B_INSTANT_WARP_MOUSE:
return 3;
} }
} }
@@ -48,151 +63,153 @@ mouse_mode_to_index(mode_mouse mode)
// #pragma mark - // #pragma mark -
SettingsView::SettingsView(BRect rect, MouseSettings &settings) SettingsView::SettingsView(MouseSettings &settings)
: : BBox("main_view"),
BBox(rect, "main_view"),
fSettings(settings) fSettings(settings)
{ {
ResizeToPreferred();
fDoubleClickBitmap = BTranslationUtils::GetBitmap("double_click_bmap");
fSpeedBitmap = BTranslationUtils::GetBitmap("speed_bmap");
fAccelerationBitmap = BTranslationUtils::GetBitmap("acceleration_bmap");
// Add the "Mouse Type" pop up menu // Add the "Mouse Type" pop up menu
fTypeMenu = new BPopUpMenu("unknown"); fTypeMenu = new BPopUpMenu("unknown");
fTypeMenu->AddItem(new BMenuItem("1-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("1-Button", new BMessage(kMsgMouseType)));
fTypeMenu->AddItem(new BMenuItem("2-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("2-Button", new BMessage(kMsgMouseType)));
fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType)));
BMenuField *field = new BMenuField(BRect(7, 8, 155, 190), "mouse_type", BMenuField *fTypeField = new BMenuField("Mouse type:", fTypeMenu, NULL);
"Mouse type:", fTypeMenu); fTypeField->SetAlignment(B_ALIGN_RIGHT);
field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT);
AddChild(field);
BFont font = be_plain_font;
float length = font.StringWidth("Mouse type: [3-Button]") + 20;
fLeftArea.Set(8, 7, length + 8, 198);
if (fLeftArea.Width() < 125)
fLeftArea.right = fLeftArea.left + 125;
fRightArea.Set(fLeftArea.right + 10, 11, 200, 7);
// Create the "Double-click speed slider... // Create the "Double-click speed slider...
fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed", fClickSpeedSlider = new BSlider("double_click_speed", "Double-click speed",
"Double-click speed", new BMessage(kMsgDoubleClickSpeed), 0, 1000); new BMessage(kMsgDoubleClickSpeed), 0, 1000, B_HORIZONTAL);
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fClickSpeedSlider->SetHashMarkCount(5); fClickSpeedSlider->SetHashMarkCount(5);
fClickSpeedSlider->SetLimitLabels("Slow", "Fast"); fClickSpeedSlider->SetLimitLabels("Slow", "Fast");
AddChild(fClickSpeedSlider);
length = fClickSpeedSlider->Bounds().Height() + 6;
fDoubleClickBmpPoint.y = fRightArea.top +
(length - (fDoubleClickBitmap != NULL
? fDoubleClickBitmap->Bounds().Height() : 0)) / 2;
fRightArea.top += length;
// Create the "Mouse Speed" slider... // Create the "Mouse Speed" slider...
fMouseSpeedSlider = new BSlider(fRightArea, "mouse_speed", "Mouse Speed", fMouseSpeedSlider = new BSlider("mouse_speed", "Mouse Speed",
new BMessage(kMsgMouseSpeed), 0, 1000); new BMessage(kMsgMouseSpeed), 0, 1000, B_HORIZONTAL);
fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fMouseSpeedSlider->SetHashMarkCount(7); fMouseSpeedSlider->SetHashMarkCount(7);
fMouseSpeedSlider->SetLimitLabels("Slow", "Fast"); fMouseSpeedSlider->SetLimitLabels("Slow", "Fast");
AddChild(fMouseSpeedSlider);
fSpeedBmpPoint.y = fRightArea.top +
(length - (fSpeedBitmap != NULL
? fSpeedBitmap->Bounds().Height() : 0)) / 2;
fRightArea.top += length;
// Create the "Mouse Acceleration" slider... // Create the "Mouse Acceleration" slider...
fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration", fAccelerationSlider = new BSlider("mouse_acceleration",
"Mouse Acceleration", new BMessage(kMsgAccelerationFactor), 0, 1000); "Mouse Acceleration", new BMessage(kMsgAccelerationFactor),
0, 1000, B_HORIZONTAL);
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAccelerationSlider->SetHashMarkCount(5); fAccelerationSlider->SetHashMarkCount(5);
fAccelerationSlider->SetLimitLabels("Slow", "Fast"); fAccelerationSlider->SetLimitLabels("Slow", "Fast");
AddChild(fAccelerationSlider);
fAccelerationBmpPoint.y = fRightArea.top + // Mouse image...
(length - (fAccelerationBitmap != NULL fMouseView = new MouseView(fSettings);
? fAccelerationBitmap->Bounds().Height() : 0)) / 2;
fRightArea.top += length - 3;
// Add the "Focus follows mouse" pop up menu
fFocusMenu = new BPopUpMenu("Disabled");
const char *focusLabels[] = {"Disabled", "Enabled", "Warping",
"Instant-Warping"};
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_FOCUS_FOLLOWS_MOUSE,
B_WARP_MOUSE, B_INSTANT_WARP_MOUSE};
for (int i = 0; i < 4; i++) { // Create the "Double-click test area" text box...
BTextControl *fDoubleClick = new BTextControl(NULL,
"Double-click test area", NULL);
fDoubleClick->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
// Add the "Mouse focus mode" pop up menu
fFocusMenu = new BPopUpMenu("Click to Activate");
const char *focusLabels[] = {"Click to Activate", "Click to Focus",
"Focus Follows Mouse"};
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE,
B_FOCUS_FOLLOWS_MOUSE};
for (int i = 0; i < 3; i++) {
BMessage *message = new BMessage(kMsgMouseFocusMode); BMessage *message = new BMessage(kMsgMouseFocusMode);
message->AddInt32("mode", focusModes[i]); message->AddInt32("mode", focusModes[i]);
fFocusMenu->AddItem(new BMenuItem(focusLabels[i], message)); fFocusMenu->AddItem(new BMenuItem(focusLabels[i], message));
} }
BRect frame(fRightArea.left, fRightArea.top + 10, fRightArea.left + BMenuField *fFocusField = new BMenuField("Focus mode:", fFocusMenu, NULL);
font.StringWidth("Focus follows mouse:") + fFocusField->SetAlignment(B_ALIGN_RIGHT);
font.StringWidth(focusLabels[3]) + 30, 200);
field = new BMenuField(frame, "ffm", "Focus follows mouse:", fFocusMenu, // Add the "Focus follows mouse mode" pop up menu
true); fFocusFollowsMouseMenu = new BPopUpMenu("Normal");
field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT); const char *focusFollowsMouseLabels[] = {"Normal", "Warp", "Instant Warp"};
AddChild(field); const mode_focus_follows_mouse focusFollowsMouseModes[] =
{B_NORMAL_FOCUS_FOLLOWS_MOUSE, B_WARP_FOCUS_FOLLOWS_MOUSE,
B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE};
// Finalize the areas for (int i = 0; i < 3; i++) {
fRightArea.bottom = fRightArea.top; BMessage *message = new BMessage(kMsgFollowsMouseMode);
fRightArea.top = 11; message->AddInt32("mode_focus_follows_mouse",
fRightArea.right = frame.right + 8; focusFollowsMouseModes[i]);
if (fRightArea.Width() < 200)
fRightArea.right = fRightArea.left + 200;
fLeftArea.bottom = fRightArea.bottom;
// Position mouse bitmaps fFocusFollowsMouseMenu->AddItem(new BMenuItem(
fDoubleClickBmpPoint.x = fRightArea.right - 15 focusFollowsMouseLabels[i], message));
- (fDoubleClickBitmap != NULL ? fDoubleClickBitmap->Bounds().right : 0); }
fSpeedBmpPoint.x = fRightArea.right - 15
- (fSpeedBitmap != NULL ? fSpeedBitmap->Bounds().right : 0);
fAccelerationBmpPoint.x = fRightArea.right - 15
- (fAccelerationBitmap != NULL ? fAccelerationBitmap->Bounds().right
: 0);
// Resize sliders to equal size BMenuField *fFocusFollowsMouseField = new BMenuField(
length = fRightArea.left - 5; "Focus follows mouse mode:", fFocusFollowsMouseMenu, NULL);
fClickSpeedSlider->ResizeTo(fDoubleClickBmpPoint.x - length, fFocusFollowsMouseField->SetAlignment(B_ALIGN_RIGHT);
fClickSpeedSlider->Bounds().Height());
fMouseSpeedSlider->ResizeTo(fSpeedBmpPoint.x - length,
fMouseSpeedSlider->Bounds().Height());
fAccelerationSlider->ResizeTo(fAccelerationBmpPoint.x - length,
fAccelerationSlider->Bounds().Height());
// Mouse image... // Add the "Click-through" check box
frame.Set(0, 0, 148, 162); fAcceptFirstClickBox = new BCheckBox("Accept first click",
fMouseView = new MouseView(frame, fSettings); new BMessage(kMsgAcceptFirstClick));
fMouseView->ResizeToPreferred();
fMouseView->MoveBy((fLeftArea.right - fMouseView->Bounds().Width()) / 2,
(fLeftArea.bottom - fMouseView->Bounds().Height()) / 2);
AddChild(fMouseView);
// Create the "Double-click test area" text box... // dividers
frame.Set(fLeftArea.left, fLeftArea.bottom + 10, fLeftArea.right, 0); BBox* hdivider = new BBox(
BTextControl *textControl = new BTextControl(frame, BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
"double_click_test_area", NULL, "Double-click test area", NULL); B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); hdivider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));
AddChild(textControl);
BBox* vdivider = new BBox(
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
vdivider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
ResizeTo(fRightArea.right + 5, fLeftArea.bottom + 60); // Build the layout
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.AddGroup(B_HORIZONTAL, 10)
.AddGroup(B_VERTICAL, 10, 1)
.AddGroup(B_HORIZONTAL, 10)
.AddGlue()
.Add(fTypeField)
.AddGlue()
.End()
.AddGlue()
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.AddGlue()
.Add(fMouseView)
.AddGlue()
)
.AddGlue()
.Add(fDoubleClick)
.End()
.Add(hdivider)
.AddGroup(B_VERTICAL, 5, 3)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fClickSpeedSlider)
)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fMouseSpeedSlider)
)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fAccelerationSlider)
)
.End()
.End()
.Add(vdivider)
.AddGroup(B_HORIZONTAL, 10)
.Add(fFocusField)
.AddGlue()
.AddGroup(B_VERTICAL, 0)
.Add(fAcceptFirstClickBox)
//.Add(fFocusFollowsMouseField)
.End()
.End()
.SetInsets(5, 5, 5, 5)
);
} }
SettingsView::~SettingsView() SettingsView::~SettingsView()
{ {
delete fDoubleClickBitmap;
delete fSpeedBitmap;
delete fAccelerationBitmap;
} }
@@ -203,69 +220,6 @@ SettingsView::AttachedToWindow()
} }
void
SettingsView::GetPreferredSize(float* _width, float* _height)
{
if (_width)
*_width = fRightArea.right + 5;
if (_height)
*_height = fLeftArea.bottom + 60;
}
void
SettingsView::Draw(BRect updateFrame)
{
inherited::Draw(updateFrame);
SetHighColor(120, 120, 120);
SetLowColor(255, 255, 255);
// Line above the test area
fLeft = fLeftArea.LeftBottom();
fRight = fLeftArea.RightBottom();
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.y++; fRight.y++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
// Line above focus follows mouse
fLeft = fRightArea.LeftBottom();
fRight = fRightArea.RightBottom();
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.y++; fRight.y++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
// Line in the middle
fLeft = fLeftArea.RightTop();
fRight = fLeftArea.RightBottom();
fLeft.x += 5;
fRight.x += 5;
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.x++; fRight.x++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
SetDrawingMode(B_OP_OVER);
// Draw the icons
if (fDoubleClickBitmap != NULL
&& updateFrame.Intersects(BRect(fDoubleClickBmpPoint,
fDoubleClickBmpPoint + fDoubleClickBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fDoubleClickBitmap, fDoubleClickBmpPoint);
if (fSpeedBitmap != NULL
&& updateFrame.Intersects(BRect(fSpeedBmpPoint, fSpeedBmpPoint
+ fSpeedBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fSpeedBitmap, fSpeedBmpPoint);
if (fAccelerationBitmap != NULL
&& updateFrame.Intersects(BRect(fAccelerationBmpPoint, fAccelerationBmpPoint
+ fAccelerationBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fAccelerationBitmap, fAccelerationBmpPoint);
SetDrawingMode(B_OP_COPY);
}
void void
SettingsView::SetMouseType(int32 type) SettingsView::SetMouseType(int32 type)
{ {
@@ -304,4 +258,16 @@ SettingsView::UpdateFromSettings()
item = fFocusMenu->ItemAt(mouse_mode_to_index(fSettings.MouseMode())); item = fFocusMenu->ItemAt(mouse_mode_to_index(fSettings.MouseMode()));
if (item != NULL) if (item != NULL)
item->SetMarked(true); 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);
fAcceptFirstClickBox->SetValue(fSettings.AcceptFirstClick()
? B_CONTROL_ON : B_CONTROL_OFF);
} }
+9 -12
View File
@@ -6,6 +6,7 @@
* Jérôme Duval, * Jérôme Duval,
* Axel Dörfler (axeld@pinc-software.de) * Axel Dörfler (axeld@pinc-software.de)
* Andrew McCall (mccall@digitalparadise.co.uk) * Andrew McCall (mccall@digitalparadise.co.uk)
* Brecht Machiels (brecht@mos6581.org)
*/ */
#ifndef SETTINGS_VIEW_H #ifndef SETTINGS_VIEW_H
#define SETTINGS_VIEW_H #define SETTINGS_VIEW_H
@@ -14,6 +15,7 @@
#include <Box.h> #include <Box.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h> #include <Button.h>
#include <CheckBox.h>
#include <Slider.h> #include <Slider.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
@@ -23,32 +25,27 @@ class MouseView;
class SettingsView : public BBox { class SettingsView : public BBox {
public: public:
SettingsView(BRect frame, MouseSettings &settings); SettingsView(MouseSettings &settings);
virtual ~SettingsView(); virtual ~SettingsView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void GetPreferredSize(float* _width, float* _height);
virtual void Draw(BRect frame);
void SetMouseType(int32 type); void SetMouseType(int32 type);
void MouseMapUpdated(); void MouseMapUpdated();
void UpdateFromSettings(); void UpdateFromSettings();
private: private:
friend class MouseWindow;
typedef BBox inherited; typedef BBox inherited;
const MouseSettings &fSettings; const MouseSettings &fSettings;
BPopUpMenu *fTypeMenu, *fFocusMenu; BPopUpMenu *fTypeMenu, *fFocusMenu, *fFocusFollowsMouseMenu;
BCheckBox *fAcceptFirstClickBox;
MouseView *fMouseView; MouseView *fMouseView;
BSlider *fClickSpeedSlider, *fMouseSpeedSlider, *fAccelerationSlider; BSlider *fClickSpeedSlider, *fMouseSpeedSlider, *fAccelerationSlider;
BBitmap *fDoubleClickBitmap, *fSpeedBitmap, *fAccelerationBitmap;
BRect fLeftArea, fRightArea;
BPoint fLeft, fRight;
BPoint fDoubleClickBmpPoint, fSpeedBmpPoint, fAccelerationBmpPoint;
}; };
#endif /* SETTINGS_VIEW_H */ #endif /* SETTINGS_VIEW_H */
+11 -10
View File
@@ -13,6 +13,16 @@
#include "DefaultDecorator.h" #include "DefaultDecorator.h"
#include <new>
#include <stdio.h>
#include <Autolock.h>
#include <GradientLinear.h>
#include <Rect.h>
#include <View.h>
#include <WindowPrivate.h>
#include "BitmapDrawingEngine.h" #include "BitmapDrawingEngine.h"
#include "DesktopSettings.h" #include "DesktopSettings.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
@@ -21,15 +31,6 @@
#include "PatternHandler.h" #include "PatternHandler.h"
#include "ServerBitmap.h" #include "ServerBitmap.h"
#include <WindowPrivate.h>
#include <Autolock.h>
#include <GradientLinear.h>
#include <Rect.h>
#include <View.h>
#include <new>
#include <stdio.h>
//#define DEBUG_DECORATOR //#define DEBUG_DECORATOR
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
@@ -576,7 +577,7 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
// NOTE: On R5, windows are not moved to back if clicked inside the // NOTE: On R5, windows are not moved to back if clicked inside the
// resize area with the second mouse button. So we check this after // resize area with the second mouse button. So we check this after
// the check above // the check above
if (buttons == B_SECONDARY_MOUSE_BUTTON) if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
return DEC_MOVETOBACK; return DEC_MOVETOBACK;
if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE)) if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
+3 -1
View File
@@ -10,9 +10,11 @@
#define DEFAULT_DECORATOR_H #define DEFAULT_DECORATOR_H
#include "Decorator.h"
#include <Region.h> #include <Region.h>
#include "Decorator.h"
class Desktop; class Desktop;
class ServerBitmap; class ServerBitmap;
+61 -25
View File
@@ -5,8 +5,9 @@
* Authors: * Authors:
* Adrian Oanca <adioanca@cotty.iren.ro> * Adrian Oanca <adioanca@cotty.iren.ro>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler <axeld@pinc-software.de>
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>
* Brecht Machiels <brecht@mos6581.org>
*/ */
@@ -123,7 +124,8 @@ KeyboardFilter::_UpdateFocus(int32 key, uint32 modifiers, EventTarget** _target)
// be done differently, though (using something like B_LOCK_WINDOW_FOCUS) // be done differently, though (using something like B_LOCK_WINDOW_FOCUS)
// (at least B_WINDOW_ACTIVATED must be postponed) // (at least B_WINDOW_ACTIVATED must be postponed)
if (fLastFocus == NULL || (focus != fLastFocus && now - fTimestamp > 100000)) { if (fLastFocus == NULL
|| (focus != fLastFocus && now - fTimestamp > 100000)) {
// if the time span between the key presses is very short // if the time span between the key presses is very short
// we keep our previous focus alive - this is safe even // we keep our previous focus alive - this is safe even
// if the target doesn't exist anymore, as we don't reset // if the target doesn't exist anymore, as we don't reset
@@ -215,8 +217,8 @@ MouseFilter::MouseFilter(Desktop* desktop)
filter_result filter_result
MouseFilter::Filter(BMessage* message, EventTarget** _target, int32* _viewToken, MouseFilter::Filter(BMessage* message, EventTarget** _target,
BMessage* latestMouseMoved) int32* _viewToken, BMessage* latestMouseMoved)
{ {
BPoint where; BPoint where;
if (message->FindPoint("where", &where) != B_OK) if (message->FindPoint("where", &where) != B_OK)
@@ -244,7 +246,8 @@ MouseFilter::Filter(BMessage* message, EventTarget** _target, int32* _viewToken,
case B_MOUSE_UP: case B_MOUSE_UP:
window->MouseUp(message, where, &viewToken); window->MouseUp(message, where, &viewToken);
fDesktop->SetMouseEventWindow(NULL); if (buttons == 0)
fDesktop->SetMouseEventWindow(NULL);
break; break;
case B_MOUSE_MOVED: case B_MOUSE_MOVED:
@@ -388,7 +391,8 @@ Desktop::Init()
return B_ERROR; return B_ERROR;
} }
fVirtualScreen.HWInterface()->MoveCursorTo(fVirtualScreen.Frame().Width() / 2, fVirtualScreen.HWInterface()->MoveCursorTo(
fVirtualScreen.Frame().Width() / 2,
fVirtualScreen.Frame().Height() / 2); fVirtualScreen.Frame().Height() / 2);
#if TEST_MODE #if TEST_MODE
@@ -843,6 +847,24 @@ Desktop::RemoveWorkspacesView(WorkspacesView* view)
// #pragma mark - Methods for Window manipulation // #pragma mark - Methods for Window manipulation
/*! \brief Activates or focusses the window based on the pointer position.
*/
void
Desktop::SelectWindow(Window* window)
{
if (fSettings->MouseMode() != B_NORMAL_MOUSE) {
// Only bring the window to front when it is not the window under the
// mouse pointer. This should result in sensible behaviour.
if (window != fWindowUnderMouse
|| (window == fWindowUnderMouse && window != FocusWindow()))
ActivateWindow(window);
else
SetFocusWindow(window);
} else
ActivateWindow(window);
}
/*! \brief Tries to move the specified window to the front of the screen, /*! \brief Tries to move the specified window to the front of the screen,
and make it the focus window. and make it the focus window.
@@ -853,7 +875,8 @@ Desktop::RemoveWorkspacesView(WorkspacesView* view)
void void
Desktop::ActivateWindow(Window* window) Desktop::ActivateWindow(Window* window)
{ {
STRACE(("ActivateWindow(%p, %s)\n", window, window ? window->Title() : "<none>")); STRACE(("ActivateWindow(%p, %s)\n", window, window
? window->Title() : "<none>"));
if (window == NULL) { if (window == NULL) {
fBack = NULL; fBack = NULL;
@@ -1003,8 +1026,10 @@ Desktop::SendWindowBehind(Window* window, Window* behindOf)
MarkDirty(dirty); MarkDirty(dirty);
_UpdateFronts(); _UpdateFronts();
SetFocusWindow(fSettings->FocusFollowsMouse() ? if (fSettings->MouseMode() == B_FOCUS_FOLLOWS_MOUSE)
WindowAt(fLastMousePosition) : NULL); SetFocusWindow(WindowAt(fLastMousePosition));
else if (fSettings->MouseMode() == B_NORMAL_MOUSE)
SetFocusWindow(NULL);
bool sendFakeMouseMoved = false; bool sendFakeMouseMoved = false;
if (FocusWindow() != window) if (FocusWindow() != window)
@@ -1413,7 +1438,8 @@ Desktop::SetWindowFeel(Window* window, window_feel newFeel)
// adopt the window's current workspaces // adopt the window's current workspaces
if (!window->IsNormal()) if (!window->IsNormal())
_ChangeWindowWorkspaces(window, window->Workspaces(), window->SubsetWorkspaces()); _ChangeWindowWorkspaces(window, window->Workspaces(),
window->SubsetWorkspaces());
// make sure the window has the correct position in the window lists // make sure the window has the correct position in the window lists
// (ie. all floating windows have to be on the top, ...) // (ie. all floating windows have to be on the top, ...)
@@ -2083,7 +2109,8 @@ Desktop::_LaunchInputServer()
if (entryStatus == B_OK) if (entryStatus == B_OK)
entryStatus = roster.Launch(&ref); entryStatus = roster.Launch(&ref);
if (entryStatus == B_OK || entryStatus == B_ALREADY_RUNNING) { if (entryStatus == B_OK || entryStatus == B_ALREADY_RUNNING) {
syslog(LOG_ERR, "Failed to launch the input server by signature: %s!\n", syslog(LOG_ERR,
"Failed to launch the input server by signature: %s!\n",
strerror(status)); strerror(status));
return; return;
} }
@@ -2119,7 +2146,8 @@ Desktop::_PrepareQuit()
// wait for the last app to die // wait for the last app to die
if (count > 0) if (count > 0)
acquire_sem_etc(fShutdownSemaphore, fShutdownCount, B_RELATIVE_TIMEOUT, 250000); acquire_sem_etc(fShutdownSemaphore, fShutdownCount, B_RELATIVE_TIMEOUT,
250000);
fApplicationsLock.Unlock(); fApplicationsLock.Unlock();
} }
@@ -2135,7 +2163,8 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// Attached data: // Attached data:
// 1) port_id - receiver port of a regular app // 1) port_id - receiver port of a regular app
// 2) port_id - client looper port - for sending messages to the client // 2) port_id - client looper port - for sending messages to the
// client
// 2) team_id - app's team ID // 2) team_id - app's team ID
// 3) int32 - handler token of the regular app // 3) int32 - handler token of the regular app
// 4) char * - signature of the regular app // 4) char * - signature of the regular app
@@ -2179,8 +2208,8 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_DELETE_APP: case AS_DELETE_APP:
{ {
// Delete a ServerApp. Received only from the respective ServerApp when a // Delete a ServerApp. Received only from the respective ServerApp
// BApplication asks it to quit. // when a BApplication asks it to quit.
// Attached Data: // Attached Data:
// 1) thread_id - thread ID of the ServerApp to be deleted // 1) thread_id - thread ID of the ServerApp to be deleted
@@ -2213,7 +2242,8 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
if (fQuitting && count <= 1) { if (fQuitting && count <= 1) {
// wait for the last app to die // wait for the last app to die
acquire_sem_etc(fShutdownSemaphore, fShutdownCount, B_RELATIVE_TIMEOUT, 500000); acquire_sem_etc(fShutdownSemaphore, fShutdownCount,
B_RELATIVE_TIMEOUT, 500000);
PostMessage(kMsgQuitLooper); PostMessage(kMsgQuitLooper);
} }
break; break;
@@ -2268,8 +2298,8 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case B_QUIT_REQUESTED: case B_QUIT_REQUESTED:
// We've been asked to quit, so (for now) broadcast to all // We've been asked to quit, so (for now) broadcast to all
// test apps to quit. This situation will occur only when the server // test apps to quit. This situation will occur only when the
// is compiled as a regular Be application. // server is compiled as a regular Be application.
fApplicationsLock.Lock(); fApplicationsLock.Lock();
fShutdownSemaphore = create_sem(0, "desktop shutdown"); fShutdownSemaphore = create_sem(0, "desktop shutdown");
@@ -2313,7 +2343,8 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
} }
default: default:
printf("Desktop %d:%s received unexpected code %ld\n", 0, "baron", code); printf("Desktop %d:%s received unexpected code %ld\n", 0, "baron",
code);
if (link.NeedsReply()) { if (link.NeedsReply()) {
// the client is now blocking and waiting for a reply! // the client is now blocking and waiting for a reply!
@@ -2425,8 +2456,10 @@ Desktop::_UpdateFront(bool updateFloating)
fFront = NULL; fFront = NULL;
for (Window* window = _CurrentWindows().LastWindow(); for (Window* window = _CurrentWindows().LastWindow();
window != NULL; window = window->PreviousWindow(fCurrentWorkspace)) { window != NULL;
if (window->IsHidden() || window->IsFloating() || !window->SupportsFront()) window = window->PreviousWindow(fCurrentWorkspace)) {
if (window->IsHidden() || window->IsFloating()
|| !window->SupportsFront())
continue; continue;
fFront = window; fFront = window;
@@ -2564,7 +2597,8 @@ void
Desktop::_UpdateSubsetWorkspaces(Window* window, int32 previousIndex, Desktop::_UpdateSubsetWorkspaces(Window* window, int32 previousIndex,
int32 newIndex) int32 newIndex)
{ {
STRACE(("_UpdateSubsetWorkspaces(window %p, %s)\n", window, window->Title())); STRACE(("_UpdateSubsetWorkspaces(window %p, %s)\n", window,
window->Title()));
// if the window is hidden, the subset windows are up-to-date already // if the window is hidden, the subset windows are up-to-date already
if (!window->IsNormal() || window->IsHidden()) if (!window->IsNormal() || window->IsHidden())
@@ -2720,7 +2754,8 @@ Desktop::_LastFocusSubsetWindow(Window* window)
for (Window* front = fFocusList.LastWindow(); front != NULL; for (Window* front = fFocusList.LastWindow(); front != NULL;
front = front->PreviousWindow(kFocusList)) { front = front->PreviousWindow(kFocusList)) {
if (front != window && !front->IsHidden() && window->HasInSubset(front)) if (front != window && !front->IsHidden()
&& window->HasInSubset(front))
return front; return front;
} }
@@ -3142,7 +3177,8 @@ Desktop::_SetWorkspace(int32 index)
} }
if (window->Frame().LeftTop() != position) { if (window->Frame().LeftTop() != position) {
// the window was visible before, but its on-screen location changed // the window was visible before, but its on-screen location
// changed
BPoint offset = position - window->Frame().LeftTop(); BPoint offset = position - window->Frame().LeftTop();
MoveWindowBy(window, offset.x, offset.y); MoveWindowBy(window, offset.x, offset.y);
// TODO: be a bit smarter than this... // TODO: be a bit smarter than this...
+3 -1
View File
@@ -5,8 +5,9 @@
* Authors: * Authors:
* Adrian Oanca <adioanca@cotty.iren.ro> * Adrian Oanca <adioanca@cotty.iren.ro>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler <axeld@pinc-software.de>
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Brecht Machiels <brecht@mos6581.org>
*/ */
#ifndef DESKTOP_H #ifndef DESKTOP_H
#define DESKTOP_H #define DESKTOP_H
@@ -161,6 +162,7 @@ public:
// Window methods // Window methods
void SelectWindow(Window* window);
void ActivateWindow(Window* window); void ActivateWindow(Window* window);
void SendWindowBehind(Window* window, void SendWindowBehind(Window* window,
Window* behindOf = NULL); Window* behindOf = NULL);
+87 -12
View File
@@ -11,6 +11,15 @@
#include "DesktopSettings.h" #include "DesktopSettings.h"
#include "DesktopSettingsPrivate.h" #include "DesktopSettingsPrivate.h"
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
#include <DefaultColors.h>
#include <ServerReadOnlyMemory.h>
#include "Desktop.h" #include "Desktop.h"
#include "FontCache.h" #include "FontCache.h"
#include "FontCacheEntry.h" #include "FontCacheEntry.h"
@@ -18,14 +27,6 @@
#include "GlobalSubpixelSettings.h" #include "GlobalSubpixelSettings.h"
#include "ServerConfig.h" #include "ServerConfig.h"
#include <DefaultColors.h>
#include <ServerReadOnlyMemory.h>
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared) DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
: :
@@ -50,6 +51,8 @@ DesktopSettingsPrivate::_SetDefaults()
fFixedFont = *gFontManager->DefaultFixedFont(); fFixedFont = *gFontManager->DefaultFixedFont();
fMouseMode = B_NORMAL_MOUSE; fMouseMode = B_NORMAL_MOUSE;
fFocusFollowsMouseMode = B_NORMAL_FOCUS_FOLLOWS_MOUSE;
fAcceptFirstClick = false;
fShowAllDraggers = true; fShowAllDraggers = true;
// init scrollbar info // init scrollbar info
@@ -194,9 +197,18 @@ DesktopSettingsPrivate::_Load()
status = settings.Unflatten(&file); status = settings.Unflatten(&file);
if (status == B_OK) { if (status == B_OK) {
int32 mode; int32 mode;
if (settings.FindInt32("mode", &mode) == B_OK) { if (settings.FindInt32("mode", &mode) == B_OK)
fMouseMode = (mode_mouse)mode; fMouseMode = (mode_mouse)mode;
int32 focusFollowsMouseMode;
if (settings.FindInt32("focus follows mouse mode",
&focusFollowsMouseMode) == B_OK) {
fFocusFollowsMouseMode =
(mode_focus_follows_mouse)focusFollowsMouseMode;
} }
bool acceptFirstClick;
if (settings.FindBool("accept first click", &acceptFirstClick)
== B_OK)
fAcceptFirstClick = acceptFirstClick;
} }
} }
@@ -235,8 +247,8 @@ DesktopSettingsPrivate::_Load()
fMenuInfo.click_to_open = clickToOpen; fMenuInfo.click_to_open = clickToOpen;
bool triggersAlwaysShown; bool triggersAlwaysShown;
if (settings.FindBool("triggers always shown", &triggersAlwaysShown) if (settings.FindBool("triggers always shown",
== B_OK) { &triggersAlwaysShown) == B_OK) {
fMenuInfo.triggers_always_shown = triggersAlwaysShown; fMenuInfo.triggers_always_shown = triggersAlwaysShown;
} }
@@ -350,6 +362,9 @@ DesktopSettingsPrivate::Save(uint32 mask)
if (path.Append("mouse") == B_OK) { if (path.Append("mouse") == B_OK) {
BMessage settings('asms'); BMessage settings('asms');
settings.AddInt32("mode", (int32)fMouseMode); settings.AddInt32("mode", (int32)fMouseMode);
settings.AddInt32("focus follows mouse mode",
(int32)fFocusFollowsMouseMode);
settings.AddBool("accept first click", fAcceptFirstClick);
BFile file; BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
@@ -498,6 +513,15 @@ DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
} }
void
DesktopSettingsPrivate::SetFocusFollowsMouseMode(
const mode_focus_follows_mouse mode)
{
fFocusFollowsMouseMode = mode;
Save(kMouseSettings);
}
mode_mouse mode_mouse
DesktopSettingsPrivate::MouseMode() const DesktopSettingsPrivate::MouseMode() const
{ {
@@ -505,10 +529,32 @@ DesktopSettingsPrivate::MouseMode() const
} }
mode_focus_follows_mouse
DesktopSettingsPrivate::FocusFollowsMouseMode() const
{
return fFocusFollowsMouseMode;
}
void
DesktopSettingsPrivate::SetAcceptFirstClick(const bool acceptFirstClick)
{
fAcceptFirstClick = acceptFirstClick;
Save(kMouseSettings);
}
bool
DesktopSettingsPrivate::AcceptFirstClick() const
{
return fAcceptFirstClick;
}
bool bool
DesktopSettingsPrivate::FocusFollowsMouse() const DesktopSettingsPrivate::FocusFollowsMouse() const
{ {
return MouseMode() != B_NORMAL_MOUSE; return MouseMode() == B_FOCUS_FOLLOWS_MOUSE;
} }
@@ -740,6 +786,13 @@ DesktopSettings::MouseMode() const
} }
mode_focus_follows_mouse
DesktopSettings::FocusFollowsMouseMode() const
{
return fSettings->FocusFollowsMouseMode();
}
bool bool
DesktopSettings::FocusFollowsMouse() const DesktopSettings::FocusFollowsMouse() const
{ {
@@ -747,6 +800,13 @@ DesktopSettings::FocusFollowsMouse() const
} }
bool
DesktopSettings::AcceptFirstClick() const
{
return fSettings->AcceptFirstClick();
}
bool bool
DesktopSettings::ShowAllDraggers() const DesktopSettings::ShowAllDraggers() const
{ {
@@ -882,6 +942,21 @@ LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
} }
void
LockedDesktopSettings::SetFocusFollowsMouseMode(
const mode_focus_follows_mouse mode)
{
fSettings->SetFocusFollowsMouseMode(mode);
}
void
LockedDesktopSettings::SetAcceptFirstClick(const bool acceptFirstClick)
{
fSettings->SetAcceptFirstClick(acceptFirstClick);
}
void void
LockedDesktopSettings::SetShowAllDraggers(bool show) LockedDesktopSettings::SetShowAllDraggers(bool show)
{ {
+5
View File
@@ -44,7 +44,9 @@ class DesktopSettings {
void GetMenuInfo(menu_info& info) const; void GetMenuInfo(menu_info& info) const;
mode_mouse MouseMode() const; mode_mouse MouseMode() const;
mode_focus_follows_mouse FocusFollowsMouseMode() const;
bool FocusFollowsMouse() const; bool FocusFollowsMouse() const;
bool AcceptFirstClick() const;
bool ShowAllDraggers() const; bool ShowAllDraggers() const;
@@ -77,6 +79,9 @@ class LockedDesktopSettings : public DesktopSettings {
void SetMenuInfo(const menu_info& info); void SetMenuInfo(const menu_info& info);
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
void SetFocusFollowsMouseMode(
const mode_focus_follows_mouse mode);
void SetAcceptFirstClick(bool accept_first_click);
void SetShowAllDraggers(bool show); void SetShowAllDraggers(bool show);
+10 -1
View File
@@ -11,10 +11,12 @@
#include "DesktopSettings.h" #include "DesktopSettings.h"
#include "ServerFont.h"
#include <Locker.h> #include <Locker.h>
#include "ServerFont.h"
struct server_read_only_memory; struct server_read_only_memory;
@@ -43,7 +45,12 @@ public:
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
mode_mouse MouseMode() const; mode_mouse MouseMode() const;
void SetFocusFollowsMouseMode(
mode_focus_follows_mouse mode);
mode_focus_follows_mouse FocusFollowsMouseMode() const;
bool FocusFollowsMouse() const; bool FocusFollowsMouse() const;
void SetAcceptFirstClick(bool accept_first_click);
bool AcceptFirstClick() const;
void SetShowAllDraggers(bool show); void SetShowAllDraggers(bool show);
bool ShowAllDraggers() const; bool ShowAllDraggers() const;
@@ -85,6 +92,8 @@ private:
scroll_bar_info fScrollBarInfo; scroll_bar_info fScrollBarInfo;
menu_info fMenuInfo; menu_info fMenuInfo;
mode_mouse fMouseMode; mode_mouse fMouseMode;
mode_focus_follows_mouse fFocusFollowsMouseMode;
bool fAcceptFirstClick;
bool fShowAllDraggers; bool fShowAllDraggers;
int32 fWorkspacesColumns; int32 fWorkspacesColumns;
int32 fWorkspacesRows; int32 fWorkspacesRows;
+234 -229
View File
@@ -26,280 +26,285 @@ string_for_message_code(uint32 code, BString& string)
CODE(AS_EVENT_STREAM_CLOSED); CODE(AS_EVENT_STREAM_CLOSED);
// Desktop definitions (through the ServerApp, though) // Desktop definitions (through the ServerApp, though)
case AS_GET_WINDOW_LIST: string = "AS_GET_WINDOW_LIST"; break; CODE(AS_GET_WINDOW_LIST);
case AS_GET_WINDOW_INFO: string = "AS_GET_WINDOW_INFO"; break; CODE(AS_GET_WINDOW_INFO);
case AS_MINIMIZE_TEAM: string = "AS_MINIMIZE_TEAM"; break; CODE(AS_MINIMIZE_TEAM);
case AS_BRING_TEAM_TO_FRONT: string = "AS_BRING_TEAM_TO_FRONT"; break; CODE(AS_BRING_TEAM_TO_FRONT);
case AS_WINDOW_ACTION: string = "AS_WINDOW_ACTION"; break; CODE(AS_WINDOW_ACTION);
// Application definitions // Application definitions
case AS_CREATE_APP: string = "AS_CREATE_APP"; break; CODE(AS_CREATE_APP);
case AS_DELETE_APP: string = "AS_DELETE_APP"; break; CODE(AS_DELETE_APP);
case AS_QUIT_APP: string = "AS_QUIT_APP"; break; CODE(AS_QUIT_APP);
case AS_ACTIVATE_APP: string = "AS_ACTIVATE_APP"; break; CODE(AS_ACTIVATE_APP);
case AS_APP_CRASHED: string = "AS_APP_CRASHED"; break; CODE(AS_APP_CRASHED);
case AS_CREATE_WINDOW: string = "AS_CREATE_WINDOW"; break; CODE(AS_CREATE_WINDOW);
case AS_CREATE_OFFSCREEN_WINDOW: string = "AS_CREATE_OFFSCREEN_WINDOW"; break; CODE(AS_CREATE_OFFSCREEN_WINDOW);
case AS_DELETE_WINDOW: string = "AS_DELETE_WINDOW"; break; CODE(AS_DELETE_WINDOW);
case AS_CREATE_BITMAP: string = "AS_CREATE_BITMAP"; break; CODE(AS_CREATE_BITMAP);
case AS_DELETE_BITMAP: string = "AS_DELETE_BITMAP"; break; CODE(AS_DELETE_BITMAP);
case AS_GET_BITMAP_OVERLAY_RESTRICTIONS: string = "AS_GET_BITMAP_OVERLAY_RESTRICTIONS"; break; CODE(AS_GET_BITMAP_OVERLAY_RESTRICTIONS);
// Cursor commands // Cursor commands
case AS_SET_CURSOR: string = "AS_SET_CURSOR"; break; CODE(AS_SET_CURSOR);
case AS_SET_VIEW_CURSOR: string = "AS_SET_VIEW_CURSOR"; break; CODE(AS_SET_VIEW_CURSOR);
case AS_SHOW_CURSOR: string = "AS_SHOW_CURSOR"; break; CODE(AS_SHOW_CURSOR);
case AS_HIDE_CURSOR: string = "AS_HIDE_CURSOR"; break; CODE(AS_HIDE_CURSOR);
case AS_OBSCURE_CURSOR: string = "AS_OBSCURE_CURSOR"; break; CODE(AS_OBSCURE_CURSOR);
case AS_QUERY_CURSOR_HIDDEN: string = "AS_QUERY_CURSOR_HIDDEN"; break; CODE(AS_QUERY_CURSOR_HIDDEN);
case AS_CREATE_CURSOR: string = "AS_CREATE_CURSOR"; break; CODE(AS_CREATE_CURSOR);
case AS_REFERENCE_CURSOR: string = "AS_REFERENCE_CURSOR"; break; CODE(AS_REFERENCE_CURSOR);
case AS_DELETE_CURSOR: string = "AS_DELETE_CURSOR"; break; CODE(AS_DELETE_CURSOR);
case AS_BEGIN_RECT_TRACKING: string = "AS_BEGIN_RECT_TRACKING"; break; CODE(AS_BEGIN_RECT_TRACKING);
case AS_END_RECT_TRACKING: string = "AS_END_RECT_TRACKING"; break; CODE(AS_END_RECT_TRACKING);
// Window definitions // Window definitions
case AS_SHOW_WINDOW: string = "AS_SHOW_WINDOW"; break; CODE(AS_SHOW_WINDOW);
case AS_HIDE_WINDOW: string = "AS_HIDE_WINDOW"; break; CODE(AS_HIDE_WINDOW);
case AS_MINIMIZE_WINDOW: string = "AS_MINIMIZE_WINDOW"; break; CODE(AS_MINIMIZE_WINDOW);
case AS_QUIT_WINDOW: string = "AS_QUIT_WINDOW"; break; CODE(AS_QUIT_WINDOW);
case AS_SEND_BEHIND: string = "AS_SEND_BEHIND"; break; CODE(AS_SEND_BEHIND);
case AS_SET_LOOK: string = "AS_SET_LOOK"; break; CODE(AS_SET_LOOK);
case AS_SET_FEEL: string = "AS_SET_FEEL"; break; CODE(AS_SET_FEEL);
case AS_SET_FLAGS: string = "AS_SET_FLAGS"; break; CODE(AS_SET_FLAGS);
case AS_DISABLE_UPDATES: string = "AS_DISABLE_UPDATES"; break; CODE(AS_DISABLE_UPDATES);
case AS_ENABLE_UPDATES: string = "AS_ENABLE_UPDATES"; break; CODE(AS_ENABLE_UPDATES);
case AS_BEGIN_UPDATE: string = "AS_BEGIN_UPDATE"; break; CODE(AS_BEGIN_UPDATE);
case AS_END_UPDATE: string = "AS_END_UPDATE"; break; CODE(AS_END_UPDATE);
case AS_NEEDS_UPDATE: string = "AS_NEEDS_UPDATE"; break; CODE(AS_NEEDS_UPDATE);
case AS_SET_WINDOW_TITLE: string = "AS_SET_WINDOW_TITLE"; break; CODE(AS_SET_WINDOW_TITLE);
case AS_ADD_TO_SUBSET: string = "AS_ADD_TO_SUBSET"; break; CODE(AS_ADD_TO_SUBSET);
case AS_REMOVE_FROM_SUBSET: string = "AS_REMOVE_FROM_SUBSET"; break; CODE(AS_REMOVE_FROM_SUBSET);
case AS_SET_ALIGNMENT: string = "AS_SET_ALIGNMENT"; break; CODE(AS_SET_ALIGNMENT);
case AS_GET_ALIGNMENT: string = "AS_GET_ALIGNMENT"; break; CODE(AS_GET_ALIGNMENT);
case AS_GET_WORKSPACES: string = "AS_GET_WORKSPACES"; break; CODE(AS_GET_WORKSPACES);
case AS_SET_WORKSPACES: string = "AS_SET_WORKSPACES"; break; CODE(AS_SET_WORKSPACES);
case AS_WINDOW_RESIZE: string = "AS_WINDOW_RESIZE"; break; CODE(AS_WINDOW_RESIZE);
case AS_WINDOW_MOVE: string = "AS_WINDOW_MOVE"; break; CODE(AS_WINDOW_MOVE);
case AS_SET_SIZE_LIMITS: string = "AS_SET_SIZE_LIMITS"; break; CODE(AS_SET_SIZE_LIMITS);
case AS_ACTIVATE_WINDOW: string = "AS_ACTIVATE_WINDOW"; break; CODE(AS_ACTIVATE_WINDOW);
case AS_IS_FRONT_WINDOW: string = "AS_IS_FRONT_WINDOW"; break; CODE(AS_IS_FRONT_WINDOW);
// BPicture definitions // BPicture definitions
case AS_CREATE_PICTURE: string = "AS_CREATE_PICTURE"; break; CODE(AS_CREATE_PICTURE);
case AS_DELETE_PICTURE: string = "AS_DELETE_PICTURE"; break; CODE(AS_DELETE_PICTURE);
case AS_CLONE_PICTURE: string = "AS_CLONE_PICTURE"; break; CODE(AS_CLONE_PICTURE);
case AS_DOWNLOAD_PICTURE: string = "AS_DOWNLOAD_PICTURE"; break; CODE(AS_DOWNLOAD_PICTURE);
// Font-related server communications // Font-related server communications
case AS_SET_SYSTEM_FONT: string = "AS_SET_SYSTEM_FONT"; break; CODE(AS_SET_SYSTEM_FONT);
case AS_GET_SYSTEM_FONTS: string = "AS_GET_SYSTEM_FONTS"; break; CODE(AS_GET_SYSTEM_FONTS);
case AS_GET_SYSTEM_DEFAULT_FONT: string = "AS_GET_SYSTEM_DEFAULT_FONT"; break; CODE(AS_GET_SYSTEM_DEFAULT_FONT);
case AS_GET_FONT_LIST_REVISION: string = "AS_GET_FONT_LIST_REVISION"; break; CODE(AS_GET_FONT_LIST_REVISION);
case AS_GET_FAMILY_AND_STYLES: string = "AS_GET_FAMILY_AND_STYLES"; break; CODE(AS_GET_FAMILY_AND_STYLES);
case AS_GET_FAMILY_AND_STYLE: string = "AS_GET_FAMILY_AND_STYLE"; break; CODE(AS_GET_FAMILY_AND_STYLE);
case AS_GET_FAMILY_AND_STYLE_IDS: string = "AS_GET_FAMILY_AND_STYLE_IDS"; break; CODE(AS_GET_FAMILY_AND_STYLE_IDS);
case AS_GET_FONT_BOUNDING_BOX: string = "AS_GET_FONT_BOUNDING_BOX"; break; CODE(AS_GET_FONT_BOUNDING_BOX);
case AS_GET_TUNED_COUNT: string = "AS_GET_TUNED_COUNT"; break; CODE(AS_GET_TUNED_COUNT);
case AS_GET_TUNED_INFO: string = "AS_GET_TUNED_INFO"; break; CODE(AS_GET_TUNED_INFO);
case AS_GET_FONT_HEIGHT: string = "AS_GET_FONT_HEIGHT"; break; CODE(AS_GET_FONT_HEIGHT);
case AS_GET_FONT_FILE_FORMAT: string = "AS_GET_FONT_FILE_FORMAT"; break; CODE(AS_GET_FONT_FILE_FORMAT);
case AS_GET_EXTRA_FONT_FLAGS: string = "AS_GET_EXTRA_FONT_FLAGS"; break; CODE(AS_GET_EXTRA_FONT_FLAGS);
case AS_GET_STRING_WIDTHS: string = "AS_GET_STRING_WIDTHS"; break; CODE(AS_GET_STRING_WIDTHS);
case AS_GET_EDGES: string = "AS_GET_EDGES"; break; CODE(AS_GET_EDGES);
case AS_GET_ESCAPEMENTS: string = "AS_GET_ESCAPEMENTS"; break; CODE(AS_GET_ESCAPEMENTS);
case AS_GET_ESCAPEMENTS_AS_FLOATS: string = "AS_GET_ESCAPEMENTS_AS_FLOATS"; break; CODE(AS_GET_ESCAPEMENTS_AS_FLOATS);
case AS_GET_BOUNDINGBOXES_CHARS: string = "AS_GET_BOUNDINGBOXES_CHARS"; break; CODE(AS_GET_BOUNDINGBOXES_CHARS);
case AS_GET_BOUNDINGBOXES_STRING: string = "AS_GET_BOUNDINGBOXES_STRING"; break; CODE(AS_GET_BOUNDINGBOXES_STRING);
case AS_GET_BOUNDINGBOXES_STRINGS: string = "AS_GET_BOUNDINGBOXES_STRINGS"; break; CODE(AS_GET_BOUNDINGBOXES_STRINGS);
case AS_GET_HAS_GLYPHS: string = "AS_GET_HAS_GLYPHS"; break; CODE(AS_GET_HAS_GLYPHS);
case AS_GET_GLYPH_SHAPES: string = "AS_GET_GLYPH_SHAPES"; break; CODE(AS_GET_GLYPH_SHAPES);
case AS_GET_TRUNCATED_STRINGS: string = "AS_GET_TRUNCATED_STRINGS"; break; CODE(AS_GET_TRUNCATED_STRINGS);
// Screen methods // Screen methods
case AS_VALID_SCREEN_ID: string = "AS_VALID_SCREEN_ID"; break; CODE(AS_VALID_SCREEN_ID);
case AS_GET_NEXT_SCREEN_ID: string = "AS_GET_NEXT_SCREEN_ID"; break; CODE(AS_GET_NEXT_SCREEN_ID);
case AS_SCREEN_GET_MODE: string = "AS_SCREEN_GET_MODE"; break; CODE(AS_SCREEN_GET_MODE);
case AS_SCREEN_SET_MODE: string = "AS_SCREEN_SET_MODE"; break; CODE(AS_SCREEN_SET_MODE);
case AS_PROPOSE_MODE: string = "AS_PROPOSE_MODE"; break; CODE(AS_PROPOSE_MODE);
case AS_GET_MODE_LIST: string = "AS_GET_MODE_LIST"; break; CODE(AS_GET_MODE_LIST);
case AS_GET_PIXEL_CLOCK_LIMITS: string = "AS_GET_PIXEL_CLOCK_LIMITS"; break; CODE(AS_GET_PIXEL_CLOCK_LIMITS);
case AS_GET_TIMING_CONSTRAINTS: string = "AS_GET_TIMING_CONSTRAINTS"; break; CODE(AS_GET_TIMING_CONSTRAINTS);
case AS_SCREEN_GET_COLORMAP: string = "AS_SCREEN_GET_COLORMAP"; break; CODE(AS_SCREEN_GET_COLORMAP);
case AS_GET_DESKTOP_COLOR: string = "AS_GET_DESKTOP_COLOR"; break; CODE(AS_GET_DESKTOP_COLOR);
case AS_SET_DESKTOP_COLOR: string = "AS_SET_DESKTOP_COLOR"; break; CODE(AS_SET_DESKTOP_COLOR);
case AS_GET_SCREEN_ID_FROM_WINDOW: string = "AS_GET_SCREEN_ID_FROM_WINDOW"; break; CODE(AS_GET_SCREEN_ID_FROM_WINDOW);
case AS_READ_BITMAP: string = "AS_READ_BITMAP"; break; CODE(AS_READ_BITMAP);
case AS_GET_RETRACE_SEMAPHORE: string = "AS_GET_RETRACE_SEMAPHORE"; break; CODE(AS_GET_RETRACE_SEMAPHORE);
case AS_GET_ACCELERANT_INFO: string = "AS_GET_ACCELERANT_INFO"; break; CODE(AS_GET_ACCELERANT_INFO);
case AS_GET_MONITOR_INFO: string = "AS_GET_MONITOR_INFO"; break; CODE(AS_GET_MONITOR_INFO);
case AS_GET_FRAME_BUFFER_CONFIG: string = "AS_GET_FRAME_BUFFER_CONFIG"; break; CODE(AS_GET_FRAME_BUFFER_CONFIG);
case AS_SET_DPMS: string = "AS_SET_DPMS"; break; CODE(AS_SET_DPMS);
case AS_GET_DPMS_STATE: string = "AS_GET_DPMS_STATE"; break; CODE(AS_GET_DPMS_STATE);
case AS_GET_DPMS_CAPABILITIES: string = "AS_GET_DPMS_CAPABILITIES"; break; CODE(AS_GET_DPMS_CAPABILITIES);
// Misc stuff // Misc stuff
case AS_GET_ACCELERANT_PATH: string = "AS_GET_ACCELERANT_PATH"; break; CODE(AS_GET_ACCELERANT_PATH);
case AS_GET_DRIVER_PATH: string = "AS_GET_DRIVER_PATH"; break; CODE(AS_GET_DRIVER_PATH);
// Global function call defs // Global function call defs
case AS_SET_UI_COLORS: string = "AS_SET_UI_COLORS"; break; CODE(AS_SET_UI_COLORS);
case AS_SET_UI_COLOR: string = "AS_SET_UI_COLOR"; break; CODE(AS_SET_UI_COLOR);
case AS_SET_DECORATOR: string = "AS_SET_DECORATOR"; break; CODE(AS_SET_DECORATOR);
case AS_GET_DECORATOR: string = "AS_GET_DECORATOR"; break; CODE(AS_GET_DECORATOR);
case AS_R5_SET_DECORATOR: string = "AS_R5_SET_DECORATOR"; break; case AS_R5_SET_DECORATOR:
case AS_COUNT_DECORATORS: string = "AS_COUNT_DECORATORS"; break; string = "AS_R5_SET_DECORATOR"; break;
case AS_GET_DECORATOR_NAME: string = "AS_GET_DECORATOR_NAME"; break; CODE(AS_COUNT_DECORATORS);
CODE(AS_GET_DECORATOR_NAME);
CODE(AS_SET_WORKSPACE_LAYOUT); CODE(AS_SET_WORKSPACE_LAYOUT);
CODE(AS_GET_WORKSPACE_LAYOUT); CODE(AS_GET_WORKSPACE_LAYOUT);
case AS_CURRENT_WORKSPACE: string = "AS_CURRENT_WORKSPACE"; break; CODE(AS_CURRENT_WORKSPACE);
case AS_ACTIVATE_WORKSPACE: string = "AS_ACTIVATE_WORKSPACE"; break; CODE(AS_ACTIVATE_WORKSPACE);
case AS_GET_SCROLLBAR_INFO: string = "AS_GET_SCROLLBAR_INFO"; break; CODE(AS_GET_SCROLLBAR_INFO);
case AS_SET_SCROLLBAR_INFO: string = "AS_SET_SCROLLBAR_INFO"; break; CODE(AS_SET_SCROLLBAR_INFO);
case AS_GET_MENU_INFO: string = "AS_GET_MENU_INFO"; break; CODE(AS_GET_MENU_INFO);
case AS_SET_MENU_INFO: string = "AS_SET_MENU_INFO"; break; CODE(AS_SET_MENU_INFO);
case AS_IDLE_TIME: string = "AS_IDLE_TIME"; break; CODE(AS_IDLE_TIME);
case AS_SET_MOUSE_MODE: string = "AS_SET_MOUSE_MODE"; break; CODE(AS_SET_MOUSE_MODE);
case AS_GET_MOUSE_MODE: string = "AS_GET_MOUSE_MODE"; break; CODE(AS_GET_MOUSE_MODE);
case AS_GET_MOUSE: string = "AS_GET_MOUSE"; break; CODE(AS_SET_FOCUS_FOLLOWS_MOUSE_MODE);
case AS_SET_DECORATOR_SETTINGS: string = "AS_SET_DECORATOR_SETTINGS"; break; CODE(AS_GET_FOCUS_FOLLOWS_MOUSE_MODE);
case AS_GET_DECORATOR_SETTINGS: string = "AS_GET_DECORATOR_SETTINGS"; break; CODE(AS_SET_ACCEPT_FIRST_CLICK);
case AS_GET_SHOW_ALL_DRAGGERS: string = "AS_GET_SHOW_ALL_DRAGGERS"; break; CODE(AS_GET_ACCEPT_FIRST_CLICK);
case AS_SET_SHOW_ALL_DRAGGERS: string = "AS_SET_SHOW_ALL_DRAGGERS"; break; CODE(AS_GET_MOUSE);
CODE(AS_SET_DECORATOR_SETTINGS);
CODE(AS_GET_DECORATOR_SETTINGS);
CODE(AS_GET_SHOW_ALL_DRAGGERS);
CODE(AS_SET_SHOW_ALL_DRAGGERS);
// Subpixel antialiasing & hinting // Subpixel antialiasing & hinting
case AS_SET_SUBPIXEL_ANTIALIASING: string = "AS_SET_SUBPIXEL_ANTIALIASING"; break; CODE(AS_SET_SUBPIXEL_ANTIALIASING);
case AS_GET_SUBPIXEL_ANTIALIASING: string = "AS_GET_SUBPIXEL_ANTIALIASING"; break; CODE(AS_GET_SUBPIXEL_ANTIALIASING);
case AS_SET_HINTING: string = "AS_SET_HINTING"; break; CODE(AS_SET_HINTING);
case AS_GET_HINTING: string = "AS_GET_HINTING"; break; CODE(AS_GET_HINTING);
case AS_SET_SUBPIXEL_AVERAGE_WEIGHT: string = "AS_SET_SUBPIXEL_AVERAGE_WEIGHT"; break; CODE(AS_SET_SUBPIXEL_AVERAGE_WEIGHT);
case AS_GET_SUBPIXEL_AVERAGE_WEIGHT: string = "AS_GET_SUBPIXEL_AVERAGE_WEIGHT"; break; CODE(AS_GET_SUBPIXEL_AVERAGE_WEIGHT);
case AS_SET_SUBPIXEL_ORDERING: string = "AS_SET_SUBPIXEL_ORDERING"; break; CODE(AS_SET_SUBPIXEL_ORDERING);
case AS_GET_SUBPIXEL_ORDERING: string = "AS_GET_SUBPIXEL_ORDERING"; break; CODE(AS_GET_SUBPIXEL_ORDERING);
// Graphics calls // Graphics calls
case AS_SET_HIGH_COLOR: string = "AS_SET_HIGH_COLOR"; break; CODE(AS_SET_HIGH_COLOR);
case AS_SET_LOW_COLOR: string = "AS_SET_LOW_COLOR"; break; CODE(AS_SET_LOW_COLOR);
case AS_SET_VIEW_COLOR: string = "AS_SET_VIEW_COLOR"; break; CODE(AS_SET_VIEW_COLOR);
case AS_STROKE_ARC: string = "AS_STROKE_ARC"; break; CODE(AS_STROKE_ARC);
case AS_STROKE_BEZIER: string = "AS_STROKE_BEZIER"; break; CODE(AS_STROKE_BEZIER);
case AS_STROKE_ELLIPSE: string = "AS_STROKE_ELLIPSE"; break; CODE(AS_STROKE_ELLIPSE);
case AS_STROKE_LINE: string = "AS_STROKE_LINE"; break; CODE(AS_STROKE_LINE);
case AS_STROKE_LINEARRAY: string = "AS_STROKE_LINEARRAY"; break; CODE(AS_STROKE_LINEARRAY);
case AS_STROKE_POLYGON: string = "AS_STROKE_POLYGON"; break; CODE(AS_STROKE_POLYGON);
case AS_STROKE_RECT: string = "AS_STROKE_RECT"; break; CODE(AS_STROKE_RECT);
case AS_STROKE_ROUNDRECT: string = "AS_STROKE_ROUNDRECT"; break; CODE(AS_STROKE_ROUNDRECT);
case AS_STROKE_SHAPE: string = "AS_STROKE_SHAPE"; break; CODE(AS_STROKE_SHAPE);
case AS_STROKE_TRIANGLE: string = "AS_STROKE_TRIANGLE"; break; CODE(AS_STROKE_TRIANGLE);
case AS_FILL_ARC: string = "AS_FILL_ARC"; break; CODE(AS_FILL_ARC);
case AS_FILL_ARC_GRADIENT: string = "AS_FILL_ARC_GRADIENT"; break; CODE(AS_FILL_ARC_GRADIENT);
case AS_FILL_BEZIER: string = "AS_FILL_BEZIER"; break; CODE(AS_FILL_BEZIER);
case AS_FILL_BEZIER_GRADIENT: string = "AS_FILL_BEZIER_GRADIENT"; break; CODE(AS_FILL_BEZIER_GRADIENT);
case AS_FILL_ELLIPSE: string = "AS_FILL_ELLIPSE"; break; CODE(AS_FILL_ELLIPSE);
case AS_FILL_ELLIPSE_GRADIENT: string = "AS_FILL_ELLIPSE_GRADIENT"; break; CODE(AS_FILL_ELLIPSE_GRADIENT);
case AS_FILL_POLYGON: string = "AS_FILL_POLYGON"; break; CODE(AS_FILL_POLYGON);
case AS_FILL_POLYGON_GRADIENT: string = "AS_FILL_POLYGON_GRADIENT"; break; CODE(AS_FILL_POLYGON_GRADIENT);
case AS_FILL_RECT: string = "AS_FILL_RECT"; break; CODE(AS_FILL_RECT);
case AS_FILL_RECT_GRADIENT: string = "AS_FILL_RECT_GRADIENT"; break; CODE(AS_FILL_RECT_GRADIENT);
case AS_FILL_REGION: string = "AS_FILL_REGION"; break; CODE(AS_FILL_REGION);
case AS_FILL_REGION_GRADIENT: string = "AS_FILL_REGION_GRADIENT"; break; CODE(AS_FILL_REGION_GRADIENT);
case AS_FILL_ROUNDRECT: string = "AS_FILL_ROUNDRECT"; break; CODE(AS_FILL_ROUNDRECT);
case AS_FILL_ROUNDRECT_GRADIENT: string = "AS_FILL_ROUNDRECT_GRADIENT"; break; CODE(AS_FILL_ROUNDRECT_GRADIENT);
case AS_FILL_SHAPE: string = "AS_FILL_SHAPE"; break; CODE(AS_FILL_SHAPE);
case AS_FILL_SHAPE_GRADIENT: string = "AS_FILL_SHAPE_GRADIENT"; break; CODE(AS_FILL_SHAPE_GRADIENT);
case AS_FILL_TRIANGLE: string = "AS_FILL_TRIANGLE"; break; CODE(AS_FILL_TRIANGLE);
case AS_FILL_TRIANGLE_GRADIENT: string = "AS_FILL_TRIANGLE_GRADIENT"; break; CODE(AS_FILL_TRIANGLE_GRADIENT);
case AS_DRAW_STRING: string = "AS_DRAW_STRING"; break; CODE(AS_DRAW_STRING);
case AS_DRAW_STRING_WITH_DELTA: string = "AS_DRAW_STRING_WITH_DELTA"; break; CODE(AS_DRAW_STRING_WITH_DELTA);
case AS_SYNC: string = "AS_SYNC"; break; CODE(AS_SYNC);
case AS_VIEW_CREATE: string = "AS_VIEW_CREATE"; break; CODE(AS_VIEW_CREATE);
case AS_VIEW_DELETE: string = "AS_VIEW_DELETE"; break; CODE(AS_VIEW_DELETE);
case AS_VIEW_CREATE_ROOT: string = "AS_VIEW_CREATE_ROOT"; break; CODE(AS_VIEW_CREATE_ROOT);
case AS_VIEW_SHOW: string = "AS_VIEW_SHOW"; break; CODE(AS_VIEW_SHOW);
case AS_VIEW_HIDE: string = "AS_VIEW_HIDE"; break; CODE(AS_VIEW_HIDE);
case AS_VIEW_MOVE: string = "AS_VIEW_MOVE"; break; CODE(AS_VIEW_MOVE);
case AS_VIEW_RESIZE: string = "AS_VIEW_RESIZE"; break; CODE(AS_VIEW_RESIZE);
case AS_VIEW_DRAW: string = "AS_VIEW_DRAW"; break; CODE(AS_VIEW_DRAW);
// View definitions // View definitions
case AS_VIEW_GET_COORD: string = "AS_VIEW_GET_COORD"; break; CODE(AS_VIEW_GET_COORD);
case AS_VIEW_SET_FLAGS: string = "AS_VIEW_SET_FLAGS"; break; CODE(AS_VIEW_SET_FLAGS);
case AS_VIEW_SET_ORIGIN: string = "AS_VIEW_SET_ORIGIN"; break; CODE(AS_VIEW_SET_ORIGIN);
case AS_VIEW_GET_ORIGIN: string = "AS_VIEW_GET_ORIGIN"; break; CODE(AS_VIEW_GET_ORIGIN);
case AS_VIEW_RESIZE_MODE: string = "AS_VIEW_RESIZE_MODE"; break; CODE(AS_VIEW_RESIZE_MODE);
case AS_VIEW_BEGIN_RECT_TRACK: string = "AS_VIEW_BEGIN_RECT_TRACK"; break; CODE(AS_VIEW_BEGIN_RECT_TRACK);
case AS_VIEW_END_RECT_TRACK: string = "AS_VIEW_END_RECT_TRACK"; break; CODE(AS_VIEW_END_RECT_TRACK);
case AS_VIEW_DRAG_RECT: string = "AS_VIEW_DRAG_RECT"; break; CODE(AS_VIEW_DRAG_RECT);
case AS_VIEW_DRAG_IMAGE: string = "AS_VIEW_DRAG_IMAGE"; break; CODE(AS_VIEW_DRAG_IMAGE);
case AS_VIEW_SCROLL: string = "AS_VIEW_SCROLL"; break; CODE(AS_VIEW_SCROLL);
case AS_VIEW_SET_LINE_MODE: string = "AS_VIEW_SET_LINE_MODE"; break; CODE(AS_VIEW_SET_LINE_MODE);
case AS_VIEW_GET_LINE_MODE: string = "AS_VIEW_GET_LINE_MODE"; break; CODE(AS_VIEW_GET_LINE_MODE);
case AS_VIEW_PUSH_STATE: string = "AS_VIEW_PUSH_STATE"; break; CODE(AS_VIEW_PUSH_STATE);
case AS_VIEW_POP_STATE: string = "AS_VIEW_POP_STATE"; break; CODE(AS_VIEW_POP_STATE);
case AS_VIEW_SET_SCALE: string = "AS_VIEW_SET_SCALE"; break; CODE(AS_VIEW_SET_SCALE);
case AS_VIEW_GET_SCALE: string = "AS_VIEW_GET_SCALE"; break; CODE(AS_VIEW_GET_SCALE);
case AS_VIEW_SET_DRAWING_MODE: string = "AS_VIEW_SET_DRAWING_MODE"; break; CODE(AS_VIEW_SET_DRAWING_MODE);
case AS_VIEW_GET_DRAWING_MODE: string = "AS_VIEW_GET_DRAWING_MODE"; break; CODE(AS_VIEW_GET_DRAWING_MODE);
case AS_VIEW_SET_BLENDING_MODE: string = "AS_VIEW_SET_BLENDING_MODE"; break; CODE(AS_VIEW_SET_BLENDING_MODE);
case AS_VIEW_GET_BLENDING_MODE: string = "AS_VIEW_GET_BLENDING_MODE"; break; CODE(AS_VIEW_GET_BLENDING_MODE);
case AS_VIEW_SET_PEN_LOC: string = "AS_VIEW_SET_PEN_LOC"; break; CODE(AS_VIEW_SET_PEN_LOC);
case AS_VIEW_GET_PEN_LOC: string = "AS_VIEW_GET_PEN_LOC"; break; CODE(AS_VIEW_GET_PEN_LOC);
case AS_VIEW_SET_PEN_SIZE: string = "AS_VIEW_SET_PEN_SIZE"; break; CODE(AS_VIEW_SET_PEN_SIZE);
case AS_VIEW_GET_PEN_SIZE: string = "AS_VIEW_GET_PEN_SIZE"; break; CODE(AS_VIEW_GET_PEN_SIZE);
case AS_VIEW_SET_HIGH_COLOR: string = "AS_VIEW_SET_HIGH_COLOR"; break; CODE(AS_VIEW_SET_HIGH_COLOR);
case AS_VIEW_SET_LOW_COLOR: string = "AS_VIEW_SET_LOW_COLOR"; break; CODE(AS_VIEW_SET_LOW_COLOR);
case AS_VIEW_SET_VIEW_COLOR: string = "AS_VIEW_SET_VIEW_COLOR"; break; CODE(AS_VIEW_SET_VIEW_COLOR);
case AS_VIEW_GET_HIGH_COLOR: string = "AS_VIEW_GET_HIGH_COLOR"; break; CODE(AS_VIEW_GET_HIGH_COLOR);
case AS_VIEW_GET_LOW_COLOR: string = "AS_VIEW_GET_LOW_COLOR"; break; CODE(AS_VIEW_GET_LOW_COLOR);
case AS_VIEW_GET_VIEW_COLOR: string = "AS_VIEW_GET_VIEW_COLOR"; break; CODE(AS_VIEW_GET_VIEW_COLOR);
case AS_VIEW_PRINT_ALIASING: string = "AS_VIEW_PRINT_ALIASING"; break; CODE(AS_VIEW_PRINT_ALIASING);
case AS_VIEW_CLIP_TO_PICTURE: string = "AS_VIEW_CLIP_TO_PICTURE"; break; CODE(AS_VIEW_CLIP_TO_PICTURE);
case AS_VIEW_GET_CLIP_REGION: string = "AS_VIEW_GET_CLIP_REGION"; break; CODE(AS_VIEW_GET_CLIP_REGION);
case AS_VIEW_DRAW_BITMAP: string = "AS_VIEW_DRAW_BITMAP"; break; CODE(AS_VIEW_DRAW_BITMAP);
case AS_VIEW_SET_EVENT_MASK: string = "AS_VIEW_SET_EVENT_MASK"; break; CODE(AS_VIEW_SET_EVENT_MASK);
case AS_VIEW_SET_MOUSE_EVENT_MASK: string = "AS_VIEW_SET_MOUSE_EVENT_MASK"; break; CODE(AS_VIEW_SET_MOUSE_EVENT_MASK);
case AS_VIEW_DRAW_STRING: string = "AS_VIEW_DRAW_STRING"; break; CODE(AS_VIEW_DRAW_STRING);
case AS_VIEW_SET_CLIP_REGION: string = "AS_VIEW_SET_CLIP_REGION"; break; CODE(AS_VIEW_SET_CLIP_REGION);
case AS_VIEW_LINE_ARRAY: string = "AS_VIEW_LINE_ARRAY"; break; CODE(AS_VIEW_LINE_ARRAY);
case AS_VIEW_BEGIN_PICTURE: string = "AS_VIEW_BEGIN_PICTURE"; break; CODE(AS_VIEW_BEGIN_PICTURE);
case AS_VIEW_APPEND_TO_PICTURE: string = "AS_VIEW_APPEND_TO_PICTURE"; break; CODE(AS_VIEW_APPEND_TO_PICTURE);
case AS_VIEW_END_PICTURE: string = "AS_VIEW_END_PICTURE"; break; CODE(AS_VIEW_END_PICTURE);
case AS_VIEW_COPY_BITS: string = "AS_VIEW_COPY_BITS"; break; CODE(AS_VIEW_COPY_BITS);
case AS_VIEW_DRAW_PICTURE: string = "AS_VIEW_DRAW_PICTURE"; break; CODE(AS_VIEW_DRAW_PICTURE);
case AS_VIEW_INVALIDATE_RECT: string = "AS_VIEW_INVALIDATE_RECT"; break; CODE(AS_VIEW_INVALIDATE_RECT);
case AS_VIEW_INVALIDATE_REGION: string = "AS_VIEW_INVALIDATE_REGION"; break; CODE(AS_VIEW_INVALIDATE_REGION);
case AS_VIEW_INVERT_RECT: string = "AS_VIEW_INVERT_RECT"; break; CODE(AS_VIEW_INVERT_RECT);
case AS_VIEW_MOVE_TO: string = "AS_VIEW_MOVE_TO"; break; CODE(AS_VIEW_MOVE_TO);
case AS_VIEW_RESIZE_TO: string = "AS_VIEW_RESIZE_TO"; break; CODE(AS_VIEW_RESIZE_TO);
case AS_VIEW_SET_STATE: string = "AS_VIEW_SET_STATE"; break; CODE(AS_VIEW_SET_STATE);
case AS_VIEW_SET_FONT_STATE: string = "AS_VIEW_SET_FONT_STATE"; break; CODE(AS_VIEW_SET_FONT_STATE);
case AS_VIEW_GET_STATE: string = "AS_VIEW_GET_STATE"; break; CODE(AS_VIEW_GET_STATE);
case AS_VIEW_SET_VIEW_BITMAP: string = "AS_VIEW_SET_VIEW_BITMAP"; break; CODE(AS_VIEW_SET_VIEW_BITMAP);
case AS_VIEW_SET_PATTERN: string = "AS_VIEW_SET_PATTERN"; break; CODE(AS_VIEW_SET_PATTERN);
case AS_SET_CURRENT_VIEW: string = "AS_SET_CURRENT_VIEW"; break; CODE(AS_SET_CURRENT_VIEW);
// BDirectWindow codes // BDirectWindow codes
case AS_DIRECT_WINDOW_GET_SYNC_DATA: string = "AS_DIRECT_WINDOW_GET_SYNC_DATA"; break; CODE(AS_DIRECT_WINDOW_GET_SYNC_DATA);
case AS_DIRECT_WINDOW_SET_FULLSCREEN: string = "AS_DIRECT_WINDOW_SET_FULLSCREEN"; break; CODE(AS_DIRECT_WINDOW_SET_FULLSCREEN);
default: default:
string << "unkown code: " << code; string << "unkown code: " << code;
+64 -5
View File
@@ -379,8 +379,8 @@ ServerApp::_MessageLooper()
case AS_QUIT_APP: case AS_QUIT_APP:
{ {
// This message is received only when the app_server is asked to // This message is received only when the app_server is asked
// shut down in test/debug mode. Of course, if we are testing // to shut down in test/debug mode. Of course, if we are testing
// while using AccelerantDriver, we do NOT want to shut down // while using AccelerantDriver, we do NOT want to shut down
// client applications. The server can be quit in this fashion // client applications. The server can be quit in this fashion
// through the driver's interface, such as closing the // through the driver's interface, such as closing the
@@ -1159,10 +1159,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
case AS_SET_MOUSE_MODE: case AS_SET_MOUSE_MODE:
{ {
STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n", STRACE(("ServerApp %s: Set Mouse Focus mode\n",
Signature())); Signature()));
// Attached Data: // Attached Data:
// 1) enum mode_mouse FFM mouse mode // 1) enum mode_mouse mouse focus mode
mode_mouse mouseMode; mode_mouse mouseMode;
if (link.Read<mode_mouse>(&mouseMode) == B_OK) { if (link.Read<mode_mouse>(&mouseMode) == B_OK) {
LockedDesktopSettings settings(fDesktop); LockedDesktopSettings settings(fDesktop);
@@ -1172,7 +1172,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
} }
case AS_GET_MOUSE_MODE: case AS_GET_MOUSE_MODE:
{ {
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n", STRACE(("ServerApp %s: Get Mouse Focus mode\n",
Signature())); Signature()));
if (fDesktop->LockSingleWindow()) { if (fDesktop->LockSingleWindow()) {
@@ -1188,6 +1188,65 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
fLink.Flush(); fLink.Flush();
break; break;
} }
case AS_SET_FOCUS_FOLLOWS_MOUSE_MODE:
{
STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n", Signature()));
// Attached Data:
// 1) enum mode_focus_follows_mouse FFM mouse mode
mode_focus_follows_mouse focusFollowsMousMode;
if (link.Read<mode_focus_follows_mouse>(&focusFollowsMousMode) == B_OK) {
LockedDesktopSettings settings(fDesktop);
settings.SetFocusFollowsMouseMode(focusFollowsMousMode);
}
break;
}
case AS_GET_FOCUS_FOLLOWS_MOUSE_MODE:
{
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n", Signature()));
if (fDesktop->LockSingleWindow()) {
DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK);
fLink.Attach<mode_focus_follows_mouse>(
settings.FocusFollowsMouseMode());
fDesktop->UnlockSingleWindow();
} else
fLink.StartMessage(B_ERROR);
fLink.Flush();
break;
}
case AS_SET_ACCEPT_FIRST_CLICK:
{
STRACE(("ServerApp %s: Set Accept First Click\n", Signature()));
// Attached Data:
// 1) bool accept_first_click
bool acceptFirstClick;
if (link.Read<bool>(&acceptFirstClick) == B_OK) {
LockedDesktopSettings settings(fDesktop);
settings.SetAcceptFirstClick(acceptFirstClick);
}
break;
}
case AS_GET_ACCEPT_FIRST_CLICK:
{
STRACE(("ServerApp %s: Get Accept First Click\n", Signature()));
if (fDesktop->LockSingleWindow()) {
DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK);
fLink.Attach<bool>(settings.AcceptFirstClick());
fDesktop->UnlockSingleWindow();
} else
fLink.StartMessage(B_ERROR);
fLink.Flush();
break;
}
case AS_GET_SHOW_ALL_DRAGGERS: case AS_GET_SHOW_ALL_DRAGGERS:
{ {
+4 -3
View File
@@ -7,9 +7,10 @@
* Adrian Oanca <adioanca@gmail.com> * Adrian Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Stefano Ceccherini <stefano.ceccherini@gmail.com> * Stefano Ceccherini <stefano.ceccherini@gmail.com>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler <axeld@pinc-software.de>
* Artur Wyszynski <harakash@gmail.com> * Artur Wyszynski <harakash@gmail.com>
* Philippe Saint-Pierre, stpere@gmail.com * Philippe Saint-Pierre <stpere@gmail.com>
* Brecht Machiels <brecht@mos6581.org>
*/ */
@@ -648,7 +649,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fDesktop->UnlockSingleWindow(); fDesktop->UnlockSingleWindow();
if (activate) if (activate)
fDesktop->ActivateWindow(fWindow); fDesktop->SelectWindow(fWindow);
else else
fDesktop->SendWindowBehind(fWindow, NULL); fDesktop->SendWindowBehind(fWindow, NULL);
+52 -26
View File
@@ -6,7 +6,8 @@
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@gmail.com> * Adi Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler <axeld@pinc-software.de>
* Brecht Machiels <brecht@mos6581.org>
*/ */
@@ -774,6 +775,8 @@ static const bigtime_t kWindowActivationTimeout = 500000LL;
void void
Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken) Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
{ {
DesktopSettings desktopSettings(fDesktop);
// TODO: move into Decorator // TODO: move into Decorator
if (!fBorderRegionValid) if (!fBorderRegionValid)
GetBorderRegion(&fBorderRegion); GetBorderRegion(&fBorderRegion);
@@ -800,11 +803,13 @@ Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
action = DEC_DRAG; action = DEC_DRAG;
} }
// ignore clicks on decorator buttons if the if (!desktopSettings.AcceptFirstClick()) {
// non-floating window doesn't have focus // ignore clicks on decorator buttons if the
if (!IsFocus() && !IsFloating() && action != DEC_MOVETOBACK // non-floating window doesn't have focus
&& action != DEC_RESIZE && action != DEC_SLIDETAB) if (!IsFocus() && !IsFloating() && action != DEC_MOVETOBACK
action = DEC_DRAG; && action != DEC_RESIZE && action != DEC_SLIDETAB)
action = DEC_DRAG;
}
// set decorator internals // set decorator internals
switch (action) { switch (action) {
@@ -869,20 +874,30 @@ Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
} }
if (action == DEC_MOVETOBACK) { if (action == DEC_MOVETOBACK) {
fDesktop->SendWindowBehind(this); if (desktopSettings.MouseMode() == B_CLICK_TO_FOCUS_MOUSE) {
bool covered = true;
BRegion fullRegion;
GetFullRegion(&fullRegion);
if (fullRegion == VisibleRegion()) {
// window is overlapped.
covered = false;
}
if (this != fDesktop->FrontWindow() && covered)
fDesktop->ActivateWindow(this);
else
fDesktop->SendWindowBehind(this);
} else
fDesktop->SendWindowBehind(this);
} else { } else {
fDesktop->SetMouseEventWindow(this); fDesktop->SetMouseEventWindow(this);
// activate window if not in FFM mode // activate window if in click to activate mode, else only focus it
DesktopSettings desktopSettings(fDesktop); if (desktopSettings.MouseMode() == B_NORMAL_MOUSE)
if (!desktopSettings.FocusFollowsMouse()) {
fDesktop->ActivateWindow(this); fDesktop->ActivateWindow(this);
} else { else {
// actually, the window should already be
// focused since the mouse would have to
// be over it, but just for completeness...
fDesktop->SetFocusWindow(this); fDesktop->SetFocusWindow(this);
if (action == DEC_DRAG) { if (desktopSettings.MouseMode() == B_FOCUS_FOLLOWS_MOUSE
&& action == DEC_DRAG) {
fActivateOnMouseUp = true; fActivateOnMouseUp = true;
fMouseMoveDistance = 0.0f; fMouseMoveDistance = 0.0f;
fLastMoveTime = system_time(); fLastMoveTime = system_time();
@@ -897,13 +912,17 @@ Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
// clicking a simple View // clicking a simple View
if (!IsFocus()) { if (!IsFocus()) {
DesktopSettings desktopSettings(fDesktop); bool acceptFirstClick = desktopSettings.AcceptFirstClick()
|| ((Flags() & B_WILL_ACCEPT_FIRST_CLICK) != 0);
bool avoidFocus = (Flags() & B_AVOID_FOCUS) != 0;
// Activate window in case it doesn't accept first click, and // Activate or focus the window in case it doesn't accept first
// we're not in FFM mode // click, depending on the mouse mode
if ((Flags() & B_WILL_ACCEPT_FIRST_CLICK) == 0 if (desktopSettings.MouseMode() == B_NORMAL_MOUSE
&& !desktopSettings.FocusFollowsMouse()) && !acceptFirstClick)
fDesktop->ActivateWindow(this); fDesktop->ActivateWindow(this);
else if (!avoidFocus)
fDesktop->SetFocusWindow(this);
// Eat the click if we don't accept first click // Eat the click if we don't accept first click
// (B_AVOID_FOCUS never gets the focus, so they always accept // (B_AVOID_FOCUS never gets the focus, so they always accept
@@ -911,8 +930,7 @@ Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
// TODO: the latter is unlike BeOS - if we really wanted to // TODO: the latter is unlike BeOS - if we really wanted to
// imitate this behaviour, we would need to check if we're // imitate this behaviour, we would need to check if we're
// the front window instead of the focus window // the front window instead of the focus window
if ((Flags() & (B_WILL_ACCEPT_FIRST_CLICK if (!acceptFirstClick && !avoidFocus)
| B_AVOID_FOCUS)) == 0)
return; return;
} }
@@ -968,6 +986,18 @@ Window::MouseUp(BMessage* message, BPoint where, int32* _viewToken)
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fRegionPool.Recycle(visibleBorder); fRegionPool.Recycle(visibleBorder);
int32 buttons;
if (message->FindInt32("buttons", &buttons) != B_OK)
buttons = 0;
// if the primary mouse button is released, stop
// dragging/resizing/sliding
if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) {
fIsDragging = false;
fIsResizing = false;
fIsSlidingTab = false;
}
} }
// in FFM mode, activate the window and bring it // in FFM mode, activate the window and bring it
@@ -981,10 +1011,6 @@ Window::MouseUp(BMessage* message, BPoint where, int32* _viewToken)
fDesktop->ActivateWindow(this); fDesktop->ActivateWindow(this);
} }
fIsDragging = false;
fIsResizing = false;
fIsSlidingTab = false;
if (View* view = ViewAt(where)) { if (View* view = ViewAt(where)) {
if (HasModal()) if (HasModal())
return; return;
+2 -1
View File
@@ -6,7 +6,8 @@
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@gmail.com> * Adi Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler <axeld@pinc-software.de>
* Brecht Machiels <brecht@mos6581.org>
*/ */
#ifndef WINDOW_H #ifndef WINDOW_H
#define WINDOW_H #define WINDOW_H
+62 -18
View File
@@ -15,19 +15,23 @@
// //
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include "MouseSettings.h"
#include <stdio.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <File.h> #include <File.h>
#include <Path.h> #include <Path.h>
#include <View.h> #include <View.h>
#include <stdio.h>
#include "MouseSettings.h"
static const bigtime_t kDefaultClickSpeed = 500000; static const bigtime_t kDefaultClickSpeed = 500000;
static const int32 kDefaultMouseSpeed = 65536; static const int32 kDefaultMouseSpeed = 65536;
static const int32 kDefaultMouseType = 3; // 3 button mouse static const int32 kDefaultMouseType = 3; // 3 button mouse
static const int32 kDefaultAccelerationFactor = 65536; static const int32 kDefaultAccelerationFactor = 65536;
static const bool kDefaultAcceptFirstClick = false;
MouseSettings::MouseSettings() MouseSettings::MouseSettings()
@@ -41,6 +45,8 @@ MouseSettings::MouseSettings()
fOriginalSettings = fSettings; fOriginalSettings = fSettings;
fOriginalMode = fMode; fOriginalMode = fMode;
fOriginalFocusFollowsMouseMode = fFocusFollowsMouseMode;
fOriginalAcceptFirstClick = fAcceptFirstClick;
} }
@@ -68,6 +74,7 @@ MouseSettings::RetrieveSettings()
// retrieve current values // retrieve current values
fMode = mouse_mode(); fMode = mouse_mode();
fAcceptFirstClick = accept_first_click();
Defaults(); Defaults();
// also try to load the window position from disk // also try to load the window position from disk
@@ -85,12 +92,16 @@ MouseSettings::RetrieveSettings()
if ((file.Read(&fSettings.type, sizeof(int32)) != sizeof(int32)) if ((file.Read(&fSettings.type, sizeof(int32)) != sizeof(int32))
|| (file.Read(&fSettings.map, sizeof(int32) * 3) != sizeof(int32) * 3) || (file.Read(&fSettings.map, sizeof(int32) * 3) != sizeof(int32) * 3)
|| (file.Read(&fSettings.accel, sizeof(mouse_accel)) != sizeof(mouse_accel)) || (file.Read(&fSettings.accel, sizeof(mouse_accel))
|| (file.Read(&fSettings.click_speed, sizeof(bigtime_t)) != sizeof(bigtime_t))) { != sizeof(mouse_accel))
|| (file.Read(&fSettings.click_speed, sizeof(bigtime_t))
.282
!= sizeof(bigtime_t))) {
Defaults(); Defaults();
} }
#else #else
if (file.ReadAt(0, &fSettings, sizeof(mouse_settings)) != sizeof(mouse_settings)) { if (file.ReadAt(0, &fSettings, sizeof(mouse_settings))
!= sizeof(mouse_settings)) {
Defaults(); Defaults();
} }
#endif #endif
@@ -128,7 +139,7 @@ MouseSettings::SaveSettings()
file.Write(&fSettings, sizeof(fSettings)); file.Write(&fSettings, sizeof(fSettings));
#endif #endif
// who is responsible for saving the mouse mode? // who is responsible for saving the mouse mode and accept_first_click?
return B_OK; return B_OK;
} }
@@ -139,28 +150,44 @@ void
MouseSettings::Dump() MouseSettings::Dump()
{ {
printf("type:\t\t%ld button mouse\n", fSettings.type); printf("type:\t\t%ld button mouse\n", fSettings.type);
printf("map:\t\tleft = %lu : middle = %lu : right = %lu\n", fSettings.map.button[0], fSettings.map.button[2], fSettings.map.button[1]); printf("map:\t\tleft = %lu : middle = %lu : right = %lu\n",
fSettings.map.button[0], fSettings.map.button[2],
fSettings.map.button[1]);
printf("click speed:\t%Ld\n", fSettings.click_speed); printf("click speed:\t%Ld\n", fSettings.click_speed);
printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled"); printf("accel:\t\t%s\n", fSettings.accel.enabled
? "enabled" : "disabled");
printf("accel factor:\t%ld\n", fSettings.accel.accel_factor); printf("accel factor:\t%ld\n", fSettings.accel.accel_factor);
printf("speed:\t\t%ld\n", fSettings.accel.speed); printf("speed:\t\t%ld\n", fSettings.accel.speed);
char *mode = "unknown"; char *mode = "unknown";
switch (fMode) { switch (fMode) {
case B_NORMAL_MOUSE: case B_NORMAL_MOUSE:
mode = "normal"; mode = "activate";
break;
case B_CLICK_TO_FOCUS_MOUSE:
mode = "focus";
break; break;
case B_FOCUS_FOLLOWS_MOUSE: case B_FOCUS_FOLLOWS_MOUSE:
mode = "focus follows mouse"; mode = "auto-focus";
break;
case B_WARP_MOUSE:
mode = "warp mouse";
break;
case B_INSTANT_WARP_MOUSE:
mode = "instant warp mouse";
break; break;
} }
printf("mode:\t\t%s\n", mode); printf("mouse mode:\t%s\n", mode);
char *focus_follows_mouse_mode = "unknown";
switch (fMode) {
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 #endif
@@ -176,6 +203,8 @@ MouseSettings::Defaults()
SetMouseType(kDefaultMouseType); SetMouseType(kDefaultMouseType);
SetAccelerationFactor(kDefaultAccelerationFactor); SetAccelerationFactor(kDefaultAccelerationFactor);
SetMouseMode(B_NORMAL_MOUSE); SetMouseMode(B_NORMAL_MOUSE);
SetFocusFollowsMouseMode(B_NORMAL_FOCUS_FOLLOWS_MOUSE);
SetAcceptFirstClick(kDefaultAcceptFirstClick);
fSettings.map.button[0] = B_PRIMARY_MOUSE_BUTTON; fSettings.map.button[0] = B_PRIMARY_MOUSE_BUTTON;
fSettings.map.button[1] = B_SECONDARY_MOUSE_BUTTON; fSettings.map.button[1] = B_SECONDARY_MOUSE_BUTTON;
@@ -253,3 +282,18 @@ MouseSettings::SetMouseMode(mode_mouse mode)
fMode = mode; fMode = mode;
} }
void
MouseSettings::SetFocusFollowsMouseMode(mode_focus_follows_mouse mode)
{
fFocusFollowsMouseMode = mode;
}
void
MouseSettings::SetAcceptFirstClick(bool acceptFirstClick)
{
fAcceptFirstClick = acceptFirstClick;
}
+15 -2
View File
@@ -18,9 +18,10 @@
#ifndef MOUSE_SETTINGS_H_ #ifndef MOUSE_SETTINGS_H_
#define MOUSE_SETTINGS_H_ #define MOUSE_SETTINGS_H_
#include <SupportDefs.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <kb_mouse_settings.h> #include <kb_mouse_settings.h>
#include <Path.h>
#include <SupportDefs.h>
class MouseSettings { class MouseSettings {
@@ -40,7 +41,8 @@ class MouseSettings {
int32 MouseSpeed() const { return fSettings.accel.speed; } int32 MouseSpeed() const { return fSettings.accel.speed; }
void SetMouseSpeed(int32 speed); void SetMouseSpeed(int32 speed);
int32 AccelerationFactor() const { return fSettings.accel.accel_factor; } int32 AccelerationFactor() const
{ return fSettings.accel.accel_factor; }
void SetAccelerationFactor(int32 factor); void SetAccelerationFactor(int32 factor);
uint32 Mapping(int32 index) const; uint32 Mapping(int32 index) const;
@@ -51,6 +53,13 @@ class MouseSettings {
mode_mouse MouseMode() const { return fMode; } mode_mouse MouseMode() const { return fMode; }
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
mode_focus_follows_mouse FocusFollowsMouseMode() const
{ return fFocusFollowsMouseMode; }
void SetFocusFollowsMouseMode(mode_focus_follows_mouse mode);
bool AcceptFirstClick() const { return fAcceptFirstClick; }
void SetAcceptFirstClick(bool acceptFirstClick);
status_t SaveSettings(); status_t SaveSettings();
private: private:
@@ -59,6 +68,10 @@ class MouseSettings {
mouse_settings fSettings, fOriginalSettings; mouse_settings fSettings, fOriginalSettings;
mode_mouse fMode, fOriginalMode; mode_mouse fMode, fOriginalMode;
mode_focus_follows_mouse fFocusFollowsMouseMode;
mode_focus_follows_mouse fOriginalFocusFollowsMouseMode;
bool fAcceptFirstClick;
bool fOriginalAcceptFirstClick;
}; };
#endif #endif