1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: gtk2_run.cpp,v 1.8 2003/04/15 20:42:04 karibu 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 //--- GTK2 ------------------------------------------------------------------
31 //--- VLC -------------------------------------------------------------------
34 //--- SKIN ------------------------------------------------------------------
40 #include "os_window.h"
43 #include "skin_common.h"
47 //---------------------------------------------------------------------------
49 //---------------------------------------------------------------------------
50 bool IsVLCEvent( unsigned int msg );
51 int SkinManage( intf_thread_t *p_intf );
55 //---------------------------------------------------------------------------
56 // REFRESH TIMER CALLBACK
57 //---------------------------------------------------------------------------
58 /*void CALLBACK RefreshTimer( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
60 intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
64 //---------------------------------------------------------------------------
66 //---------------------------------------------------------------------------
68 //---------------------------------------------------------------------------
69 void GTK2Proc( GdkEvent *event, gpointer data )
71 // Get pointer to thread info
73 VlcProc *proc = (VlcProc *)data;
74 intf_thread_t *p_intf = proc->GetpIntf();
76 list<Window *>::const_iterator win;
77 GdkWindow *gwnd = ((GdkEventAny *)event)->window;
79 // Create event to dispatch in windows
81 if( event->type == GDK_CLIENT_EVENT )
83 msg = ( (GdkEventClient *)event )->data.l[0];
84 evt = (Event *)new OSEvent( p_intf,
85 ((GdkEventAny *)event)->window,
87 ( (GdkEventClient *)event )->data.l[1],
88 ( (GdkEventClient *)event )->data.l[2] );
94 evt = (Event *)new OSEvent( p_intf,
95 ((GdkEventAny *)event)->window, msg, 0, (long)event );
98 if( IsVLCEvent( msg ) )
100 if( !proc->EventProc( evt ) )
101 return; // Exit VLC !
103 else if( gwnd == NULL )
105 for( win = p_intf->p_sys->p_theme->WindowList.begin();
106 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
108 (*win)->ProcessEvent( evt );
113 // Find window matching with gwnd
114 for( win = p_intf->p_sys->p_theme->WindowList.begin();
115 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
117 // If it is the correct window
118 if( gwnd == ( (GTK2Window *)(*win) )->GetHandle() )
120 // Send event and check if processed
121 if( (*win)->ProcessEvent( evt ) )
123 delete (OSEvent *)evt;
134 delete (OSEvent *)evt;
137 // If Window is parent window
138 if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
140 if( uMsg == WM_SYSCOMMAND )
142 if( (Event *)wParam != NULL )
143 ( (Event *)wParam )->SendEvent();
146 else if( uMsg == WM_RBUTTONDOWN && wParam == 42 &&
147 lParam == WM_RBUTTONDOWN )
150 OSAPI_GetMousePos( x, y );
152 ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetSysMenu(),
153 0, x, y, 0, hwnd, NULL );
158 // If closing parent window
159 if( uMsg == WM_CLOSE )
161 OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );
165 // If hwnd does not match any window or message not processed
166 return DefWindowProc( hwnd, uMsg, wParam, lParam );
169 //---------------------------------------------------------------------------
173 //---------------------------------------------------------------------------
175 //---------------------------------------------------------------------------
176 void OSRun( intf_thread_t *p_intf )
178 // Create VLC event object processing
179 VlcProc *proc = new VlcProc( p_intf );
181 gdk_event_handler_set( GTK2Proc, (gpointer)proc, NULL );
184 GMainLoop *loop = g_main_loop_new( NULL, TRUE );
185 g_main_loop_run( loop );
187 //---------------------------------------------------------------------------
188 bool IsVLCEvent( unsigned int msg )
190 return( msg > VLC_MESSAGE && msg < VLC_WINDOW );
192 //---------------------------------------------------------------------------