[haiku-commits] r40464 - haiku/trunk/src/kits/tracker

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 12 Feb 2011 19:07:20 +0100 (CET)

Author: axeld
Date: 2011-02-12 19:07:20 +0100 (Sat, 12 Feb 2011)
New Revision: 40464
Changeset: http://dev.haiku-os.org/changeset/40464
Ticket: http://dev.haiku-os.org/ticket/7211

Modified:
   haiku/trunk/src/kits/tracker/ContainerWindow.cpp
   haiku/trunk/src/kits/tracker/SelectionWindow.cpp
Log:
* Let SelectionWindow::MoveCloseToMouse() also take the current workspace into
  account. This fixes bug #7211.
* Also, don't move it that close to the border of the screen (it now keeps an
  offset of 20 pixels).
* Always move the selection window to the mouse position, even if it's already
  on screen.
* Close the window when pressing the escape key.


Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2011-02-12 17:42:22 UTC 
(rev 40463)
+++ haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2011-02-12 18:07:20 UTC 
(rev 40464)
@@ -3827,10 +3827,11 @@
                fSelectionWindow = new SelectionWindow(this);
                fSelectionWindow->Show();
        } else if (fSelectionWindow->Lock()) {
-               if (fSelectionWindow->IsHidden()) {
-                       fSelectionWindow->MoveCloseToMouse();
+               // The window is already there, just bring it close
+               fSelectionWindow->MoveCloseToMouse();
+               if (fSelectionWindow->IsHidden())
                        fSelectionWindow->Show();
-               }
+
                fSelectionWindow->Unlock();
        }
 }

Modified: haiku/trunk/src/kits/tracker/SelectionWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/SelectionWindow.cpp    2011-02-12 17:42:22 UTC 
(rev 40463)
+++ haiku/trunk/src/kits/tracker/SelectionWindow.cpp    2011-02-12 18:07:20 UTC 
(rev 40464)
@@ -32,12 +32,13 @@
 All rights reserved.
 */
 
-#include <BeBuild.h>
+
 #include <Alert.h>
 #include <Box.h>
 #include <Catalog.h>
 #include <Locale.h>
 #include <MenuItem.h>
+#include <MessageFilter.h>
 
 #include "AutoLock.h"
 #include "ContainerWindow.h"
@@ -45,13 +46,14 @@
 #include "Screen.h"
 #include "SelectionWindow.h"
 
-const int frameThickness = 9;
 
 const uint32 kSelectButtonPressed = 'sbpr';
 
+
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "SelectionWindow"
 
+
 SelectionWindow::SelectionWindow(BContainerWindow* window)
        :
        BWindow(BRect(0, 0, 270, 0), B_TRANSLATE("Select"),     B_TITLED_WINDOW,
@@ -147,6 +149,32 @@
                B_TRANSLATE("Name matches wildcard expression:###"));
        float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : 
topMinWidth;
 
+       class EscapeFilter : public BMessageFilter {
+       public:
+               EscapeFilter(BWindow* target)
+                       :
+                       BMessageFilter(B_KEY_DOWN),
+                       fTarget(target)
+               {
+               }
+
+               virtual filter_result Filter(BMessage* message, BHandler** 
_target)
+               {
+                       int8 byte;
+                       if (message->what == B_KEY_DOWN
+                               && message->FindInt8("byte", &byte) == B_OK
+                               && byte == B_ESCAPE) {
+                               fTarget->Hide();
+                               return B_SKIP_MESSAGE;
+                       }
+                       return B_DISPATCH_MESSAGE;
+               }
+
+       private:
+               BWindow* fTarget;
+       };
+       AddCommonFilter(new(std::nothrow) EscapeFilter(this));
+
        Run();
 
        Lock();
@@ -154,7 +182,7 @@
 
        SetSizeLimits(minWidth, 1280, Bounds().bottom, Bounds().bottom);
 
-       MoveCloseToMouse();     
+       MoveCloseToMouse();
        Unlock();
 }
 
@@ -212,12 +240,13 @@
 
        // ... unless that's outside of the current screen size:
        BScreen screen;
-       windowPosition.x = MAX(0, MIN(screen.Frame().right - Frame().Width(),
+       windowPosition.x = MAX(20, MIN(screen.Frame().right - 20 - 
Frame().Width(),
                windowPosition.x));
-       windowPosition.y = MAX(0, MIN(screen.Frame().bottom - Frame().Height(),
-               windowPosition.y));
+       windowPosition.y = MAX(20,
+               MIN(screen.Frame().bottom - 20 - Frame().Height(), 
windowPosition.y));
 
        MoveTo(windowPosition);
+       SetWorkspaces(1UL << current_workspace());
 }
 
 


Other related posts:

  • » [haiku-commits] r40464 - haiku/trunk/src/kits/tracker - axeld