1 /*****************************************************************************
2 * x11_theme.cpp: X11 implementation of the Theme class
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: x11_theme.cpp,v 1.6 2003/05/29 16:48:29 asmax Exp $
7 * Authors: Cyril Deguet <asmax@videolan.org>
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.
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.
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,
23 *****************************************************************************/
27 //--- X11 -------------------------------------------------------------------
30 //--- VLC -------------------------------------------------------------------
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"
46 //---------------------------------------------------------------------------
47 void SkinManage( intf_thread_t *p_intf );
50 //---------------------------------------------------------------------------
52 //---------------------------------------------------------------------------
53 X11Theme::X11Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
57 display = p_intf->p_sys->display;
60 //---------------------------------------------------------------------------
63 // Unregister the window class if needed
65 if( GetClassInfo( hinst, "SkinWindow", &wndclass ) )
67 UnregisterClass( "SkinWindow", hinst );
69 if( GetClassInfo( hinst, "ParentWindow", &wndclass ) )
71 UnregisterClass( "ParentWindow", hinst );
74 // Delete tray icon if exists
77 Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
80 // Destroy parent window
83 gdk_window_destroy( ParentWindow );
86 //---------------------------------------------------------------------------
87 void X11Theme::OnLoadTheme()
92 // Set the parent window attributes
93 /* GdkWindowAttr attr;
94 attr.title = "VLC Media Player";
95 attr.event_mask = GDK_ALL_EVENTS_MASK;
100 attr.window_type = GDK_WINDOW_TOPLEVEL;
101 attr.wclass = GDK_INPUT_ONLY;
102 attr.override_redirect = FALSE;
104 gint mask = GDK_WA_TITLE|GDK_WA_X|GDK_WA_Y|GDK_WA_NOREDIR;
106 // Create the parent window
107 ParentWindow = gdk_window_new( NULL, &attr, mask);
110 msg_Err( p_intf, "gdk_window_new failed" );
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);
120 XMapRaised( display, ParentWindow );
123 //---------------------------------------------------------------------------
124 void X11Theme::AddSystemMenu( string name, Event *event )
126 if( name == "SEPARATOR" )
128 AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
132 AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
133 (char *)name.c_str() );
136 //---------------------------------------------------------------------------
137 void X11Theme::ChangeClientWindowName( string name )
139 SetWindowText( ParentWindow, name.c_str() );*/
141 //---------------------------------------------------------------------------
142 void X11Theme::AddWindow( string name, int x, int y, bool visible,
143 int fadetime, int alpha, int movealpha, bool dragdrop )
145 /* GdkWindowAttr attr;
146 attr.title = (gchar *)name.c_str();
147 attr.event_mask = GDK_ALL_EVENTS_MASK;
150 attr.window_type = GDK_WINDOW_TOPLEVEL;
151 attr.wclass = GDK_INPUT_OUTPUT;
152 attr.override_redirect = FALSE;
154 gint mask = GDK_WA_NOREDIR;
157 GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
160 msg_Err( p_intf, "gdk_window_new failed" );
164 gdk_window_set_decorations( gwnd, (GdkWMDecoration)0 );
166 gdk_window_show( gwnd );*/
169 Window root = DefaultRootWindow( display );
170 XSetWindowAttributes attr;
171 Window wnd = XCreateWindow( display, root, 0, 0, 1, 1, 0, 0, InputOutput,
172 CopyFromParent, 0, &attr );
173 XSelectInput( display, wnd, ExposureMask|StructureNotifyMask|
174 KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|
175 PointerMotionMask|EnterWindowMask|LeaveWindowMask);
177 // Changing decorations
180 unsigned long functions;
181 unsigned long decorations;
183 unsigned long status;
186 Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
188 motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS;
189 motifWmHints.decorations = 0;
191 XChangeProperty( display, wnd, hints_atom, hints_atom, 32,
192 PropModeReplace, (unsigned char *)&motifWmHints,
193 sizeof( motifWmHints ) / sizeof( long ) );
195 // Display the window
196 XMapRaised( display, wnd );
201 XNextEvent( display, &evt );
202 } while( evt.type != MapNotify );
204 WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y,
205 visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
207 //---------------------------------------------------------------------------
208 void X11Theme::ChangeTray()
212 Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
217 Shell_NotifyIcon( NIM_ADD, &TrayIcon );
221 //---------------------------------------------------------------------------
222 void X11Theme::ChangeTaskbar()
226 ShowWindow( ParentWindow, SW_HIDE );
227 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
228 WS_EX_LAYERED|WS_EX_TOOLWINDOW );
229 ShowWindow( ParentWindow, SW_SHOW );
230 ShowInTaskbar = false;
234 ShowWindow( ParentWindow, SW_HIDE );
235 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
236 WS_EX_LAYERED|WS_EX_APPWINDOW );
237 ShowWindow( ParentWindow, SW_SHOW );
238 ShowInTaskbar = true;
241 //---------------------------------------------------------------------------