]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_tooltip.cpp
* all: brand new skins interface ( still _experimental_) for x11 and
[vlc] / modules / gui / skins2 / x11 / x11_tooltip.cpp
1 /*****************************************************************************
2  * x11_tooltip.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_tooltip.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
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
47
48 X11Tooltip::~X11Tooltip()
49 {
50     XDestroyWindow( XDISPLAY, m_wnd );
51 }
52
53
54 void X11Tooltip::show( int left, int top, OSGraphics &rText )
55 {
56     // Source drawable
57     Drawable src = ((X11Graphics&)rText).getDrawable();
58     int width = rText.getWidth();
59     int height = rText.getHeight();
60
61     XMoveResizeWindow( XDISPLAY, m_wnd, left, top, width, height );
62     // Show the window
63     XMapRaised( XDISPLAY, m_wnd );
64     // Move it again if the window manager forgets the position
65     XMoveWindow( XDISPLAY, m_wnd, left, top );
66     XCopyArea( XDISPLAY, src, m_wnd, XGC, 0, 0, width, height, 0, 0 );
67 }
68
69
70 void X11Tooltip::hide()
71 {
72     // Unmap the window
73     XUnmapWindow( XDISPLAY, m_wnd );
74 }
75
76
77 #endif