]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_theme.cpp
* events aren't perfect yet, but it is better enough to commit
[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.4 2003/05/24 21:28:29 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     ParentWindow = 0;
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     // Set the parent window attributes
93 /*    GdkWindowAttr attr;
94     attr.title = "VLC Media Player";
95     attr.event_mask = GDK_ALL_EVENTS_MASK;
96     attr.x = 0;
97     attr.y = 0;
98     attr.width = 0;
99     attr.height = 0;
100     attr.window_type = GDK_WINDOW_TOPLEVEL;
101     attr.wclass = GDK_INPUT_ONLY;
102     attr.override_redirect = FALSE;
103     
104     gint mask = GDK_WA_TITLE|GDK_WA_X|GDK_WA_Y|GDK_WA_NOREDIR;
105     
106     // Create the parent window
107     ParentWindow = gdk_window_new( NULL, &attr, mask);
108     if( !ParentWindow )
109     {
110         msg_Err( p_intf, "gdk_window_new failed" );
111         return;
112     }*/
113
114 /*    Window root = DefaultRootWindow( display );
115     ParentWindow = XCreateSimpleWindow( display, root, 0, 0, 100, 100, 0, 0, 0 );
116     XSelectInput( display, ParentWindow, ExposureMask|
117             KeyPressMask|KeyReleaseMask|ButtonPressMask|PointerMotionMask|
118             PointerMotionHintMask| EnterWindowMask|LeaveWindowMask);
119
120     XMapRaised( display, ParentWindow );
121     XFlush( display );*/
122 }
123 //---------------------------------------------------------------------------
124 void X11Theme::AddSystemMenu( string name, Event *event )
125 {/*
126     if( name == "SEPARATOR" )
127     {
128         AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
129     }
130     else
131     {
132         AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
133                     (char *)name.c_str() );
134     }*/
135 }
136 //---------------------------------------------------------------------------
137 void X11Theme::ChangeClientWindowName( string name )
138 {/*
139     SetWindowText( ParentWindow, name.c_str() );*/
140 }
141 //---------------------------------------------------------------------------
142 void X11Theme::AddWindow( string name, int x, int y, bool visible,
143     int fadetime, int alpha, int movealpha, bool dragdrop )
144 {
145 /*    GdkWindowAttr attr;
146     attr.title = (gchar *)name.c_str();
147     attr.event_mask = GDK_ALL_EVENTS_MASK;
148     attr.width = 0;
149     attr.height = 0;
150     attr.window_type = GDK_WINDOW_TOPLEVEL;
151     attr.wclass = GDK_INPUT_OUTPUT;
152     attr.override_redirect = FALSE;
153
154     gint mask = GDK_WA_NOREDIR;
155
156     // Create the window
157     GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
158     if( !gwnd )
159     {
160         msg_Err( p_intf, "gdk_window_new failed" );
161         return;
162     }
163
164     gdk_window_set_decorations( gwnd, (GdkWMDecoration)0 );
165
166     gdk_window_show( gwnd );*/
167
168     // Create the window
169     Window root = DefaultRootWindow( display );
170     Window wnd = XCreateSimpleWindow( display, root, 0, 0, 1, 1, 0, 0, 0 );
171     XSelectInput( display, wnd, ExposureMask|
172             KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|
173             PointerMotionMask|EnterWindowMask|LeaveWindowMask);
174
175     // Changing decorations
176     struct {
177         unsigned long flags;
178         unsigned long functions;
179         unsigned long decorations;
180         long input_mode;
181         unsigned long status;
182     } motifWmHints;
183
184     Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
185     
186     motifWmHints.flags = 2;    // MWM_HINTS_DECORATIONS;
187     motifWmHints.decorations = 0;
188
189     XChangeProperty( display, wnd, hints_atom, hints_atom, 32, 
190                      PropModeReplace, (unsigned char *)&motifWmHints, 
191                      sizeof( motifWmHints ) / sizeof( long ) );
192
193     // Display the window
194     XMapRaised( display, wnd );
195     XSync( display, False );
196
197     WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y, 
198         visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
199 }
200 //---------------------------------------------------------------------------
201 void X11Theme::ChangeTray()
202 {/*
203     if( ShowInTray )
204     {
205         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
206         ShowInTray = false;
207     }
208     else
209     {
210         Shell_NotifyIcon( NIM_ADD, &TrayIcon );
211         ShowInTray = true;
212     }*/
213 }
214 //---------------------------------------------------------------------------
215 void X11Theme::ChangeTaskbar()
216 {/*
217     if( ShowInTaskbar )
218     {
219         ShowWindow( ParentWindow, SW_HIDE );
220         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
221                           WS_EX_LAYERED|WS_EX_TOOLWINDOW );
222         ShowWindow( ParentWindow, SW_SHOW );
223         ShowInTaskbar = false;
224     }
225     else
226     {
227         ShowWindow( ParentWindow, SW_HIDE );
228         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
229                           WS_EX_LAYERED|WS_EX_APPWINDOW );
230         ShowWindow( ParentWindow, SW_SHOW );
231         ShowInTaskbar = true;
232     }*/
233 }
234 //---------------------------------------------------------------------------
235
236 #endif