]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_event.cpp
* at least it compiles now ;)
[vlc] / modules / gui / skins / x11 / x11_event.cpp
1 /*****************************************************************************
2  * x11_event.cpp: x11 implementation of the Event class
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_event.cpp,v 1.5 2003/06/22 12:54:03 asmax Exp $
6  *
7  * Authors: Cyril Deguet     <asmax@videolan.org>
8  *          Emmanuel Puig    <karibu@via.ecp.fr>
9  *          Olivier Teulière <ipkiss@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
24  * USA.
25  *****************************************************************************/
26
27 #ifdef X11_SKINS
28
29 //--- X11 -------------------------------------------------------------------
30 #include <X11/Xlib.h>
31
32 //--- VLC -------------------------------------------------------------------
33 #include <vlc/intf.h>
34
35 //--- SKIN ------------------------------------------------------------------
36 #include "../os_api.h"
37 #include "../src/event.h"
38 #include "../os_event.h"
39 #include "../src/window.h"
40 #include "../os_window.h"
41 #include "../src/theme.h"
42 #include "../os_theme.h"
43 #include "../src/skin_common.h"
44
45
46 //---------------------------------------------------------------------------
47 //   VLC Event
48 //---------------------------------------------------------------------------
49 X11Event::X11Event( intf_thread_t *p_intf, string Desc, string shortcut )
50     : Event( p_intf, Desc, shortcut )
51 {
52     Wnd = None;
53 }
54 //---------------------------------------------------------------------------
55 X11Event::X11Event( intf_thread_t *p_intf, Window wnd, unsigned int msg,
56     unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
57 {
58     Wnd = wnd;
59 }
60 //---------------------------------------------------------------------------
61 X11Event::X11Event( intf_thread_t *p_intf, SkinWindow *win, unsigned int msg,
62     unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
63 {
64     Wnd = ( (X11Window *)win )->GetHandle();
65 }
66 //---------------------------------------------------------------------------
67 X11Event::~X11Event()
68 {
69 }
70 //---------------------------------------------------------------------------
71 bool X11Event::SendEvent()
72 {
73     if( Message != VLC_NOTHING )
74     {
75         // Find window matching with Wnd
76         list<SkinWindow *>::const_iterator win;
77         for( win = p_intf->p_sys->p_theme->WindowList.begin();
78              win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
79         {
80             // If it is the correct window
81             if( Wnd == ( (X11Window *)(*win) )->GetHandle() )
82             {
83                 OSAPI_PostMessage( *win, Message, Param1, Param2 );
84                 PostSynchroMessage();
85                 return true;
86             }
87         }
88         OSAPI_PostMessage( NULL, Message, Param1, Param2 );
89         return true;
90     }
91
92     return false;
93 }
94 //---------------------------------------------------------------------------
95 bool X11Event::IsEqual( Event *evt )
96 {
97     X11Event *XEvt = (X11Event *)evt;
98     return( XEvt->GetWindow() == Wnd   && XEvt->GetMessage() == Message &&
99             XEvt->GetParam1() == Param1 && XEvt->GetParam2()  == Param2 );
100 }
101 //---------------------------------------------------------------------------
102 void X11Event::CreateOSEvent( string para1, string para2, string para3 )
103 {
104     // Find Parameters
105     switch( Message )
106     {
107         case WINDOW_MOVE:
108             Wnd = GetWindowFromName( para1 );
109             break;
110
111         case WINDOW_CLOSE:
112             Wnd = GetWindowFromName( para1 );
113             break;
114
115         case WINDOW_OPEN:
116             Wnd = GetWindowFromName( para1 );
117             break;
118
119     }
120 }
121 //---------------------------------------------------------------------------
122 Window X11Event::GetWindowFromName( string name )
123 {
124     X11Window *win = (X11Window *)
125         p_intf->p_sys->p_theme->GetWindow( name );
126
127     if( win == NULL )
128     {
129         return None;
130     }
131     else
132     {
133         return win->GetHandle();
134     }
135 }
136 //---------------------------------------------------------------------------
137
138 #endif