[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/source

Zolnai Tamás tamas.zolnai at collabora.com
Fri Jan 31 04:07:11 PST 2014


 include/vcl/window.hxx                |    3 +
 sfx2/source/control/thumbnailview.cxx |    1 
 sfx2/source/dialog/backingwindow.cxx  |   55 +++++++++++++++++++++++++++++++++-
 sfx2/source/dialog/backingwindow.hxx  |    2 +
 vcl/source/window/taskpanelist.cxx    |   12 +++----
 vcl/source/window/window.cxx          |   25 +++++++++------
 6 files changed, 80 insertions(+), 18 deletions(-)

New commits:
commit 5b1e68bd852cac4534c5ce2e548187dce1d4561a
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Wed Jan 29 21:07:42 2014 +0100

    fdo#71763: F6 key moves focus on this trip: Menu -> Sidebar -> Thumbnail view
    
    Sidebar and thumbnail View are actually not separate windows
    but F6 key traversal should simulate it as they would be.
    Define a new getfocus flag called GETFOCUS_F6 which means focus
    were grabed as a result of pressing F6 key. Use this and other two
    (GETFOCUS_FORWARD, GETFOCUS_BACKWARD) flags to indicate the focus were
    grabbed along subwindow relation (define a new ImplGrabFocusToDocument
    method with a flag parameter on the analogy of GrabFocus() <-> ImplGrabFocus()).
    Handle F6, Shift+F6 inside BackingWindow as it would have
    two subwindow (sidebar and thumbnail view).
    Plus Ctrl+F6 -> grab focus to the thumbnail view.
    
    Change-Id: Ie43d761e7cb0269afb79481a81947a4b96e1dde0
    Reviewed-on: https://gerrit.libreoffice.org/7486
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 32dccde..0a3cf45 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -253,6 +253,7 @@ typedef sal_uInt16 StateChangedType;
 #define GETFOCUS_TAB                    ((sal_uInt16)0x0001)
 #define GETFOCUS_CURSOR                 ((sal_uInt16)0x0002)
 #define GETFOCUS_MNEMONIC               ((sal_uInt16)0x0004)
+#define GETFOCUS_F6                     ((sal_uInt16)0x0008)
 #define GETFOCUS_FORWARD                ((sal_uInt16)0x0010)
 #define GETFOCUS_BACKWARD               ((sal_uInt16)0x0020)
 #define GETFOCUS_AROUND                 ((sal_uInt16)0x0040)
@@ -260,6 +261,7 @@ typedef sal_uInt16 StateChangedType;
 #define GETFOCUS_INIT                   ((sal_uInt16)0x0200)
 #define GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL ((sal_uInt16)0x0400)
 
+
 // Draw-Flags fuer Draw()
 #define WINDOW_DRAW_MONO                ((sal_uLong)0x00000001)
 #define WINDOW_DRAW_NOBORDER            ((sal_uLong)0x00000002)
@@ -481,6 +483,7 @@ public:
     SAL_DLLPRIVATE void        ImplCallMouseMove( sal_uInt16 nMouseCode, sal_Bool bModChanged = sal_False );
     SAL_DLLPRIVATE void        ImplGenerateMouseMove();
     SAL_DLLPRIVATE void        ImplGrabFocus( sal_uInt16 nFlags );
+    SAL_DLLPRIVATE void        ImplGrabFocusToDocument( sal_uInt16 nFlags );
     SAL_DLLPRIVATE void        ImplInvertFocus( const Rectangle& rRect );
     SAL_DLLPRIVATE void        ImplControlFocus( sal_uInt16 nFlags = 0 );
     SAL_DLLPRIVATE Window*     ImplGetDlgWindow( sal_uInt16 n, sal_uInt16 nType, sal_uInt16 nStart = 0, sal_uInt16 nEnd = 0xFFFF, sal_uInt16* pIndex = NULL );
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index eda19f0..d55e4a1 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -891,7 +891,6 @@ void ThumbnailView::Paint( const Rectangle &aRect)
 
 void ThumbnailView::GetFocus()
 {
-    if(GETFOCUS_TAB & GetGetFocusFlags())
     {
         // Select the first item if nothing selected
         int nSelected = -1;
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index daa3d10..70605d8 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -308,6 +308,41 @@ void BackingWindow::Paint( const Rectangle& )
                 aDev );
 }
 
+bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
+{
+    if( rNEvt.GetType() == EVENT_KEYINPUT )
+    {
+        const KeyEvent* pEvt = rNEvt.GetKeyEvent();
+        const KeyCode& rKeyCode(pEvt->GetKeyCode());
+        // Subwindows of BackingWindow: Sidebar and Thumbnail view
+        if( rKeyCode.GetCode() == KEY_F6 )
+        {
+            if( rKeyCode.IsShift() ) // Shift + F6
+            {
+                if( mpAllRecentThumbnails->HasFocus() )
+                {
+                    mpOpenButton->GrabFocus();
+                    return true;
+                }
+            }
+            else if ( rKeyCode.IsMod1() ) // Ctrl + F6
+            {
+                mpAllRecentThumbnails->GrabFocus();
+                return true;
+            }
+            else // F6
+            {
+                if( mpAllButtonsBox->HasChildPathFocus() )
+                {
+                    mpAllRecentThumbnails->GrabFocus();
+                    return true;
+                }
+            }
+        }
+    }
+    return Window::PreNotify( rNEvt );
+}
+
 bool BackingWindow::Notify( NotifyEvent& rNEvt )
 {
     if( rNEvt.GetType() == EVENT_KEYINPUT )
@@ -318,7 +353,6 @@ bool BackingWindow::Notify( NotifyEvent& rNEvt )
             mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
             mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame);
         }
