[haiku-commits] haiku: hrev45252 - src/servers/app

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 8 Feb 2013 01:00:23 +0100 (CET)

hrev45252 adds 3 changesets to branch 'master'
old head: 02deec6403705bbf3e7b90cbf547f8186a3392ff
new head: 4db1a8c61d68370bc8cccadcb8793679774a7426
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=4db1a8c+%5E02deec6

----------------------------------------------------------------------------

5c1b6cc: Style cleanup.

d6bb64d: app_server: Added NormalMouse() and ClickToFocusMouse() methods.
  
  * Made FocusFollowsMouse() inline.
  * For convenience only.

4db1a8c: app_server: reworked SetFocusWindow() logic a bit.
  
  * The normal mouse mode now only uses the window that had focus last if that
    window is one that does not support to be the front window (such as the
    desktop).
  * This should keep the logic of r41264 without the drawbacks (see #7280 for
    more information).
  * Added _WindowCanHaveFocus() method.
  * This should fix #7630.

                                   [ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

5 files changed, 115 insertions(+), 92 deletions(-)
src/servers/app/Desktop.cpp              |  70 +++++++++++-------
src/servers/app/Desktop.h                |   5 +-
src/servers/app/DesktopSettings.cpp      |  16 +---
src/servers/app/DesktopSettings.h        | 105 +++++++++++++++------------
src/servers/app/DesktopSettingsPrivate.h |  11 ++-

############################################################################

Commit:      5c1b6cc3d4dd5bfd2c8a73cccd1ed2d17ae66d89
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5c1b6cc
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Thu Feb  7 23:38:34 2013 UTC

Style cleanup.

----------------------------------------------------------------------------

diff --git a/src/servers/app/DesktopSettings.h 
b/src/servers/app/DesktopSettings.h
index cd6c806..d6b7345 100644
--- a/src/servers/app/DesktopSettings.h
+++ b/src/servers/app/DesktopSettings.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2009, Haiku.
+ * Copyright 2001-2013, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -14,6 +14,7 @@
 #include <Menu.h>
 #include <Message.h>
 
+
 class Desktop;
 class DesktopSettingsPrivate;
 class ServerFont;
@@ -30,70 +31,75 @@ enum {
        kDraggerSettings        = 0x10,
 };
 
+
 class DesktopSettings {
-       public:
-               DesktopSettings(Desktop* desktop);
+public:
+                                                               
DesktopSettings(Desktop* desktop);
 
-               status_t                Save(uint32 mask = kAllSettings);
+                       status_t                        Save(uint32 mask = 
kAllSettings);
 
-               void                    GetDefaultPlainFont(ServerFont& font) 
const;
-               void                    GetDefaultBoldFont(ServerFont& font) 
const;
-               void                    GetDefaultFixedFont(ServerFont& font) 
const;
+                       void                            
GetDefaultPlainFont(ServerFont& font) const;
+                       void                            
GetDefaultBoldFont(ServerFont& font) const;
+                       void                            
GetDefaultFixedFont(ServerFont& font) const;
 
-               void                    GetScrollBarInfo(scroll_bar_info& info) 
const;
-               void                    GetMenuInfo(menu_info& info) const;
+                       void                            
GetScrollBarInfo(scroll_bar_info& info) const;
+                       void                            GetMenuInfo(menu_info& 
info) const;
 
-               mode_mouse              MouseMode() const;
-               mode_focus_follows_mouse FocusFollowsMouseMode() const;
-               bool                    FocusFollowsMouse() const;
-               bool                    AcceptFirstClick() const;
+                       mode_mouse                      MouseMode() const;
+                       mode_focus_follows_mouse FocusFollowsMouseMode() const;
+                       bool                            FocusFollowsMouse() 
const;
+                       bool                            AcceptFirstClick() 
const;
 
-               bool                    ShowAllDraggers() const;
+                       bool                            ShowAllDraggers() const;
 
-               int32                   WorkspacesCount() const;
-               int32                   WorkspacesColumns() const;
-               int32                   WorkspacesRows() const;
-               const BMessage* WorkspacesMessage(int32 index) const;
+                       int32                           WorkspacesCount() const;
+                       int32                           WorkspacesColumns() 
const;
+                       int32                           WorkspacesRows() const;
+                       const BMessage*         WorkspacesMessage(int32 index) 
const;
 
-               rgb_color               UIColor(color_which which) const;
+                       rgb_color                       UIColor(color_which 
which) const;
 
-               bool                    SubpixelAntialiasing() const;
-               uint8                   Hinting() const;
-               uint8                   SubpixelAverageWeight() const;
-               bool                    IsSubpixelOrderingRegular() const;
+                       bool                            SubpixelAntialiasing() 
const;
+                       uint8                           Hinting() const;
+                       uint8                           SubpixelAverageWeight() 
const;
+                       bool                            
IsSubpixelOrderingRegular() const;
 
-       protected:
-               DesktopSettingsPrivate* fSettings;
+protected:
+                       DesktopSettingsPrivate* fSettings;
 };
 
+
 class LockedDesktopSettings : public DesktopSettings {
-       public:
-               LockedDesktopSettings(Desktop* desktop);
-               ~LockedDesktopSettings();
+public:
+                                                               
LockedDesktopSettings(Desktop* desktop);
+                                                               
~LockedDesktopSettings();
 
-               void                    SetDefaultPlainFont(const ServerFont& 
font);
-               void                    SetDefaultBoldFont(const ServerFont& 
font);
-               void                    SetDefaultFixedFont(const ServerFont& 
font);
+                       void                            
SetDefaultPlainFont(const ServerFont& font);
+                       void                            
SetDefaultBoldFont(const ServerFont& font);
+                       void                            
SetDefaultFixedFont(const ServerFont& font);
 
-               void                    SetScrollBarInfo(const scroll_bar_info& 
info);
-               void                    SetMenuInfo(const menu_info& info);
+                       void                            SetScrollBarInfo(const 
scroll_bar_info& info);
+                       void                            SetMenuInfo(const 
menu_info& info);
 
-               void                    SetMouseMode(mode_mouse mode);
-               void                    SetFocusFollowsMouseMode(
-                                                       
mode_focus_follows_mouse mode);
-               void                    SetAcceptFirstClick(bool 
acceptFirstClick);
+                       void                            SetMouseMode(mode_mouse 
mode);
+                       void                            
SetFocusFollowsMouseMode(
+                                                                       
mode_focus_follows_mouse mode);
+                       void                            
SetAcceptFirstClick(bool acceptFirstClick);
 
-               void                    SetShowAllDraggers(bool show);
+                       void                            SetShowAllDraggers(bool 
show);
 
-               void                    SetUIColor(color_which which, const 
rgb_color color);
+                       void                            SetUIColor(color_which 
which,
+                                                                       const 
rgb_color color);
 
-               void                    SetSubpixelAntialiasing(bool subpix);
-               void                    SetHinting(uint8 hinting);
-               void                    SetSubpixelAverageWeight(uint8 
averageWeight);
-               void                    SetSubpixelOrderingRegular(bool 
subpixelOrdering);
+                       void                            
SetSubpixelAntialiasing(bool subpix);
+                       void                            SetHinting(uint8 
hinting);
+                       void                            
SetSubpixelAverageWeight(uint8 averageWeight);
+                       void                            
SetSubpixelOrderingRegular(
+                                                                       bool 
subpixelOrdering);
 
-       private:
-               Desktop*                fDesktop;
+private:
+                       Desktop*                        fDesktop;
 };
 
+
 #endif /* DESKTOP_SETTINGS_H */

############################################################################

Commit:      d6bb64d84872c1ce527e4ca75d5f133c3991a0b5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d6bb64d
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Thu Feb  7 23:52:16 2013 UTC

app_server: Added NormalMouse() and ClickToFocusMouse() methods.

* Made FocusFollowsMouse() inline.
* For convenience only.

----------------------------------------------------------------------------

diff --git a/src/servers/app/DesktopSettings.cpp 
b/src/servers/app/DesktopSettings.cpp
index 6c3a0d2..f5660b9 100644
--- a/src/servers/app/DesktopSettings.cpp
+++ b/src/servers/app/DesktopSettings.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009, Haiku.
+ * Copyright 2005-2013, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -578,13 +578,6 @@ DesktopSettingsPrivate::AcceptFirstClick() const
 }
 
 
