]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_tooltip.cpp
3341b3e7bccb4f5f6427ec783be4b1f076d05745
[vlc] / modules / gui / skins2 / x11 / x11_tooltip.cpp
1 /*****************************************************************************
2  * x11_tooltip.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifdef X11_SKINS
26
27 #include "../src/generic_window.hpp"
28 #include "x11_display.hpp"
29 #include "x11_graphics.hpp"
30 #include "x11_tooltip.hpp"
31
32 X11Tooltip::X11Tooltip( intf_thread_t *pIntf,
33                                    X11Display &rDisplay ):
34     OSTooltip( pIntf ), m_rDisplay( rDisplay )
35 {
36     Window root = DefaultRootWindow( XDISPLAY );
37     XSetWindowAttributes attr;
38     // Bypass the window manager
39     attr.override_redirect = True;
40
41     // Create the window
42     m_wnd = XCreateWindow( XDISPLAY, root, 0, 0, 1, 1, 0, 0,
43                            InputOutput, CopyFromParent, CWOverrideRedirect,
44                            &attr );
45
46     // Set the colormap for 8bpp mode
47     if( XPIXELSIZE == 1 )
48     {
49         XSetWindowColormap( XDISPLAY, m_wnd, m_rDisplay.getColormap() );
50     }
51 }
52
53
54 X11Tooltip::~X11Tooltip()
55 {
56     XDestroyWindow( XDISPLAY, m_wnd );
57 }
58
59
60 void X11Tooltip::show( int left, int top, OSGraphics &rText )
61 {
62     // Source drawable
63     Drawable src = ((X11Graphics&)rText).getDrawable();
64     int width = rText.getWidth();
65     int height = rText.getHeight();
66
67     XMoveResizeWindow( XDISPLAY, m_wnd, left, top, width, height );
68     // Show the window
69     XMapRaised( XDISPLAY, m_wnd );
70     // Move it again if the window manager forgets the position
71     XMoveWindow( XDISPLAY, m_wnd, left, top );
72     XCopyArea( XDISPLAY, src, m_wnd, XGC, 0, 0, width, height, 0, 0 );
73 }
74
75
76 void X11Tooltip::hide()
77 {
78     // Unmap the window
79     XUnmapWindow( XDISPLAY, m_wnd );
80 }
81
82
83 #endif