[vlc-commits] skins2(win): fix focus loss when tooltip is displayed

Erwan Tulou git at videolan.org
Mon Mar 26 18:44:53 CEST 2012


vlc/vlc-2.0 | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Mar 25 00:32:59 2012 +0100| [b0b365ce55b2809cfaaa8deb6ed205e54f8db846] | committer: Jean-Baptiste Kempf

skins2(win): fix focus loss when tooltip is displayed

Till now, when a tooltip showed up, the underlying main window lost
keyboard focus (keys + mouse wheel). Users had to click again on the window
to regain this focus.

this patch mainly uses a flag that enables to display a window without
activating it (see msdn doc) plus a bit of cosmetics.

this patch should be backported.
(cherry picked from commit e604141e18e6478581ae253a5bd270cc04391d9c)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=b0b365ce55b2809cfaaa8deb6ed205e54f8db846
---

 modules/gui/skins2/win32/win32_tooltip.cpp |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/win32/win32_tooltip.cpp b/modules/gui/skins2/win32/win32_tooltip.cpp
index 0958584..f7fa748 100644
--- a/modules/gui/skins2/win32/win32_tooltip.cpp
+++ b/modules/gui/skins2/win32/win32_tooltip.cpp
@@ -34,14 +34,13 @@ Win32Tooltip::Win32Tooltip( intf_thread_t *pIntf, HINSTANCE hInst,
 {
     // Create the window
     m_hWnd = CreateWindowEx( WS_EX_TOOLWINDOW,
-        "SkinWindowClass", "default name", WS_POPUP, CW_USEDEFAULT,
-        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hParentWindow, 0,
-        hInst, NULL );
+        "SkinWindowClass", "tooltip", WS_POPUP | WS_DISABLED,
+        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+        hParentWindow, 0, hInst, NULL );
 
     if( !m_hWnd )
     {
         msg_Err( getIntf(), "createWindow failed" );
-        return;
     }
 }
 
@@ -60,9 +59,11 @@ void Win32Tooltip::show( int left, int top, OSGraphics &rText )
     int width = rText.getWidth();
     int height = rText.getHeight();
 
-    // Set the window on top, resize it and show it
-    SetWindowPos( m_hWnd, HWND_TOPMOST, left, top, width, height, 0 );
-    ShowWindow( m_hWnd, SW_SHOW );
+    // Set the window on top, resize it, and show it
+    // SWP_NOACTIVATE is needed to make sure the underlying window
+    // keeps the keyboard focus ( keys + mouse_wheel )
+    SetWindowPos( m_hWnd, HWND_TOPMOST, left, top, width, height,
+                  SWP_NOACTIVATE | SWP_SHOWWINDOW );
 
     HDC wndDC = GetDC( m_hWnd );
     BitBlt( wndDC, 0, 0, width, height, srcDC, 0, 0, SRCCOPY );



More information about the vlc-commits mailing list