-bool
-DesktopSettingsPrivate::FocusFollowsMouse() const
-{
-       return MouseMode() == B_FOCUS_FOLLOWS_MOUSE;
-}
-
-
 void
 DesktopSettingsPrivate::SetShowAllDraggers(bool show)
 {
@@ -817,13 +810,6 @@ DesktopSettings::FocusFollowsMouseMode() const
 
 
 bool
-DesktopSettings::FocusFollowsMouse() const
-{
-       return fSettings->FocusFollowsMouse();
-}
-
-
-bool
 DesktopSettings::AcceptFirstClick() const
 {
        return fSettings->AcceptFirstClick();
diff --git a/src/servers/app/DesktopSettings.h 
b/src/servers/app/DesktopSettings.h
index d6b7345..77d1656 100644
--- a/src/servers/app/DesktopSettings.h
+++ b/src/servers/app/DesktopSettings.h
@@ -47,7 +47,16 @@ public:
 
                        mode_mouse                      MouseMode() const;
                        mode_focus_follows_mouse FocusFollowsMouseMode() const;
-                       bool                            FocusFollowsMouse() 
const;
+
+                       bool                            NormalMouse() const
+                                                                       { 
return MouseMode() == B_NORMAL_MOUSE; }
+                       bool                            FocusFollowsMouse() 
const
+                                                                       { 
return MouseMode()
+                                                                               
== B_FOCUS_FOLLOWS_MOUSE; }
+                       bool                            ClickToFocusMouse() 
const
+                                                                       { 
return MouseMode()
+                                                                               
== B_CLICK_TO_FOCUS_MOUSE; }
+
                        bool                            AcceptFirstClick() 
const;
 
                        bool                            ShowAllDraggers() const;
diff --git a/src/servers/app/DesktopSettingsPrivate.h 
b/src/servers/app/DesktopSettingsPrivate.h
index 3894dca..71b7519 100644
--- a/src/servers/app/DesktopSettingsPrivate.h
+++ b/src/servers/app/DesktopSettingsPrivate.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009, Haiku.
+ * Copyright 2005-2013, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -48,7 +48,14 @@ public:
                        void                            
SetFocusFollowsMouseMode(
                                                                        
mode_focus_follows_mouse mode);
                        mode_focus_follows_mouse FocusFollowsMouseMode() const;
-                       bool                            FocusFollowsMouse() 
const;
+                       bool                            NormalMouse() const
+                                                                       { 
return MouseMode() == B_NORMAL_MOUSE; }
+                       bool                            FocusFollowsMouse() 
const
+                                                                       { 
return MouseMode()
+                                                                               
== B_FOCUS_FOLLOWS_MOUSE; }
+                       bool                            ClickToFocusMouse() 
const
+                                                                       { 
return MouseMode()
+                                                                               
== B_CLICK_TO_FOCUS_MOUSE; }
                        void                            
SetAcceptFirstClick(bool acceptFirstClick);
                        bool                            AcceptFirstClick() 
const;
 

############################################################################

Revision:    hrev45252
Commit:      4db1a8c61d68370bc8cccadcb8793679774a7426
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4db1a8c
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Thu Feb  7 23:54:33 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/7280
Ticket:      https://dev.haiku-os.org/ticket/7630

app_server: reworked SetFocusWindow() logic a bit.

* The normal mouse mode now only uses the window that had focus last if that
  window is one that does not support to be the front window (such as the
  desktop).
* This should keep the logic of r41264 without the drawbacks (see #7280 for
  more information).
* Added _WindowCanHaveFocus() method.
* This should fix #7630.

----------------------------------------------------------------------------

diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp
index 845414a..76c8084 100644
--- a/src/servers/app/Desktop.cpp
+++ b/src/servers/app/Desktop.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2011, Haiku.
+ * Copyright 2001-2013, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -1017,7 +1017,7 @@ Desktop::RemoveWorkspacesView(WorkspacesView* view)
 void
 Desktop::SelectWindow(Window* window)
 {
-       if (fSettings->MouseMode() == B_CLICK_TO_FOCUS_MOUSE) {
+       if (fSettings->ClickToFocusMouse()) {
                // 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
@@ -1201,9 +1201,9 @@ Desktop::SendWindowBehind(Window* window, Window* 
behindOf, bool sendStack)
        }
 
        _UpdateFronts();
-       if (fSettings->MouseMode() == B_FOCUS_FOLLOWS_MOUSE)
+       if (fSettings->FocusFollowsMouse())
                SetFocusWindow(WindowAt(fLastMousePosition));
-       else if (fSettings->MouseMode() == B_NORMAL_MOUSE)
+       else if (fSettings->NormalMouse())
                SetFocusWindow(NULL);
 
        bool sendFakeMouseMoved = false;
@@ -1868,24 +1868,24 @@ Desktop::KeyboardEventTarget()
        is any window at all, that is.
 */
 void
-Desktop::SetFocusWindow(Window* focus)
+Desktop::SetFocusWindow(Window* nextFocus)
 {
        if (!LockAllWindows())
                return;
 
        // test for B_LOCK_WINDOW_FOCUS
-       if (fLockedFocusWindow && focus != fLockedFocusWindow) {
+       if (fLockedFocusWindow && nextFocus != fLockedFocusWindow) {
                UnlockAllWindows();
                return;
        }
 
-       bool hasModal = _WindowHasModal(focus);
+       bool hasModal = _WindowHasModal(nextFocus);
        bool hasWindowScreen = false;
 
-       if (!hasModal && focus != NULL) {
+       if (!hasModal && nextFocus != NULL) {
                // Check whether or not a window screen is in front of the 
window
                // (if it has a modal, the right thing is done, anyway)
-               Window* window = focus;
+               Window* window = nextFocus;
                while (true) {
                        window = window->NextWindow(fCurrentWorkspace);
                        if (window == NULL || window->Feel() == 
kWindowScreenFeel)
@@ -1895,35 +1895,36 @@ Desktop::SetFocusWindow(Window* focus)
                        hasWindowScreen = true;
        }
 
-       if (focus == fFocus && focus != NULL && !focus->IsHidden()
-               && (focus->Flags() & B_AVOID_FOCUS) == 0
+       if (nextFocus == fFocus && nextFocus != NULL && !nextFocus->IsHidden()
+               && (nextFocus->Flags() & B_AVOID_FOCUS) == 0
                && !hasModal && !hasWindowScreen) {
                // the window that is supposed to get focus already has focus
                UnlockAllWindows();
                return;
        }
 
-       uint32 list = /*fCurrentWorkspace;
-       if (fSettings->FocusFollowsMouse())
-               list = */kFocusList;
+       uint32 list = fCurrentWorkspace;
+       if (!fSettings->NormalMouse())
+               list = kFocusList;
+
+       if (nextFocus == NULL || hasModal || hasWindowScreen) {
+               nextFocus = _Windows(list).LastWindow();
 
-       if (focus == NULL || hasModal || hasWindowScreen) {
-               /*if (!fSettings->FocusFollowsMouse())
-                       focus = CurrentWindows().LastWindow();
-               else*/
-                       focus = fFocusList.LastWindow();
+               if (fSettings->NormalMouse()) {
+                       // If the last window having focus is a window that 
cannot make it
+                       // to the front, we use that as the next focus
+                       Window* lastFocus = fFocusList.LastWindow();
+                       if (!lastFocus->SupportsFront() && 
_WindowCanHaveFocus(lastFocus))
+                               nextFocus = lastFocus;
+               }
        }
 
        // make sure no window is chosen that doesn't want focus or cannot have 
it
-       while (focus != NULL
-               && (!focus->InWorkspace(fCurrentWorkspace)
-                       || (focus->Flags() & B_AVOID_FOCUS) != 0
-                       || _WindowHasModal(focus)
-                       || focus->IsHidden())) {
-               focus = focus->PreviousWindow(list);
+       while (nextFocus != NULL && !_WindowCanHaveFocus(nextFocus)) {
+               nextFocus = nextFocus->PreviousWindow(list);
        }
 
-       if (fFocus == focus) {
+       if (fFocus == nextFocus) {
                // turns out the window that is supposed to get focus now 
already has it
                UnlockAllWindows();
                return;
@@ -1937,7 +1938,7 @@ Desktop::SetFocusWindow(Window* focus)
                oldActiveApp = fFocus->ServerWindow()->App()->ClientTeam();
        }
 
-       fFocus = focus;
+       fFocus = nextFocus;
 
        if (fFocus != NULL) {
                fFocus->SetFocus(true);
@@ -2811,7 +2812,7 @@ Desktop::_UpdateFronts(bool updateFloating)
 
 
 bool
-Desktop::_WindowHasModal(Window* window)
+Desktop::_WindowHasModal(Window* window) const
 {
        if (window == NULL)
                return false;
@@ -2830,6 +2831,19 @@ Desktop::_WindowHasModal(Window* window)
 }
 
 
+/*!    Determines whether or not the specified \a window can have focus at all.
+*/
+bool
+Desktop::_WindowCanHaveFocus(Window* window) const
+{
+       return window != NULL
+               && window->InWorkspace(fCurrentWorkspace)
+               && (window->Flags() & B_AVOID_FOCUS) == 0
+               && !_WindowHasModal(window)
+               && !window->IsHidden();
+}
+
+
 /*!    You must at least hold a single window lock when calling this method.
 */
 void
diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h
index daa6f78..5c7b565 100644
--- a/src/servers/app/Desktop.h
+++ b/src/servers/app/Desktop.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2010, Haiku.
+ * Copyright 2001-2013, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -265,7 +265,8 @@ private:
                        void                            _UpdateBack();
                        void                            _UpdateFront(bool 
updateFloating = true);
                        void                            _UpdateFronts(bool 
updateFloating = true);
-                       bool                            _WindowHasModal(Window* 
window);
+                       bool                            _WindowHasModal(Window* 
window) const;
+                       bool                            
_WindowCanHaveFocus(Window* window) const;
 
                        void                            _WindowChanged(Window* 
window);
                        void                            _WindowRemoved(Window* 
window);


Other related posts: