]> git.sesse.net Git - vlc/commitdiff
skins2(win): fix focus loss when tooltip is displayed
authorErwan Tulou <erwan10@videolan.org>
Sat, 24 Mar 2012 23:32:59 +0000 (00:32 +0100)
committerErwan Tulou <erwan10@videolan.org>
Sat, 24 Mar 2012 23:57:39 +0000 (00:57 +0100)
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.

modules/gui/skins2/win32/win32_tooltip.cpp

index 09585848611b945928e5ec2b598961d7145c5fb2..f7fa7486f4ee3d1528b8129bdbd1e78a2659f677 100644 (file)
@@ -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 );