1 /*****************************************************************************
2 * vlcshell.cpp: a VLC plugin for Mozilla
3 *****************************************************************************
4 * Copyright (C) 2002-2005 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
34 #ifdef HAVE_MOZILLA_CONFIG_H
35 # include <mozilla-config.h>
38 /* This is from mozilla java, do we really need it? */
43 #include "vlcplugin.h"
45 /* Enable/disable debugging printf's for X11 resizing */
46 #undef X11_RESIZE_DEBUG
48 #define WINDOW_TEXT "Video is loading..."
50 /*****************************************************************************
51 * Unix-only declarations
52 ******************************************************************************/
55 static void Redraw( Widget w, XtPointer closure, XEvent *event );
56 static void ControlHandler( Widget w, XtPointer closure, XEvent *event );
57 static void Resize( Widget w, XtPointer closure, XEvent *event );
61 /*****************************************************************************
62 * MacOS-only declarations
63 ******************************************************************************/
67 /*****************************************************************************
68 * Windows-only declarations
69 *****************************************************************************/
72 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar );
76 /******************************************************************************
78 *****************************************************************************/
79 char * NPP_GetMIMEDescription( void )
81 return PLUGIN_MIMETYPES;
84 NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
87 static char psz_desc[1000];
89 /* plugin class variables */
92 case NPPVpluginNameString:
93 *((char **)value) = PLUGIN_NAME;
94 return NPERR_NO_ERROR;
96 case NPPVpluginDescriptionString:
97 snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, VLC_Version() );
98 *((char **)value) = psz_desc;
99 return NPERR_NO_ERROR;
102 /* move on to instance variables ... */
106 if( instance == NULL )
108 return NPERR_INVALID_INSTANCE_ERROR;
111 /* plugin instance variables */
113 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
114 if( NULL == p_plugin )
116 // plugin has not been initialized yet !
117 return NPERR_INVALID_INSTANCE_ERROR;
122 case NPPVpluginScriptableNPObject:
124 /* retrieve plugin root class */
125 NPClass *scriptClass = p_plugin->getScriptClass();
128 /* create an instance and return it */
129 *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
130 return NPERR_NO_ERROR;
138 return NPERR_GENERIC_ERROR;
142 * there is some confusion in gecko headers regarding definition of this API
143 * NPPVariable is wrongly defined as NPNVariable, which sounds incorrect.
146 NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value )
148 return NPERR_GENERIC_ERROR;
151 /******************************************************************************
153 *****************************************************************************/
155 int16 NPP_HandleEvent( NPP instance, void * event )
157 static UInt32 lastMouseUp = 0;
159 if( instance == NULL )
164 VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
166 if( p_plugin == NULL )
171 EventRecord *myEvent = (EventRecord*)event;
173 switch( myEvent->what )
179 if( (myEvent->when - lastMouseUp) < GetDblTime() )
182 libvlc_instance_t *p_vlc = p_plugin->getVLC();
186 if( libvlc_playlist_isplaying(p_vlc, NULL) )
188 libvlc_media_instance_t *p_md =
189 libvlc_playlist_get_media_instance(p_vlc, NULL);
192 libvlc_toggle_fullscreen(p_md, NULL);
193 libvlc_media_instance_release(p_md);
201 lastMouseUp = myEvent->when;
209 const NPWindow& npwindow = p_plugin->getWindow();
210 if( npwindow.window )
213 libvlc_instance_t *p_vlc = p_plugin->getVLC();
217 if( libvlc_playlist_isplaying(p_vlc, NULL) )
219 libvlc_media_instance_t *p_md =
220 libvlc_playlist_get_media_instance(p_vlc, NULL);
223 hasVout = libvlc_media_instance_has_vout(p_md, NULL);
226 libvlc_rectangle_t area;
229 area.right = npwindow.width;
230 area.bottom = npwindow.height;
231 libvlc_video_redraw_rectangle(p_md, &area, NULL);
233 libvlc_media_instance_release(p_md);
240 /* draw the beautiful "No Picture" */
242 ForeColor(blackColor);
245 /* seems that firefox forgets to set the following on occasion (reload) */
246 SetOrigin(((NP_Port *)npwindow.window)->portx,
247 ((NP_Port *)npwindow.window)->porty);
252 rect.right = npwindow.width;
253 rect.bottom = npwindow.height;
256 ForeColor(whiteColor);
257 MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
258 DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
265 case NPEventType_GetFocusEvent:
266 case NPEventType_LoseFocusEvent:
268 case NPEventType_AdjustCursorEvent:
270 case NPEventType_MenuCommandEvent:
272 case NPEventType_ClippingChangedEvent:
274 case NPEventType_ScrollingBeginsEvent:
276 case NPEventType_ScrollingEndsEvent:
283 #endif /* XP_MACOSX */
285 /******************************************************************************
286 * General Plug-in Calls
287 *****************************************************************************/
288 NPError NPP_Initialize( void )
290 return NPERR_NO_ERROR;
293 jref NPP_GetJavaClass( void )
298 void NPP_Shutdown( void )
303 NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
304 char* argn[], char* argv[], NPSavedData* saved )
308 if( instance == NULL )
310 return NPERR_INVALID_INSTANCE_ERROR;
313 VlcPlugin * p_plugin = new VlcPlugin( instance, mode );
314 if( NULL == p_plugin )
316 return NPERR_OUT_OF_MEMORY_ERROR;
319 status = p_plugin->init(argc, argn, argv);
320 if( NPERR_NO_ERROR == status )
322 instance->pdata = reinterpret_cast<void*>(p_plugin);
324 NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false);
325 NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false);
335 NPError NPP_Destroy( NPP instance, NPSavedData** save )
337 if( NULL == instance )
338 return NPERR_INVALID_INSTANCE_ERROR;
340 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
341 if( NULL == p_plugin )
342 return NPERR_NO_ERROR;
344 instance->pdata = NULL;
347 HWND win = (HWND)p_plugin->getWindow().window;
348 WNDPROC winproc = p_plugin->getWindowProc();
352 SetWindowLong( win, GWL_WNDPROC, (LONG)winproc );
358 return NPERR_NO_ERROR;
361 NPError NPP_SetWindow( NPP instance, NPWindow* window )
365 return NPERR_INVALID_INSTANCE_ERROR;
368 /* NPP_SetWindow may be called before NPP_New (Opera) */
369 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
372 /* we should probably show a splash screen here */
373 return NPERR_NO_ERROR;
376 libvlc_instance_t *p_vlc = p_plugin->getVLC();
380 * Before setting window to point to the
381 * new window, you may wish to compare the new window
382 * info to the previous window (if any) to note window
386 /* retrieve current window */
387 NPWindow& curwin = p_plugin->getWindow();
390 if( window && window->window )
392 /* check if plugin has a new parent window */
393 CGrafPtr drawable = (((NP_Port*) (window->window))->port);
394 if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
396 /* set/change parent window */
397 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
400 /* as MacOS X video output is windowless, set viewport */
401 libvlc_rectangle_t view, clip;
404 ** browser sets port origin to top-left location of plugin relative to GrafPort
405 ** window origin is set relative to document, which of little use for drawing
407 view.top = ((NP_Port*) (window->window))->porty;
408 view.left = ((NP_Port*) (window->window))->portx;
409 view.bottom = window->height+view.top;
410 view.right = window->width+view.left;
411 /* clipRect coordinates are also relative to GrafPort */
412 clip.top = window->clipRect.top;
413 clip.left = window->clipRect.left;
414 clip.bottom = window->clipRect.bottom;
415 clip.right = window->clipRect.right;
417 libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
419 /* remember new window */
420 p_plugin->setWindow(*window);
422 else if( curwin.window ) {
423 /* change/set parent */
424 libvlc_video_set_parent(p_vlc, 0, NULL);
425 curwin.window = NULL;
427 #endif /* XP_MACOSX */
430 if( window && window->window )
432 /* check if plugin has a new parent window */
433 HWND drawable = (HWND) (window->window);
434 if( !curwin.window || drawable != curwin.window )
436 /* reset previous window settings */
437 HWND oldwin = (HWND)p_plugin->getWindow().window;
438 WNDPROC oldproc = p_plugin->getWindowProc();
442 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );
444 /* attach our plugin object */
445 SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,
446 reinterpret_cast<LONG_PTR>(p_plugin));
448 /* install our WNDPROC */
449 p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,
450 GWL_WNDPROC, (LONG)Manage ) );
452 /* change window style to our liking */
453 LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);
454 style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
455 SetWindowLong((HWND)drawable, GWL_STYLE, style);
457 /* change/set parent */
458 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
460 /* remember new window */
461 p_plugin->setWindow(*window);
464 InvalidateRect( (HWND)drawable, NULL, TRUE );
465 UpdateWindow( (HWND)drawable );
468 else if ( curwin.window )
471 HWND oldwin = (HWND)curwin.window;
472 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
473 p_plugin->setWindowProc(NULL);
474 /* change/set parent */
475 libvlc_video_set_parent(p_vlc, 0, NULL);
476 curwin.window = NULL;
481 if( window && window->window )
483 Window parent = (Window) window->window;
484 if( !curwin.window || (parent != (Window)curwin.window) )
486 Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
488 XResizeWindow( p_display, parent, window->width, window->height );
490 int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
492 Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
493 window->width, window->height - p_plugin->i_control_height, 0,
494 i_blackColor, i_blackColor );
495 Window controls = XCreateSimpleWindow( p_display, parent, 0,
496 window->height - p_plugin->i_control_height-1, window->width,
497 p_plugin->i_control_height-1, 0, i_blackColor, i_blackColor );
499 XMapWindow( p_display, parent );
500 XMapWindow( p_display, video );
501 XMapWindow( p_display, controls );
505 Widget w = XtWindowToWidget( p_display, parent );
507 XtAddEventHandler( w, ExposureMask, FALSE,
508 (XtEventHandler)Redraw, p_plugin );
509 XtAddEventHandler( w, StructureNotifyMask, FALSE,
510 (XtEventHandler)Resize, p_plugin );
511 XtAddEventHandler( w, ButtonReleaseMask, FALSE,
512 (XtEventHandler)ControlHandler, p_plugin );
516 libvlc_media_instance_t *p_md;
518 libvlc_exception_t ex;
519 libvlc_exception_init(& ex );
520 p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
521 libvlc_exception_init( &ex );
522 libvlc_event_attach( libvlc_media_instance_event_manager( p_md, &ex ),
523 libvlc_MediaInstancePositionChanged, Redraw, NULL, &ex );
526 /* set/change parent window */
527 libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );
529 /* remember window */
530 p_plugin->setWindow( *window );
531 p_plugin->setVideoWindow( video );
532 p_plugin->setControlWindow( controls );
534 Redraw( w, (XtPointer)p_plugin, NULL );
537 else if ( curwin.window )
539 /* change/set parent */
540 libvlc_video_set_parent(p_vlc, 0, NULL);
541 curwin.window = NULL;
545 if( !p_plugin->b_stream )
547 if( p_plugin->psz_target )
549 if( libvlc_playlist_add( p_vlc, p_plugin->psz_target,
552 if( p_plugin->b_autoplay )
554 libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
557 p_plugin->b_stream = VLC_TRUE;
560 return NPERR_NO_ERROR;
563 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
564 NPBool seekable, uint16 *stype )
566 if( NULL == instance )
568 return NPERR_INVALID_INSTANCE_ERROR;
571 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
572 if( NULL == p_plugin )
574 return NPERR_INVALID_INSTANCE_ERROR;
578 ** Firefox/Mozilla may decide to open a stream from the URL specified
579 ** in the SRC parameter of the EMBED tag and pass it to us
581 ** since VLC will open the SRC URL as well, we're not interested in
582 ** that stream. Otherwise, we'll take it and queue it up in the playlist
584 if( !p_plugin->psz_target || strcmp(stream->url, p_plugin->psz_target) )
586 /* TODO: use pipes !!!! */
587 *stype = NP_ASFILEONLY;
588 return NPERR_NO_ERROR;
590 return NPERR_GENERIC_ERROR;
593 int32 NPP_WriteReady( NPP instance, NPStream *stream )
600 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
601 int32 len, void *buffer )
608 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
610 if( instance == NULL )
612 return NPERR_INVALID_INSTANCE_ERROR;
614 return NPERR_NO_ERROR;
618 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
620 if( instance == NULL )
625 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
626 if( NULL == p_plugin )
631 if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) != -1 )
633 if( p_plugin->b_autoplay )
635 libvlc_playlist_play( p_plugin->getVLC(), 0, 0, NULL, NULL);
641 void NPP_URLNotify( NPP instance, const char* url,
642 NPReason reason, void* notifyData )
644 /***** Insert NPP_URLNotify code here *****\
645 PluginInstance* p_plugin;
646 if (instance != NULL)
647 p_plugin = (PluginInstance*) instance->pdata;
648 \*********************************************/
652 void NPP_Print( NPP instance, NPPrint* printInfo )
654 if( printInfo == NULL )
659 if( instance != NULL )
661 /***** Insert NPP_Print code here *****\
662 PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
663 \**************************************/
665 if( printInfo->mode == NP_FULL )
669 * If your plugin would like to take over
670 * printing completely when it is in full-screen mode,
671 * set printInfo->pluginPrinted to TRUE and print your
672 * plugin as you see fit. If your plugin wants Netscape
673 * to handle printing in this case, set
674 * printInfo->pluginPrinted to FALSE (the default) and
675 * do nothing. If you do want to handle printing
676 * yourself, printOne is true if the print button
677 * (as opposed to the print menu) was clicked.
678 * On the Macintosh, platformPrint is a THPrint; on
679 * Windows, platformPrint is a structure
680 * (defined in npapi.h) containing the printer name, port,
684 /***** Insert NPP_Print code here *****\
685 void* platformPrint =
686 printInfo->print.fullPrint.platformPrint;
688 printInfo->print.fullPrint.printOne;
689 \**************************************/
692 printInfo->print.fullPrint.pluginPrinted = FALSE;
696 /* If not fullscreen, we must be embedded */
699 * If your plugin is embedded, or is full-screen
700 * but you returned false in pluginPrinted above, NPP_Print
701 * will be called with mode == NP_EMBED. The NPWindow
702 * in the printInfo gives the location and dimensions of
703 * the embedded plugin on the printed page. On the
704 * Macintosh, platformPrint is the printer port; on
705 * Windows, platformPrint is the handle to the printing
709 /***** Insert NPP_Print code here *****\
710 NPWindow* printWindow =
711 &(printInfo->print.embedPrint.window);
712 void* platformPrint =
713 printInfo->print.embedPrint.platformPrint;
714 \**************************************/
719 /******************************************************************************
720 * Windows-only methods
721 *****************************************************************************/
723 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
725 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA));
734 PAINTSTRUCT paintstruct;
738 hdc = BeginPaint( p_hwnd, &paintstruct );
740 GetClientRect( p_hwnd, &rect );
742 FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
743 SetTextColor(hdc, RGB(255, 255, 255));
744 SetBkColor(hdc, RGB(0, 0, 0));
745 DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect,
746 DT_CENTER|DT_VCENTER|DT_SINGLELINE);
748 EndPaint( p_hwnd, &paintstruct );
752 /* delegate to default handler */
753 return CallWindowProc(p_plugin->getWindowProc(), p_hwnd, i_msg, wpar, lpar );
758 /******************************************************************************
760 *****************************************************************************/
762 static void Redraw( Widget w, XtPointer closure, XEvent *event )
764 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
765 const NPWindow& window = p_plugin->getWindow();
769 Window video = p_plugin->getVideoWindow();
770 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
772 p_plugin->showToolbar();
774 gcv.foreground = BlackPixel( p_display, 0 );
775 gc = XCreateGC( p_display, video, GCForeground, &gcv );
777 XFillRectangle( p_display, video, gc,
778 0, 0, window.width, window.height - p_plugin->i_control_height );
780 gcv.foreground = WhitePixel( p_display, 0 );
781 XChangeGC( p_display, gc, GCForeground, &gcv );
783 XDrawString( p_display, video, gc,
784 window.width / 2 - 40, (window.height - p_plugin->i_control_height) / 2,
785 WINDOW_TEXT, strlen(WINDOW_TEXT) );
786 XFreeGC( p_display, gc );
788 p_plugin->redrawToolbar();
790 p_plugin->hideToolbar();
793 static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
795 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
796 const NPWindow& window = p_plugin->getWindow();
798 int i_height = window.height;
799 int i_width = window.width;
800 int i_xPos = event->xbutton.x;
801 int i_yPos = event->xbutton.y;
805 libvlc_exception_t ex;
806 libvlc_exception_init( &ex );
807 libvlc_media_instance_t *p_md =
808 libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex);
809 libvlc_exception_clear( &ex );
811 /* jump in the movie */
812 if( i_yPos <= (i_height-30) )
814 /* if a movie is loaded */
817 vlc_int64_t f_length;
818 libvlc_exception_init( &ex );
819 f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100;
820 libvlc_exception_clear( &ex );
822 f_length = (float)f_length *
823 ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );
825 libvlc_exception_init( &ex );
826 libvlc_media_instance_set_time( p_md, f_length, &ex );
827 libvlc_exception_clear( &ex );
831 /* play/pause toggle */
832 if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) )
835 libvlc_exception_init( &ex );
836 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
837 libvlc_exception_clear( &ex );
839 libvlc_exception_init( &ex );
841 libvlc_playlist_pause( p_plugin->getVLC(), &ex );
843 libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
844 libvlc_exception_clear( &ex );
848 if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) )
850 libvlc_exception_init( &ex );
851 libvlc_playlist_stop( p_plugin->getVLC(), &ex );
852 libvlc_exception_clear( &ex );
856 if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) )
859 libvlc_exception_init( &ex );
860 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
861 libvlc_exception_clear( &ex );
863 if( (i_playing == 1) && p_md )
865 libvlc_exception_init( &ex );
866 libvlc_set_fullscreen( p_md, 1, &ex );
867 libvlc_exception_clear( &ex );
872 if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109))
874 libvlc_exception_init( &ex );
875 libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
876 libvlc_exception_clear( &ex );
879 if( p_md ) libvlc_media_instance_release( p_md );
881 Redraw( w, closure, event );
884 static void Resize ( Widget w, XtPointer closure, XEvent *event )
886 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
887 const NPWindow& window = p_plugin->getWindow();
888 Window drawable = p_plugin->getVideoWindow();
889 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
892 Window root_return, parent_return, * children_return;
894 unsigned int i_nchildren;
896 #ifdef X11_RESIZE_DEBUG
897 XWindowAttributes attr;
899 if( event && event->type == ConfigureNotify )
901 fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, "
902 "send_event ? %s\n", event->xconfigure.width,
903 event->xconfigure.height,
904 event->xconfigure.send_event ? "TRUE" : "FALSE" );
906 #endif /* X11_RESIZE_DEBUG */
908 if( ! p_plugin->setSize(window.width, (window.height - p_plugin->i_control_height)) )
910 /* size already set */
914 i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - p_plugin->i_control_height) );
916 #ifdef X11_RESIZE_DEBUG
918 "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret );
920 XGetWindowAttributes ( p_display, drawable, &attr );
922 /* X is asynchronous, so the current size reported here is not
923 necessarily the requested size as the Resize request may not
924 yet have been handled by the plugin host */
925 fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n",
926 attr.width, attr.height );
927 #endif /* X11_RESIZE_DEBUG */
929 XQueryTree( p_display, drawable,
930 &root_return, &parent_return, &children_return,
933 if( i_nchildren > 0 )
935 /* XXX: Make assumptions related to the window parenting structure in
936 vlc/modules/video_output/x11/xcommon.c */
937 base_window = children_return[i_nchildren - 1];
939 #ifdef X11_RESIZE_DEBUG
940 fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren );
941 fprintf( stderr, "vlcshell::Resize() got base_window %p\n",
943 #endif /* X11_RESIZE_DEBUG */
945 i_ret = XResizeWindow( p_display, base_window,
946 window.width, ( window.height - p_plugin->i_control_height ) );
948 #ifdef X11_RESIZE_DEBUG
950 "vlcshell::Resize() XResizeWindow(base) returned %d\n",
953 XGetWindowAttributes( p_display, base_window, &attr );
955 fprintf( stderr, "vlcshell::Resize() new size %d x %d\n",
956 attr.width, attr.height );
957 #endif /* X11_RESIZE_DEBUG */