1 /*****************************************************************************
2 * vlcshell.cpp: a VLC plugin for Mozilla
3 *****************************************************************************
4 * Copyright (C) 2002-2005 VideoLAN
7 * Authors: Samuel Hocevar <sam@zoy.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, USA.
22 *****************************************************************************/
24 /* XXX: disable VLC here */
27 /*****************************************************************************
29 *****************************************************************************/
42 #ifdef HAVE_MOZILLA_CONFIG_H
43 # include <mozilla-config.h>
45 #include <nsISupports.h>
49 /* This is from mozilla java, do we really need it? */
54 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
56 #elif defined(XP_MACOSX)
66 # include <Quickdraw.h>
71 # include <X11/Xlib.h>
72 # include <X11/Intrinsic.h>
73 # include <X11/StringDefs.h>
77 #include "vlcplugin.h"
80 # define WINDOW_TEXT "(no picture)"
82 # define WINDOW_TEXT "(no libvlc)"
85 /* Enable/disable debugging printf's for X11 resizing */
86 #undef X11_RESIZE_DEBUG
88 /*****************************************************************************
89 * Unix-only declarations
90 ******************************************************************************/
92 # define VOUT_PLUGINS "xvideo,x11,dummy"
93 # define AOUT_PLUGINS "oss,dummy"
95 static void Redraw( Widget w, XtPointer closure, XEvent *event );
96 static void Resize( Widget w, XtPointer closure, XEvent *event );
99 /*****************************************************************************
100 * MacOS-only declarations
101 ******************************************************************************/
103 # define VOUT_PLUGINS "macosx"
104 # define AOUT_PLUGINS "macosx"
108 /*****************************************************************************
109 * Windows-only declarations
110 *****************************************************************************/
112 # define VOUT_PLUGINS "directx,wingdi,dummy"
113 # define AOUT_PLUGINS "directx,waveout,dummy"
115 #if defined(XP_WIN) && !USE_LIBVLC
116 LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM );
120 /******************************************************************************
121 * UNIX-only API calls
122 *****************************************************************************/
123 char * NPP_GetMIMEDescription( void )
125 return PLUGIN_MIMETYPES;
128 NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
131 static nsIID nsid = VLCINTF_IID;
132 static char psz_desc[1000];
136 case NPPVpluginNameString:
137 *((char **)value) = PLUGIN_NAME;
138 return NPERR_NO_ERROR;
140 case NPPVpluginDescriptionString:
142 snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() );
143 #else /* USE_LIBVLC */
144 snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, "(disabled)" );
145 #endif /* USE_LIBVLC */
146 psz_desc[1000-1] = 0;
147 *((char **)value) = psz_desc;
148 return NPERR_NO_ERROR;
155 if( instance == NULL )
157 return NPERR_INVALID_INSTANCE_ERROR;
160 VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;
164 case NPPVpluginScriptableInstance:
165 *(nsISupports**)value = p_plugin->GetPeer();
166 if( *(nsISupports**)value == NULL )
168 return NPERR_OUT_OF_MEMORY_ERROR;
172 case NPPVpluginScriptableIID:
173 *(nsIID**)value = (nsIID*)NPN_MemAlloc( sizeof(nsIID) );
174 if( *(nsIID**)value == NULL )
176 return NPERR_OUT_OF_MEMORY_ERROR;
178 **(nsIID**)value = nsid;
182 return NPERR_GENERIC_ERROR;
185 return NPERR_NO_ERROR;
188 /******************************************************************************
190 *****************************************************************************/
192 int16 NPP_HandleEvent( NPP instance, void * event )
194 VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
197 if( instance == NULL )
202 EventRecord *pouetEvent = (EventRecord*)event;
204 if (pouetEvent->what == 6)
207 VLC_VariableSet( p_plugin->i_vlc, "drawableredraw", value );
211 Boolean eventHandled = false;
215 #endif /* XP_MACOSX */
217 /******************************************************************************
218 * General Plug-in Calls
219 *****************************************************************************/
220 NPError NPP_Initialize( void )
222 return NPERR_NO_ERROR;
225 jref NPP_GetJavaClass( void )
230 void NPP_Shutdown( void )
235 NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
236 char* argn[], char* argv[], NPSavedData* saved )
244 #endif /* USE_LIBVLC */
246 if( instance == NULL )
248 return NPERR_INVALID_INSTANCE_ERROR;
251 VlcPlugin * p_plugin = new VlcPlugin( instance );
253 if( p_plugin == NULL )
255 return NPERR_OUT_OF_MEMORY_ERROR;
258 instance->pdata = p_plugin;
261 p_plugin->p_hwnd = NULL;
262 p_plugin->pf_wndproc = NULL;
266 p_plugin->window = 0;
267 p_plugin->p_display = NULL;
270 p_plugin->p_npwin = NULL;
271 p_plugin->i_npmode = mode;
272 p_plugin->i_width = 0;
273 p_plugin->i_height = 0;
276 p_plugin->i_vlc = VLC_Create();
277 if( p_plugin->i_vlc < 0 )
282 return NPERR_GENERIC_ERROR;
290 char *ppsz_argv[] = { "vlc", "--plugin-path", NULL };
292 home_user = strdup( getenv("HOME") );
293 directory = strdup( "/Library/Internet Plug-Ins/VLC Plugin.plugin/"
294 "Contents/MacOS/modules" );
295 plugin_path = malloc( strlen( directory ) + strlen( home_user ) );
296 memcpy( plugin_path , home_user , strlen(home_user) );
297 memcpy( plugin_path + strlen( home_user ) , directory ,
298 strlen( directory ) );
300 ppsz_argv[2] = plugin_path;
302 #elif defined(XP_WIN)
303 char *ppsz_argv[] = { NULL, "-vv" };
305 DWORD i_type, i_data = MAX_PATH + 1;
306 char p_data[MAX_PATH + 1];
307 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
308 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
310 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
311 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
313 if( i_type == REG_SZ )
315 strcat( p_data, "\\vlc" );
316 ppsz_argv[0] = p_data;
319 RegCloseKey( h_key );
322 if( !ppsz_argv[0] ) ppsz_argv[0] = "vlc";
324 #else /* XP_MACOSX */
328 /*, "--plugin-path", "/home/sam/videolan/vlc_MAIN/plugins"*/
331 #endif /* XP_MACOSX */
333 /* HACK: special case for loop, to have it set before playlist startup
335 for( i = 0; i < argc ; i++ )
337 if( !strcmp( argn[i], "loop" ) )
339 if( !strcmp( argv[i], "yes" ) )
341 value.b_bool = VLC_TRUE;
342 VLC_VariableSet( p_plugin->i_vlc, "conf::loop", value );
347 i_ret = VLC_Init( p_plugin->i_vlc, sizeof(ppsz_argv)/sizeof(char*),
354 #endif /* XP_MACOSX */
359 VLC_Destroy( p_plugin->i_vlc );
363 return NPERR_GENERIC_ERROR;
366 value.psz_string = "dummy";
367 VLC_VariableSet( p_plugin->i_vlc, "conf::intf", value );
368 value.psz_string = VOUT_PLUGINS;
369 VLC_VariableSet( p_plugin->i_vlc, "conf::vout", value );
370 value.psz_string = AOUT_PLUGINS;
371 VLC_VariableSet( p_plugin->i_vlc, "conf::aout", value );
373 #else /* USE_LIBVLC */
376 #endif /* USE_LIBVLC */
378 p_plugin->b_stream = VLC_FALSE;
379 p_plugin->b_autoplay = VLC_FALSE;
380 p_plugin->psz_target = NULL;
382 for( i = 0; i < argc ; i++ )
384 if( !strcmp( argn[i], "target" ) )
386 p_plugin->psz_target = argv[i];
388 else if( !strcmp( argn[i], "autoplay" ) )
390 if( !strcmp( argv[i], "yes" ) )
392 p_plugin->b_autoplay = 1;
395 else if( !strcmp( argn[i], "autostart" ) )
397 if( !strcmp( argv[i], "1" ) || !strcmp( argv[i], "true" ) )
399 p_plugin->b_autoplay = 1;
402 else if( !strcmp( argn[i], "filename" ) )
404 p_plugin->psz_target = argv[i];
406 else if( !strcmp( argn[i], "src" ) )
408 p_plugin->psz_target = argv[i];
412 else if( !strcmp( argn[i], "fullscreen" ) )
414 if( !strcmp( argv[i], "yes" ) )
416 value.b_bool = VLC_TRUE;
417 VLC_VariableSet( p_plugin->i_vlc, "conf::fullscreen", value );
420 else if( !strcmp( argn[i], "mute" ) )
422 if( !strcmp( argv[i], "yes" ) )
424 VLC_VolumeMute( p_plugin->i_vlc );
427 #endif /* USE_LIBVLC */
430 if( p_plugin->psz_target )
432 p_plugin->psz_target = strdup( p_plugin->psz_target );
435 return NPERR_NO_ERROR;
439 /* This is really ugly but there is a deadlock when stopping a stream
440 * (in VLC_CleanUp()) because the video output is a child of the drawable but
441 * is in a different thread. */
442 static void HackStopVout( VlcPlugin* p_plugin )
448 VLC_VariableGet( p_plugin->i_vlc, "drawable", &value );
450 hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 );
453 PostMessage( hwnd, WM_CLOSE, 0, 0 );
457 while( PeekMessage( &msg, (HWND)value.i_int, 0, 0, PM_REMOVE ) )
459 TranslateMessage(&msg);
460 DispatchMessage(&msg);
462 if( FindWindowEx( (HWND)value.i_int, 0, 0, 0 ) ) Sleep( 10 );
464 while( (hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 )) );
468 NPError NPP_Destroy( NPP instance, NPSavedData** save )
470 if( instance == NULL )
472 return NPERR_INVALID_INSTANCE_ERROR;
475 VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
477 if( p_plugin != NULL )
479 if( p_plugin->i_vlc )
483 HackStopVout( p_plugin );
485 VLC_CleanUp( p_plugin->i_vlc );
486 VLC_Destroy( p_plugin->i_vlc );
487 #endif /* USE_LIBVLC */
491 if( p_plugin->psz_target )
493 free( p_plugin->psz_target );
494 p_plugin->psz_target = NULL;
500 instance->pdata = NULL;
502 return NPERR_NO_ERROR;
505 NPError NPP_SetWindow( NPP instance, NPWindow* window )
517 vlc_value_t valueportx;
518 vlc_value_t valueporty;
521 #endif /* XP_MACOSX */
523 if( instance == NULL )
525 return NPERR_INVALID_INSTANCE_ERROR;
528 VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
530 /* Write the window ID for vlc */
534 value.i_int = ((NP_Port*) (window->window))->port;
535 VLC_VariableSet( p_plugin->i_vlc, "drawable", value );
537 valueportx.i_int = ((NP_Port*) (window->window))->portx;
538 valueporty.i_int = ((NP_Port*) (window->window))->porty;
539 VLC_VariableSet( p_plugin->i_vlc, "drawableportx", valueportx );
540 VLC_VariableSet( p_plugin->i_vlc, "drawableporty", valueporty );
542 valuex.i_int = window->x;
543 valuey.i_int = window->y;
544 valuew.i_int = window->width;
545 valueh.i_int = window->height;
546 valuet.i_int = window->clipRect.top;
547 valuel.i_int = window->clipRect.left;
548 valueb.i_int = window->clipRect.bottom;
549 valuer.i_int = window->clipRect.right;
551 VLC_VariableSet( p_plugin->i_vlc, "drawablet", valuet );
552 VLC_VariableSet( p_plugin->i_vlc, "drawablel", valuel );
553 VLC_VariableSet( p_plugin->i_vlc, "drawableb", valueb );
554 VLC_VariableSet( p_plugin->i_vlc, "drawabler", valuer );
555 VLC_VariableSet( p_plugin->i_vlc, "drawablex", valuex );
556 VLC_VariableSet( p_plugin->i_vlc, "drawabley", valuey );
557 VLC_VariableSet( p_plugin->i_vlc, "drawablew", valuew );
558 VLC_VariableSet( p_plugin->i_vlc, "drawableh", valueh );
560 p_plugin->window = window;
562 /* draw the beautiful "No Picture" */
564 black_rect.top = valuet.i_int - valuey.i_int;
565 black_rect.left = valuel.i_int - valuex.i_int;
566 black_rect.bottom = valueb.i_int - valuey.i_int;
567 black_rect.right = valuer.i_int - valuex.i_int;
569 SetPort( value.i_int );
570 SetOrigin( valueportx.i_int , valueporty.i_int );
571 ForeColor(blackColor);
573 PaintRect( &black_rect );
575 ForeColor(whiteColor);
576 text = strdup( WINDOW_TEXT );
577 MoveTo( valuew.i_int / 2 - 40 , valueh.i_int / 2 );
578 DrawText( text , 0 , strlen(text) );
581 #else /* XP_MACOSX */
582 /* FIXME: this cast sucks */
583 value.i_int = (int) (ptrdiff_t) (void *) window->window;
584 VLC_VariableSet( p_plugin->i_vlc, "drawable", value );
585 #endif /* XP_MACOSX */
587 #endif /* USE_LIBVLC */
591 * Before setting window to point to the
592 * new window, you may wish to compare the new window
593 * info to the previous window (if any) to note window
598 if( !window || !window->window )
600 /* Window was destroyed. Invalidate everything. */
601 if( p_plugin->p_npwin )
604 SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
605 (LONG)p_plugin->pf_wndproc );
606 #endif /* !USE_LIBVLC */
607 p_plugin->pf_wndproc = NULL;
608 p_plugin->p_hwnd = NULL;
611 p_plugin->p_npwin = window;
612 return NPERR_NO_ERROR;
615 if( p_plugin->p_npwin )
617 if( p_plugin->p_hwnd == (HWND)window->window )
619 /* Same window, but something may have changed. First we
620 * update the plugin structure, then we redraw the window */
621 p_plugin->i_width = window->width;
622 p_plugin->i_height = window->height;
623 p_plugin->p_npwin = window;
625 InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
626 UpdateWindow( p_plugin->p_hwnd );
627 #endif /* !USE_LIBVLC */
628 return NPERR_NO_ERROR;
631 /* Window has changed. Destroy the one we have, and go
632 * on as if it was a real initialization. */
634 SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
635 (LONG)p_plugin->pf_wndproc );
636 #endif /* !USE_LIBVLC */
637 p_plugin->pf_wndproc = NULL;
638 p_plugin->p_hwnd = NULL;
642 p_plugin->pf_wndproc = (WNDPROC)SetWindowLong( (HWND)window->window,
643 GWL_WNDPROC, (LONG)Manage );
644 #endif /* !USE_LIBVLC */
646 p_plugin->p_hwnd = (HWND)window->window;
647 SetProp( p_plugin->p_hwnd, "w00t", (HANDLE)p_plugin );
648 InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
649 UpdateWindow( p_plugin->p_hwnd );
652 p_plugin->i_width = window->width;
653 p_plugin->i_height = window->height;
654 p_plugin->p_npwin = window;
657 p_plugin->window = (Window) window->window;
658 p_plugin->p_display =
659 ((NPSetWindowCallbackStruct *)window->ws_info)->display;
661 XResizeWindow( p_plugin->p_display, p_plugin->window,
662 p_plugin->i_width, p_plugin->i_height );
663 Widget w = XtWindowToWidget( p_plugin->p_display, p_plugin->window );
664 XtAddEventHandler( w, ExposureMask, FALSE,
665 (XtEventHandler)Redraw, p_plugin );
666 XtAddEventHandler( w, StructureNotifyMask, FALSE,
667 (XtEventHandler)Resize, p_plugin );
668 Redraw( w, (XtPointer)p_plugin, NULL );
671 if( !p_plugin->b_stream )
673 int i_mode = PLAYLIST_APPEND;
675 if( p_plugin->b_autoplay )
677 i_mode |= PLAYLIST_GO;
680 if( p_plugin->psz_target )
683 VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
684 0, 0, PLAYLIST_INSERT, 0 );
686 p_plugin->b_stream = VLC_TRUE;
690 return NPERR_NO_ERROR;
693 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
694 NPBool seekable, uint16 *stype )
696 if( instance == NULL )
698 return NPERR_INVALID_INSTANCE_ERROR;
702 VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
705 /* fprintf(stderr, "NPP_NewStream - FILE mode !!\n"); */
707 /* We want a *filename* ! */
711 if( !p_plugin->b_stream )
713 p_plugin->psz_target = strdup( stream->url );
714 p_plugin->b_stream = VLC_TRUE;
718 return NPERR_NO_ERROR;
721 int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
722 * mode so we can take any size stream in our
723 * write call (since we ignore it) */
725 #define SARASS_SIZE (1024*1024)
727 int32 NPP_WriteReady( NPP instance, NPStream *stream )
731 /* fprintf(stderr, "NPP_WriteReady\n"); */
733 if (instance != NULL)
735 p_plugin = (VlcPlugin*) instance->pdata;
736 /* Muahahahahahahaha */
737 return STREAMBUFSIZE;
738 /*return SARASS_SIZE;*/
741 /* Number of bytes ready to accept in NPP_Write() */
742 return STREAMBUFSIZE;
747 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
748 int32 len, void *buffer )
750 /* fprintf(stderr, "NPP_Write %i\n", (int)len); */
752 if( instance != NULL )
754 /*VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;*/
757 return len; /* The number of bytes accepted */
761 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
763 if( instance == NULL )
765 return NPERR_INVALID_INSTANCE_ERROR;
768 return NPERR_NO_ERROR;
772 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
774 if( instance == NULL )
779 /* fprintf(stderr, "NPP_StreamAsFile %s\n", fname); */
782 VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
784 VLC_AddTarget( p_plugin->i_vlc, fname, 0, 0,
785 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
786 #endif /* USE_LIBVLC */
790 void NPP_URLNotify( NPP instance, const char* url,
791 NPReason reason, void* notifyData )
793 /***** Insert NPP_URLNotify code here *****\
794 PluginInstance* p_plugin;
795 if (instance != NULL)
796 p_plugin = (PluginInstance*) instance->pdata;
797 \*********************************************/
801 void NPP_Print( NPP instance, NPPrint* printInfo )
803 if( printInfo == NULL )
808 if( instance != NULL )
810 /***** Insert NPP_Print code here *****\
811 PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
812 \**************************************/
814 if( printInfo->mode == NP_FULL )
818 * If your plugin would like to take over
819 * printing completely when it is in full-screen mode,
820 * set printInfo->pluginPrinted to TRUE and print your
821 * plugin as you see fit. If your plugin wants Netscape
822 * to handle printing in this case, set
823 * printInfo->pluginPrinted to FALSE (the default) and
824 * do nothing. If you do want to handle printing
825 * yourself, printOne is true if the print button
826 * (as opposed to the print menu) was clicked.
827 * On the Macintosh, platformPrint is a THPrint; on
828 * Windows, platformPrint is a structure
829 * (defined in npapi.h) containing the printer name, port,
833 /***** Insert NPP_Print code here *****\
834 void* platformPrint =
835 printInfo->print.fullPrint.platformPrint;
837 printInfo->print.fullPrint.printOne;
838 \**************************************/
841 printInfo->print.fullPrint.pluginPrinted = FALSE;
845 /* If not fullscreen, we must be embedded */
848 * If your plugin is embedded, or is full-screen
849 * but you returned false in pluginPrinted above, NPP_Print
850 * will be called with mode == NP_EMBED. The NPWindow
851 * in the printInfo gives the location and dimensions of
852 * the embedded plugin on the printed page. On the
853 * Macintosh, platformPrint is the printer port; on
854 * Windows, platformPrint is the handle to the printing
858 /***** Insert NPP_Print code here *****\
859 NPWindow* printWindow =
860 &(printInfo->print.embedPrint.window);
861 void* platformPrint =
862 printInfo->print.embedPrint.platformPrint;
863 \**************************************/
868 /******************************************************************************
869 * Windows-only methods
870 *****************************************************************************/
871 #if defined(XP_WIN) && !USE_LIBVLC
872 LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
874 VlcPlugin* p_plugin = (VlcPlugin*) GetProp( p_hwnd, "w00t" );
880 PAINTSTRUCT paintstruct;
884 hdc = BeginPaint( p_hwnd, &paintstruct );
886 GetClientRect( p_hwnd, &rect );
887 FillRect( hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH) );
888 TextOut( hdc, p_plugin->i_width / 2 - 40, p_plugin->i_height / 2,
889 WINDOW_TEXT, strlen(WINDOW_TEXT) );
891 EndPaint( p_hwnd, &paintstruct );
895 p_plugin->pf_wndproc( p_hwnd, i_msg, wpar, lpar );
902 /******************************************************************************
904 *****************************************************************************/
906 static void Redraw( Widget w, XtPointer closure, XEvent *event )
908 VlcPlugin* p_plugin = (VlcPlugin*)closure;
912 gcv.foreground = BlackPixel( p_plugin->p_display, 0 );
913 gc = XCreateGC( p_plugin->p_display, p_plugin->window, GCForeground, &gcv );
915 XFillRectangle( p_plugin->p_display, p_plugin->window, gc,
916 0, 0, p_plugin->i_width, p_plugin->i_height );
918 gcv.foreground = WhitePixel( p_plugin->p_display, 0 );
919 XChangeGC( p_plugin->p_display, gc, GCForeground, &gcv );
921 XDrawString( p_plugin->p_display, p_plugin->window, gc,
922 p_plugin->i_width / 2 - 40, p_plugin->i_height / 2,
923 WINDOW_TEXT, strlen(WINDOW_TEXT) );
925 XFreeGC( p_plugin->p_display, gc );
928 static void Resize ( Widget w, XtPointer closure, XEvent *event )
930 VlcPlugin* p_plugin = (VlcPlugin*)closure;
932 Window root_return, parent_return, * children_return;
934 unsigned int i_nchildren;
936 #ifdef X11_RESIZE_DEBUG
937 XWindowAttributes attr;
939 if( event && event->type == ConfigureNotify )
941 fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, "
942 "send_event ? %s\n", event->xconfigure.width,
943 event->xconfigure.height,
944 event->xconfigure.send_event ? "TRUE" : "FALSE" );
946 #endif /* X11_RESIZE_DEBUG */
948 i_ret = XResizeWindow( p_plugin->p_display, p_plugin->window,
949 p_plugin->i_width, p_plugin->i_height );
951 #ifdef X11_RESIZE_DEBUG
953 "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret );
955 XGetWindowAttributes ( p_plugin->p_display, p_plugin->window, &attr );
957 /* X is asynchronous, so the current size reported here is not
958 necessarily the requested size as the Resize request may not
959 yet have been handled by the plugin host */
960 fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n",
961 attr.width, attr.height );
962 #endif /* X11_RESIZE_DEBUG */
964 XQueryTree( p_plugin->p_display, p_plugin->window,
965 &root_return, &parent_return, &children_return,
968 if( i_nchildren > 0 )
970 /* XXX: Make assumptions related to the window parenting structure in
971 vlc/modules/video_output/x11/xcommon.c */
972 base_window = children_return[i_nchildren - 1];
974 #ifdef X11_RESIZE_DEBUG
975 fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren );
976 fprintf( stderr, "vlcshell::Resize() got base_window %p\n",
978 #endif /* X11_RESIZE_DEBUG */
980 i_ret = XResizeWindow( p_plugin->p_display, base_window,
981 p_plugin->i_width, p_plugin->i_height );
983 #ifdef X11_RESIZE_DEBUG
985 "vlcshell::Resize() XResizeWindow(base) returned %d\n",
988 XGetWindowAttributes( p_plugin->p_display, base_window, &attr );
990 fprintf( stderr, "vlcshell::Resize() new size %d x %d\n",
991 attr.width, attr.height );
992 #endif /* X11_RESIZE_DEBUG */