1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
27 #include "../src/generic_window.hpp"
28 #include "x11_display.hpp"
29 #include "x11_graphics.hpp"
30 #include "x11_tooltip.hpp"
32 X11Tooltip::X11Tooltip( intf_thread_t *pIntf,
33 X11Display &rDisplay ):
34 OSTooltip( pIntf ), m_rDisplay( rDisplay )
36 Window root = DefaultRootWindow( XDISPLAY );
37 XSetWindowAttributes attr;
38 // Bypass the window manager
39 attr.override_redirect = True;
42 m_wnd = XCreateWindow( XDISPLAY, root, 0, 0, 1, 1, 0, 0,
43 InputOutput, CopyFromParent, CWOverrideRedirect,
46 // Set the colormap for 8bpp mode
49 XSetWindowColormap( XDISPLAY, m_wnd, m_rDisplay.getColormap() );
54 X11Tooltip::~X11Tooltip()
56 XDestroyWindow( XDISPLAY, m_wnd );
60 void X11Tooltip::show( int left, int top, OSGraphics &rText )
63 Drawable src = ((X11Graphics&)rText).getDrawable();
64 int width = rText.getWidth();
65 int height = rText.getHeight();
67 XMoveResizeWindow( XDISPLAY, m_wnd, left, top, width, height );
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 );
76 void X11Tooltip::hide()
79 XUnmapWindow( XDISPLAY, m_wnd );