]> git.sesse.net Git - vlc/blob - modules/gui/skins/win32/win32_run.cpp
* configure.ac.in: bail out with an error message if the x11 skins are enabled and...
[vlc] / modules / gui / skins / win32 / win32_run.cpp
1 /*****************************************************************************
2  * win32_run.cpp:
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: win32_run.cpp,v 1.18 2003/06/03 22:18:58 gbazin Exp $
6  *
7  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8  *          Emmanuel Puig    <karibu@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
23  * USA.
24  *****************************************************************************/
25
26 #ifdef WIN32
27
28 //--- VLC -------------------------------------------------------------------
29 #include <vlc/vlc.h>
30 #include <vlc/intf.h>
31
32 //--- GENERAL ---------------------------------------------------------------
33 #include <windows.h>
34
35 //--- SKIN ------------------------------------------------------------------
36 #include "../os_api.h"
37 #include "../src/event.h"
38 #include "../os_event.h"
39 #include "../src/banks.h"
40 #include "../src/window.h"
41 #include "../os_window.h"
42 #include "../src/theme.h"
43 #include "../os_theme.h"
44 #include "../src/skin_common.h"
45 #include "../src/vlcproc.h"
46
47 //---------------------------------------------------------------------------
48 // Specific method
49 //---------------------------------------------------------------------------
50 bool IsVLCEvent( unsigned int msg );
51 int  SkinManage( intf_thread_t *p_intf );
52
53 //---------------------------------------------------------------------------
54 // Refresh Timer Callback
55 //---------------------------------------------------------------------------
56 void CALLBACK RefreshTimer( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
57 {
58     intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
59         GWLP_USERDATA );
60     SkinManage( p_intf );
61 }
62 //---------------------------------------------------------------------------
63
64
65 //---------------------------------------------------------------------------
66 // Win32 interface
67 //---------------------------------------------------------------------------
68 void OSRun( intf_thread_t *p_intf )
69 {
70     VlcProc *Proc = new VlcProc( p_intf );
71     MSG msg;
72     list<SkinWindow *>::const_iterator win;
73     Event *ProcessEvent;
74     int KeyModifier = 0;
75
76      // Create refresh timer
77     SetTimer( ((OSTheme *)p_intf->p_sys->p_theme)->GetParentWindow(), 42, 200,
78               (TIMERPROC)RefreshTimer );
79
80     // Compute windows message list
81     while( GetMessage( &msg, NULL, 0, 0 ) )
82     {
83
84         for( win = p_intf->p_sys->p_theme->WindowList.begin();
85              win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
86         {
87             if( msg.hwnd == NULL ||
88                 msg.hwnd == ((Win32Window*)(*win))->GetHandle() )
89             {
90                 break;
91             }
92         }
93         if( win == p_intf->p_sys->p_theme->WindowList.end() )
94         {
95 //            DispatchMessage( &msg );
96 //            DefWindowProc( msg.hwnd, msg.message, msg.wParam, msg.lParam );
97         }
98
99         // Translate keys
100         TranslateMessage( &msg );
101
102         // Create event
103         ProcessEvent = (Event *)new OSEvent( p_intf, msg.hwnd, msg.message,
104                                              msg.wParam, msg.lParam );
105
106         /*****************************
107         * Process keyboard shortcuts *
108         *****************************/
109         if( msg.message == WM_KEYUP )
110         {
111             msg_Err( p_intf, "Key : %i (%i)", msg.wParam, KeyModifier );
112             // If key is CTRL
113             if( msg.wParam == 17 )
114                 KeyModifier = 0;
115             else if( KeyModifier == 0 )
116             {
117                 p_intf->p_sys->p_theme->EvtBank->TestShortcut(
118                     msg.wParam, 0 );
119             }
120         }
121         else if( msg.message == WM_KEYDOWN )
122         {
123             // If key is control
124             if( msg.wParam == 17 )
125                 KeyModifier = 2;
126             else if( KeyModifier > 0 )
127             {
128                 p_intf->p_sys->p_theme->EvtBank->TestShortcut(
129                     msg.wParam, KeyModifier );
130             }
131         }
132         else if( msg.message == WM_SYSKEYDOWN )
133         {
134             // If key is ALT
135             if( msg.wParam == 18 )
136                 KeyModifier = 1;
137         }
138         else if( msg.message == WM_SYSKEYUP )
139         {
140             // If key is a system key
141             KeyModifier = 0;
142         }
143
144         /************************
145         * Process timer message *
146         ************************/
147         else if( msg.message == WM_TIMER )
148         {
149             DispatchMessage( &msg );
150         }
151
152         /***********************
153         * VLC specific message *
154         ***********************/
155         else if( IsVLCEvent( msg.message ) )
156         {
157             if( !Proc->EventProc( ProcessEvent ) )
158                 break;      // Exit VLC !
159         }
160
161         /**********************
162         * Broadcasted message *
163         **********************/
164         else if( msg.hwnd == NULL )
165         {
166             for( win = p_intf->p_sys->p_theme->WindowList.begin();
167                  win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
168             {
169                 (*win)->ProcessEvent( ProcessEvent );
170             }
171         }
172
173         /***********************
174         * Process window event *
175         ***********************/
176         else
177         {
178             DispatchMessage( &msg );
179         }
180
181         // Delete event
182         ProcessEvent->DestructParameters();
183         delete (OSEvent *)ProcessEvent;
184
185         // Check if vlc is closing
186         Proc->IsClosing();
187     }
188 }
189 //---------------------------------------------------------------------------
190 bool IsVLCEvent( unsigned int msg )
191 {
192     return( msg > VLC_MESSAGE && msg < VLC_WINDOW );
193 }
194 //---------------------------------------------------------------------------
195
196 #endif