]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_theme.cpp
5b299e0043a464bb2f313204b185a2f5b86a4c4e
[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.15 2003/06/22 12:46:49 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 }
64 //---------------------------------------------------------------------------
65 void X11Theme::OnLoadTheme()
66 {
67 /*    // The create menu
68     CreateSystemMenu();
69 */
70 }
71 //---------------------------------------------------------------------------
72 void X11Theme::AddSystemMenu( string name, Event *event )
73 {/*
74     if( name == "SEPARATOR" )
75     {
76         AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
77     }
78     else
79     {
80         AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
81                     (char *)name.c_str() );
82     }*/
83 }
84 //---------------------------------------------------------------------------
85 void X11Theme::ChangeClientWindowName( string name )
86 {
87     XLOCK;
88     XStoreName( display, p_intf->p_sys->mainWin, name.c_str() );
89     XUNLOCK;
90 }
91 //---------------------------------------------------------------------------
92 void X11Theme::AddWindow( string name, int x, int y, bool visible,
93     int fadetime, int alpha, int movealpha, bool dragdrop )
94 {
95     // Create the window
96     Window root = DefaultRootWindow( display );
97     XSetWindowAttributes attr;
98     XLOCK;
99     Window wnd = XCreateWindow( display, root, 0, 0, 1, 1, 0, 0, InputOutput,
100                                 CopyFromParent, 0, &attr );
101     XSelectInput( display, wnd, ExposureMask|StructureNotifyMask|
102                   KeyPressMask|KeyReleaseMask|ButtonPressMask|
103                   ButtonReleaseMask|PointerMotionMask|EnterWindowMask|
104                   LeaveWindowMask);
105     XUNLOCK;
106
107     // Changing decorations
108     struct {
109         unsigned long flags;
110         unsigned long functions;
111         unsigned long decorations;
112         long input_mode;
113         unsigned long status;
114     } motifWmHints;
115
116     Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
117
118     motifWmHints.flags = 2;    // MWM_HINTS_DECORATIONS;
119     motifWmHints.decorations = 0;
120     XLOCK;
121     XChangeProperty( display, wnd, hints_atom, hints_atom, 32, 
122                      PropModeReplace, (unsigned char *)&motifWmHints, 
123                      sizeof( motifWmHints ) / sizeof( long ) );
124
125     // Change the window title
126     XStoreName( display, wnd, name.c_str() );
127     XUNLOCK;
128
129     WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y, 
130         visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
131 }
132 //---------------------------------------------------------------------------
133 void X11Theme::ChangeTray()
134 {/*
135     if( ShowInTray )
136     {
137         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
138         ShowInTray = false;
139     }
140     else
141     {
142         Shell_NotifyIcon( NIM_ADD, &TrayIcon );
143         ShowInTray = true;
144     }*/
145 }
146 //---------------------------------------------------------------------------
147 void X11Theme::ChangeTaskbar()
148 {/*
149     if( ShowInTaskbar )
150     {
151         ShowWindow( ParentWindow, SW_HIDE );
152         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
153                           WS_EX_LAYERED|WS_EX_TOOLWINDOW );
154         ShowWindow( ParentWindow, SW_SHOW );
155         ShowInTaskbar = false;
156     }
157     else
158     {
159         ShowWindow( ParentWindow, SW_HIDE );
160         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
161                           WS_EX_LAYERED|WS_EX_APPWINDOW );
162         ShowWindow( ParentWindow, SW_SHOW );
163         ShowInTaskbar = true;
164     }*/
165 }
166 //---------------------------------------------------------------------------
167
168 #endif