-
         const KeyEvent* pEvt = rNEvt.GetKeyEvent();
         const KeyCode& rKeyCode(pEvt->GetKeyCode());
         if( pEvt && mpAccExec->execute(rKeyCode) )
@@ -328,6 +362,25 @@ bool BackingWindow::Notify( NotifyEvent& rNEvt )
     return Window::Notify( rNEvt );
 }
 
+void BackingWindow::GetFocus()
+{
+    sal_uInt16 nFlags = GetParent()->GetGetFocusFlags();
+    if( nFlags & GETFOCUS_F6 )
+    {
+        if( nFlags & GETFOCUS_FORWARD ) // F6
+        {
+            mpOpenButton->GrabFocus();
+            return;
+        }
+        else // Shift + F6 or Ctrl + F6
+        {
+            mpAllRecentThumbnails->GrabFocus();
+            return;
+        }
+    }
+    Window::GetFocus();
+}
+
 void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
 {
     mxFrame = xFrame;
diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx
index 526a91b..dfa67b0 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -107,7 +107,9 @@ public:
 
     virtual void        Paint( const Rectangle& rRect );
     virtual void        Resize();
+    virtual bool        PreNotify( NotifyEvent& rNEvt );
     virtual bool        Notify( NotifyEvent& rNEvt );
+    virtual void        GetFocus();
 
     virtual Size GetOptimalSize() const;
 
diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx
index 5a5eb0e..459f557 100644
--- a/vcl/source/window/taskpanelist.cxx
+++ b/vcl/source/window/taskpanelist.cxx
@@ -77,13 +77,13 @@ struct LTRSortBackward : public ::std::binary_function< const Window*, const Win
 
 // --------------------------------------------------
 
-static void ImplTaskPaneListGrabFocus( Window *pWindow )
+static void ImplTaskPaneListGrabFocus( Window *pWindow, bool bForward )
 {
     // put focus in child of floating windows which is typically a toolbar
     // that can deal with the focus
     if( pWindow->ImplIsFloatingWindow() && pWindow->GetWindow( WINDOW_FIRSTCHILD ) )
         pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD );
-    pWindow->GrabFocus();
+    pWindow->ImplGrabFocus( GETFOCUS_F6 | (bForward ? GETFOCUS_FORWARD : GETFOCUS_BACKWARD));
 }
 
 // --------------------------------------------------
@@ -195,7 +195,7 @@ sal_Bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent )
                 // Ctrl-F6 goes directly to the document
                 if( !pWin->IsDialog() && aKeyCode.IsMod1() && !aKeyCode.IsShift() )
                 {
-                    pWin->GrabFocusToDocument();
+                    pWin->ImplGrabFocusToDocument( GETFOCUS_F6 );
                     return sal_True;
                 }
 
@@ -210,7 +210,7 @@ sal_Bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent )
                 if( pNextWin != pWin )
                 {
                     ImplGetSVData()->maWinData.mbNoSaveFocus = sal_True;
-                    ImplTaskPaneListGrabFocus( pNextWin );
+                    ImplTaskPaneListGrabFocus( pNextWin, bForward );
                     ImplGetSVData()->maWinData.mbNoSaveFocus = sal_False;
                 }
                 else
@@ -221,7 +221,7 @@ sal_Bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent )
 
                     // we did not find another taskpane, so
                     // put focus back into document
-                    pWin->GrabFocusToDocument();
+                    pWin->ImplGrabFocusToDocument( GETFOCUS_F6 | (bForward ? GETFOCUS_FORWARD : GETFOCUS_BACKWARD));
                 }
 
                 return sal_True;
@@ -240,7 +240,7 @@ sal_Bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent )
                 pWin = FindNextFloat( NULL, bForward );
             if( pWin )
             {
-                ImplTaskPaneListGrabFocus( pWin );
+                ImplTaskPaneListGrabFocus( pWin, bForward );
                 return sal_True;
             }
         }
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 64e535a..a79fecf 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -4167,6 +4167,20 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
     }
 }
 
+void Window::ImplGrabFocusToDocument( sal_uInt16 nFlags )
+{
+    Window *pWin = this;
+    while( pWin )
+    {
+        if( !pWin->GetParent() )
+        {
+            pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->ImplGrabFocus(nFlags);
+            return;
+        }
+        pWin = pWin->GetParent();
+    }
+}
+
 // -----------------------------------------------------------------------
 
 void Window::ImplNewInputContext()
@@ -7506,16 +7520,7 @@ sal_Bool Window::HasFocus() const
 
 void Window::GrabFocusToDocument()
 {
-    Window *pWin = this;
-    while( pWin )
-    {
-        if( !pWin->GetParent() )
-        {
-            pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus();
-            return;
-        }
-        pWin = pWin->GetParent();
-    }
+    ImplGrabFocusToDocument(0);
 }
 
 void Window::SetFakeFocus( bool bFocus )


More information about the Libreoffice-commits mailing list