1 /*****************************************************************************
2 * x11_theme.cpp: X11 implementation of the Theme class
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: x11_theme.cpp,v 1.10 2003/06/07 10:18:15 gbazin 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 Window root = DefaultRootWindow( display );
94 p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0,
96 XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" );
99 //---------------------------------------------------------------------------
100 void X11Theme::AddSystemMenu( string name, Event *event )
102 if( name == "SEPARATOR" )
104 AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
108 AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
109 (char *)name.c_str() );
112 //---------------------------------------------------------------------------
113 void X11Theme::ChangeClientWindowName( string name )
116 XStoreName( display, p_intf->p_sys->mainWin, name.c_str() );
119 //---------------------------------------------------------------------------
120 void X11Theme::AddWindow( string name, int x, int y, bool visible,
121 int fadetime, int alpha, int movealpha, bool dragdrop )
124 Window root = DefaultRootWindow( display );
125 XSetWindowAttributes attr;
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|
135 // Changing decorations
138 unsigned long functions;
139 unsigned long decorations;
141 unsigned long status;
144 Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
146 motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS;
147 motifWmHints.decorations = 0;
149 XChangeProperty( display, wnd, hints_atom, hints_atom, 32,
150 PropModeReplace, (unsigned char *)&motifWmHints,
151 sizeof( motifWmHints ) / sizeof( long ) );
153 // Change the window title
154 XStoreName( display, wnd, name.c_str() );
157 WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y,
158 visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
160 //---------------------------------------------------------------------------
161 void X11Theme::ChangeTray()
165 Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
170 Shell_NotifyIcon( NIM_ADD, &TrayIcon );
174 //---------------------------------------------------------------------------
175 void X11Theme::ChangeTaskbar()
179 ShowWindow( ParentWindow, SW_HIDE );
180 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
181 WS_EX_LAYERED|WS_EX_TOOLWINDOW );
182 ShowWindow( ParentWindow, SW_SHOW );
183 ShowInTaskbar = false;
187 ShowWindow( ParentWindow, SW_HIDE );
188 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
189 WS_EX_LAYERED|WS_EX_APPWINDOW );
190 ShowWindow( ParentWindow, SW_SHOW );
191 ShowInTaskbar = true;
194 //---------------------------------------------------------------------------