]> git.sesse.net Git - vlc/commitdiff
skins2(Linux): support clean exit when user closes vlc via the taskbar
authorErwan Tulou <erwan10@videolan.org>
Thu, 25 Feb 2010 21:28:39 +0000 (22:28 +0100)
committerErwan Tulou <erwan10@videolan.org>
Fri, 26 Feb 2010 22:55:28 +0000 (23:55 +0100)
if not managed, vlc terminates with a "vlc: Fatal IO error: client killed"

modules/gui/skins2/x11/x11_display.cpp
modules/gui/skins2/x11/x11_loop.cpp

index 0a4b954c01ccb69c8d9e86e75889cd340c8a4507..27adb1e722f688ed84e1e0fefce8ec2195dfa2e3 100644 (file)
@@ -209,6 +209,10 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
         m_mainWindow = XCreateWindow( m_pDisplay, root, 0, 0, 1, 1, 0, 0,
                                       InputOutput, CopyFromParent, 0, &attr );
 
+        // Receive WM_DELETE_WINDOW
+        Atom wm_delete = XInternAtom( m_pDisplay, "WM_DELETE_WINDOW", False);
+        XSetWMProtocols( m_pDisplay, m_mainWindow, &wm_delete, 1);
+
         // Changing decorations
         struct {
             unsigned long flags;
index d03cf08c5c8378af7ffafeb65c8d070d13ff1ab8..2436c69c533f0abe375b99aa5115f919db69e856 100644 (file)
@@ -180,6 +180,20 @@ void X11Loop::handleX11Event()
                 // pTheme->getWindowManager().synchVisibility();
             }
         }
+        if( event.type == ClientMessage )
+        {
+            Atom wm_protocols =
+                XInternAtom( XDISPLAY, "WM_PROTOCOLS", False);
+            Atom wm_delete =
+                XInternAtom( XDISPLAY, "WM_DELETE_WINDOW", False);
+
+            if( event.xclient.message_type == wm_protocols &&
+                event.xclient.data.l[0] == wm_delete )
+            {
+                msg_Dbg( getIntf(), "Received WM_DELETE_WINDOW message" );
+                libvlc_Quit( getIntf()->p_libvlc );
+            }
+        }
         return;
     }