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

Erwan Tulou git at videolan.org
Sun Mar 25 00:59:17 CET 2012


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Mar 25 00:32:59 2012 +0100| [e604141e18e6478581ae253a5bd270cc04391d9c] | committer: Erwan Tulou

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.

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

 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