]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_theme.cpp
* modules/gui/skins/x11/x11_api.cpp: fixed OSAPI_GetScreenSize
[vlc] / modules / gui / skins / x11 / x11_theme.cpp
1 /*****************************************************************************
2  * x11_theme.cpp: X11 implementation of the Theme class
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_theme.cpp,v 1.9 2003/06/01 22:11:24 asmax Exp $
6  *
7  * Authors: Cyril Deguet     <asmax@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
22  * USA.
23  *****************************************************************************/
24
25 #ifdef X11_SKINS
26
27 //--- X11 -------------------------------------------------------------------
28 #include <X11/Xlib.h>
29
30 //--- VLC -------------------------------------------------------------------
31 #include <vlc/intf.h>
32
33 //--- SKIN ------------------------------------------------------------------
34 #include "../os_api.h"
35 #include "../src/banks.h"
36 #include "../src/window.h"
37 #include "../os_window.h"
38 #include "../src/event.h"
39 #include "../os_event.h"
40 #include "../src/theme.h"
41 #include "../os_theme.h"
42 #include "../src/vlcproc.h"
43 #include "../src/skin_common.h"
44
45
46 //---------------------------------------------------------------------------
47 void SkinManage( intf_thread_t *p_intf );
48
49
50 //---------------------------------------------------------------------------
51 // THEME
52 //---------------------------------------------------------------------------
53 X11Theme::X11Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
54 {
55     //Initialize values
56     p_intf = _p_intf;
57     display = p_intf->p_sys->display;
58 }
59
60 //---------------------------------------------------------------------------
61 X11Theme::~X11Theme()
62 {/*
63     // Unregister the window class if needed
64     WNDCLASS wndclass;
65     if( GetClassInfo( hinst, "SkinWindow", &wndclass ) )
66     {
67         UnregisterClass( "SkinWindow", hinst );
68     }
69     if( GetClassInfo( hinst, "ParentWindow", &wndclass ) )
70     {
71         UnregisterClass( "ParentWindow", hinst );
72     }
73
74     // Delete tray icon if exists
75     if( ShowInTray )
76     {
77         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
78     }
79 */
80     // Destroy parent window
81 /*    if( ParentWindow )
82     {
83         gdk_window_destroy( ParentWindow );
84     }*/
85 }
86 //---------------------------------------------------------------------------
87 void X11Theme::OnLoadTheme()
88 {
89 /*    // The create menu
90     CreateSystemMenu();
91 */
92     Window root = DefaultRootWindow( display );
93     XLOCK;
94     p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0, 
95                                                   1, 1, 0, 0, 0 );
96     XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" );
97     XUNLOCK;
98 }
99 //---------------------------------------------------------------------------
100 void X11Theme::AddSystemMenu( string name, Event *event )
101 {/*
102     if( name == "SEPARATOR" )
103     {
104         AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
105     }
106     else
107     {
108         AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
109                     (char *)name.c_str() );
110     }*/
111 }
112 //---------------------------------------------------------------------------
113 void X11Theme::ChangeClientWindowName( string name )
114 {
115     XLOCK;
116     XStoreName( display, p_intf->p_sys->mainWin, name.c_str() );
117     XUNLOCK;
118 }
119 //---------------------------------------------------------------------------
120 void X11Theme::AddWindow( string name, int x, int y, bool visible,
121     int fadetime, int alpha, int movealpha, bool dragdrop )
122 {
123     // Create the window
124     Window root = DefaultRootWindow( display );
125     XSetWindowAttributes attr;
126     XLOCK;
127     Window wnd = XCreateWindow( display, root, 0, 0, 1, 1, 0, 0, InputOutput,
128                                 CopyFromParent, 0, &attr );
129     XSelectInput( display, wnd, ExposureMask|StructureNotifyMask|
130                   KeyPressMask|KeyReleaseMask|ButtonPressMask|
131                   ButtonReleaseMask|PointerMotionMask|EnterWindowMask|
132                   LeaveWindowMask);
133     XUNLOCK;
134
135     // Changing decorations
136     struct {
137         unsigned long flags;
138         unsigned long functions;
139         unsigned long decorations;
140         long input_mode;
141         unsigned long status;
142     } motifWmHints;
143
144     Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
145     
146     motifWmHints.flags = 2;    // MWM_HINTS_DECORATIONS;
147     motifWmHints.decorations = 0;
148     XLOCK;
149     XChangeProperty( display, wnd, hints_atom, hints_atom, 32, 
150                      PropModeReplace, (unsigned char *)&motifWmHints, 
151                      sizeof( motifWmHints ) / sizeof( long ) );
152
153     // Change the window title
154     XStoreName( display, wnd, name.c_str() );
155
156     // Display the window
157     XMapRaised( display, wnd );
158
159     XEvent evt;
160     do 
161     {
162         XNextEvent( display, &evt );
163     } while( evt.type != MapNotify );
164     XUNLOCK;
165
166     WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y, 
167         visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
168 }
169 //---------------------------------------------------------------------------
170 void X11Theme::ChangeTray()
171 {/*
172     if( ShowInTray )
173     {
174         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
175         ShowInTray = false;
176     }
177     else
178     {
179         Shell_NotifyIcon( NIM_ADD, &TrayIcon );
180         ShowInTray = true;
181     }*/
182 }
183 //---------------------------------------------------------------------------
184 void X11Theme::ChangeTaskbar()
185 {/*
186     if( ShowInTaskbar )
187     {
188         ShowWindow( ParentWindow, SW_HIDE );
189         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
190                           WS_EX_LAYERED|WS_EX_TOOLWINDOW );
191         ShowWindow( ParentWindow, SW_SHOW );
192         ShowInTaskbar = false;
193     }
194     else
195     {
196         ShowWindow( ParentWindow, SW_HIDE );
197         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
198                           WS_EX_LAYERED|WS_EX_APPWINDOW );
199         ShowWindow( ParentWindow, SW_SHOW );
200         ShowInTaskbar = true;
201     }*/
202 }
203 //---------------------------------------------------------------------------
204
205 #endif