1 /*****************************************************************************
2 * vlcshell.cpp: a VLC plugin for Mozilla
3 *****************************************************************************
4 * Copyright (C) 2002-2009 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Jean-Paul Saman <jpsaman@videolan.org>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
35 #ifdef HAVE_MOZILLA_CONFIG_H
36 # include <mozilla-config.h>
39 /* This is from mozilla java, do we really need it? */
44 #include "vlcplugin.h"
46 /* Enable/disable debugging printf's for X11 resizing */
47 #undef X11_RESIZE_DEBUG
49 #define WINDOW_TEXT "Waiting for video"
51 /*****************************************************************************
52 * Unix-only declarations
53 ******************************************************************************/
56 static void Redraw( Widget w, XtPointer closure, XEvent *event );
57 static void ControlHandler( Widget w, XtPointer closure, XEvent *event );
58 static void Resize( Widget w, XtPointer closure, XEvent *event );
62 /*****************************************************************************
63 * MacOS-only declarations
64 ******************************************************************************/
68 /*****************************************************************************
69 * Windows-only declarations
70 *****************************************************************************/
73 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar );
77 /******************************************************************************
79 *****************************************************************************/
80 char * NPP_GetMIMEDescription( void )
82 return PLUGIN_MIMETYPES;
85 NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
88 static char psz_desc[1000];
90 /* plugin class variables */
93 case NPPVpluginNameString:
94 *((char **)value) = PLUGIN_NAME;
95 return NPERR_NO_ERROR;
97 case NPPVpluginDescriptionString:
98 snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION,
99 libvlc_get_version() );
100 *((char **)value) = psz_desc;
101 return NPERR_NO_ERROR;
104 /* move on to instance variables ... */
108 if( instance == NULL )
110 return NPERR_INVALID_INSTANCE_ERROR;
113 /* plugin instance variables */
115 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
116 if( NULL == p_plugin )
118 // plugin has not been initialized yet !
119 return NPERR_INVALID_INSTANCE_ERROR;
124 case NPPVpluginScriptableNPObject:
126 /* retrieve plugin root class */
127 NPClass *scriptClass = p_plugin->getScriptClass();
130 /* create an instance and return it */
131 *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
132 return NPERR_NO_ERROR;
140 return NPERR_GENERIC_ERROR;
144 * there is some confusion in gecko headers regarding definition of this API
145 * NPPVariable is wrongly defined as NPNVariable, which sounds incorrect.
148 NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value )
150 return NPERR_GENERIC_ERROR;
153 /******************************************************************************
155 *****************************************************************************/
157 int16 NPP_HandleEvent( NPP instance, void * event )
159 static UInt32 lastMouseUp = 0;
160 libvlc_exception_t ex;
161 libvlc_exception_init(&ex);
163 if( instance == NULL )
168 VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
170 if( p_plugin == NULL )
175 EventRecord *myEvent = (EventRecord*)event;
177 switch( myEvent->what )
183 if( (myEvent->when - lastMouseUp) < GetDblTime() )
186 p_plugin->toggle_fullscreen(&ex);
187 libvlc_exception_clear(&ex);
192 lastMouseUp = myEvent->when;
200 const NPWindow& npwindow = p_plugin->getWindow();
201 if( npwindow.window )
205 if( p_plugin->playlist_isplaying(&ex) )
207 hasVout = p_plugin->player_has_vout(NULL);
210 libvlc_rectangle_t area;
213 area.right = npwindow.width;
214 area.bottom = npwindow.height;
215 libvlc_video_redraw_rectangle(p_plugin->getMD(&ex), &area, NULL);
218 libvlc_exception_clear(&ex);
222 /* draw the beautiful "No Picture" */
224 ForeColor(blackColor);
227 /* seems that firefox forgets to set the following
228 * on occasion (reload) */
229 SetOrigin(((NP_Port *)npwindow.window)->portx,
230 ((NP_Port *)npwindow.window)->porty);
235 rect.right = npwindow.width;
236 rect.bottom = npwindow.height;
239 ForeColor(whiteColor);
240 MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
241 DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
248 case NPEventType_GetFocusEvent:
249 case NPEventType_LoseFocusEvent:
251 case NPEventType_AdjustCursorEvent:
253 case NPEventType_MenuCommandEvent:
255 case NPEventType_ClippingChangedEvent:
257 case NPEventType_ScrollingBeginsEvent:
259 case NPEventType_ScrollingEndsEvent:
266 #endif /* XP_MACOSX */
268 /******************************************************************************
269 * General Plug-in Calls
270 *****************************************************************************/
271 NPError NPP_Initialize( void )
273 return NPERR_NO_ERROR;
276 jref NPP_GetJavaClass( void )
281 void NPP_Shutdown( void )
286 NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
287 char* argn[], char* argv[], NPSavedData* saved )
291 if( instance == NULL )
293 return NPERR_INVALID_INSTANCE_ERROR;
296 VlcPlugin * p_plugin = new VlcPlugin( instance, mode );
297 if( NULL == p_plugin )
299 return NPERR_OUT_OF_MEMORY_ERROR;
302 status = p_plugin->init(argc, argn, argv);
303 if( NPERR_NO_ERROR == status )
305 instance->pdata = reinterpret_cast<void*>(p_plugin);
307 NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false);
308 NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false);
318 NPError NPP_Destroy( NPP instance, NPSavedData** save )
320 if( NULL == instance )
321 return NPERR_INVALID_INSTANCE_ERROR;
323 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
324 if( NULL == p_plugin )
325 return NPERR_NO_ERROR;
327 instance->pdata = NULL;
330 HWND win = (HWND)p_plugin->getWindow().window;
331 WNDPROC winproc = p_plugin->getWindowProc();
335 SetWindowLong( win, GWL_WNDPROC, (LONG)winproc );
341 return NPERR_NO_ERROR;
344 NPError NPP_SetWindow( NPP instance, NPWindow* window )
346 #if defined(XP_UNIX) && !defined(__APPLE__)
348 unsigned int i_control_height = 0, i_control_width = 0;
353 return NPERR_INVALID_INSTANCE_ERROR;
356 /* NPP_SetWindow may be called before NPP_New (Opera) */
357 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
358 if( NULL == p_plugin )
360 /* we should probably show a splash screen here */
361 return NPERR_NO_ERROR;
363 #if defined(XP_UNIX) && !defined(__APPLE__)
364 control = p_plugin->getControlWindow();
366 libvlc_instance_t *p_vlc = p_plugin->getVLC();
370 * Before setting window to point to the
371 * new window, you may wish to compare the new window
372 * info to the previous window (if any) to note window
376 /* retrieve current window */
377 NPWindow& curwin = p_plugin->getWindow();
380 if( window && window->window )
382 /* check if plugin has a new parent window */
383 CGrafPtr drawable = (((NP_Port*) (window->window))->port);
384 if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
386 /* set/change parent window */
387 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
390 /* as MacOS X video output is windowless, set viewport */
391 libvlc_rectangle_t view, clip;
394 ** browser sets port origin to top-left location of plugin
395 ** relative to GrafPort window origin is set relative to document,
396 ** which of little use for drawing
398 view.top = ((NP_Port*) (window->window))->porty;
399 view.left = ((NP_Port*) (window->window))->portx;
400 view.bottom = window->height+view.top;
401 view.right = window->width+view.left;
402 /* clipRect coordinates are also relative to GrafPort */
403 clip.top = window->clipRect.top;
404 clip.left = window->clipRect.left;
405 clip.bottom = window->clipRect.bottom;
406 clip.right = window->clipRect.right;
408 libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
410 /* remember new window */
411 p_plugin->setWindow(*window);
413 else if( curwin.window )
415 /* change/set parent */
416 libvlc_video_set_parent(p_vlc, 0, NULL);
417 curwin.window = NULL;
419 #endif /* XP_MACOSX */
422 if( window && window->window )
424 /* check if plugin has a new parent window */
425 HWND drawable = (HWND) (window->window);
426 if( !curwin.window || drawable != curwin.window )
428 /* reset previous window settings */
429 HWND oldwin = (HWND)p_plugin->getWindow().window;
430 WNDPROC oldproc = p_plugin->getWindowProc();
434 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );
436 /* attach our plugin object */
437 SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,
438 reinterpret_cast<LONG_PTR>(p_plugin));
440 /* install our WNDPROC */
441 p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,
442 GWL_WNDPROC, (LONG)Manage ) );
444 /* change window style to our liking */
445 LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);
446 style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
447 SetWindowLong((HWND)drawable, GWL_STYLE, style);
449 /* change/set parent */
450 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
452 /* remember new window */
453 p_plugin->setWindow(*window);
456 InvalidateRect( (HWND)drawable, NULL, TRUE );
457 UpdateWindow( (HWND)drawable );
460 else if ( curwin.window )
463 HWND oldwin = (HWND)curwin.window;
464 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
465 p_plugin->setWindowProc(NULL);
466 /* change/set parent */
467 libvlc_video_set_parent(p_vlc, 0, NULL);
468 curwin.window = NULL;
473 /* default to hidden toolbar, shown at the end of this method if asked *
474 * developers note : getToolbarSize need to wait the end of this method
476 i_control_height = 0;
477 i_control_width = window->width;
479 if( window && window->window )
481 Window parent = (Window) window->window;
482 if( !curwin.window || (parent != (Window)curwin.window) )
484 Display *p_display = ( (NPSetWindowCallbackStruct *)
485 window->ws_info )->display;
487 XResizeWindow( p_display, parent, window->width, window->height );
489 int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
492 Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
493 window->width, window->height - i_control_height,
494 0, i_blackColor, i_blackColor );
495 Window controls = (Window) NULL;
496 controls = XCreateSimpleWindow( p_display, parent,
497 0, window->height - i_control_height-1,
498 window->width, i_control_height-1,
499 0, i_blackColor, i_blackColor );
501 XMapWindow( p_display, parent );
502 XMapWindow( p_display, video );
503 if( controls ) { XMapWindow( p_display, controls ); }
508 Widget w = XtWindowToWidget( p_display, parent );
510 XtAddEventHandler( w, ExposureMask, FALSE,
511 (XtEventHandler)Redraw, p_plugin );
512 XtAddEventHandler( w, StructureNotifyMask, FALSE,
513 (XtEventHandler)Resize, p_plugin );
514 XtAddEventHandler( w, ButtonReleaseMask, FALSE,
515 (XtEventHandler)ControlHandler, p_plugin );
519 libvlc_media_player_t *p_md;
521 libvlc_exception_t ex;
522 libvlc_exception_init(& ex );
523 p_md = p_plugin->getMD( &ex );
524 libvlc_exception_clear( &ex );
525 libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),
526 libvlc_MediaPlayerPositionChanged, Redraw, NULL, &ex );
529 /* set/change parent window */
530 libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );
532 /* remember window */
533 p_plugin->setWindow( *window );
534 p_plugin->setVideoWindow( video );
535 if( controls ) { p_plugin->setControlWindow( controls ); }
537 Redraw( w, (XtPointer)p_plugin, NULL );
539 /* now display toolbar if asked through parameters */
540 if( p_plugin->b_toolbar )
542 p_plugin->showToolbar();
546 else if ( curwin.window )
548 /* change/set parent */
549 libvlc_video_set_parent(p_vlc, 0, NULL);
550 curwin.window = NULL;
554 if( !p_plugin->b_stream )
556 if( p_plugin->psz_target )
558 if( p_plugin->playlist_add( p_plugin->psz_target, NULL ) != -1 )
560 if( p_plugin->b_autoplay )
562 p_plugin->playlist_play(NULL);
565 p_plugin->b_stream = true;
568 return NPERR_NO_ERROR;
571 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
572 NPBool seekable, uint16 *stype )
574 if( NULL == instance )
576 return NPERR_INVALID_INSTANCE_ERROR;
579 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
580 if( NULL == p_plugin )
582 return NPERR_INVALID_INSTANCE_ERROR;
586 ** Firefox/Mozilla may decide to open a stream from the URL specified
587 ** in the SRC parameter of the EMBED tag and pass it to us
589 ** since VLC will open the SRC URL as well, we're not interested in
590 ** that stream. Otherwise, we'll take it and queue it up in the playlist
592 if( !p_plugin->psz_target || strcmp(stream->url, p_plugin->psz_target) )
594 /* TODO: use pipes !!!! */
595 *stype = NP_ASFILEONLY;
596 return NPERR_NO_ERROR;
598 return NPERR_GENERIC_ERROR;
601 int32 NPP_WriteReady( NPP instance, NPStream *stream )
608 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
609 int32 len, void *buffer )
616 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
618 if( instance == NULL )
620 return NPERR_INVALID_INSTANCE_ERROR;
622 return NPERR_NO_ERROR;
626 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
628 if( instance == NULL )
633 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
634 if( NULL == p_plugin )
639 if( p_plugin->playlist_add( stream->url, NULL ) != -1 )
641 if( p_plugin->b_autoplay )
643 p_plugin->playlist_play(NULL);
649 void NPP_URLNotify( NPP instance, const char* url,
650 NPReason reason, void* notifyData )
652 /***** Insert NPP_URLNotify code here *****\
653 PluginInstance* p_plugin;
654 if (instance != NULL)
655 p_plugin = (PluginInstance*) instance->pdata;
656 \*********************************************/
659 void NPP_Print( NPP instance, NPPrint* printInfo )
661 if( printInfo == NULL )
666 if( instance != NULL )
668 /***** Insert NPP_Print code here *****\
669 PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
670 \**************************************/
672 if( printInfo->mode == NP_FULL )
676 * If your plugin would like to take over
677 * printing completely when it is in full-screen mode,
678 * set printInfo->pluginPrinted to TRUE and print your
679 * plugin as you see fit. If your plugin wants Netscape
680 * to handle printing in this case, set
681 * printInfo->pluginPrinted to FALSE (the default) and
682 * do nothing. If you do want to handle printing
683 * yourself, printOne is true if the print button
684 * (as opposed to the print menu) was clicked.
685 * On the Macintosh, platformPrint is a THPrint; on
686 * Windows, platformPrint is a structure
687 * (defined in npapi.h) containing the printer name, port,
691 /***** Insert NPP_Print code here *****\
692 void* platformPrint =
693 printInfo->print.fullPrint.platformPrint;
695 printInfo->print.fullPrint.printOne;
696 \**************************************/
699 printInfo->print.fullPrint.pluginPrinted = FALSE;
703 /* If not fullscreen, we must be embedded */
706 * If your plugin is embedded, or is full-screen
707 * but you returned false in pluginPrinted above, NPP_Print
708 * will be called with mode == NP_EMBED. The NPWindow
709 * in the printInfo gives the location and dimensions of
710 * the embedded plugin on the printed page. On the
711 * Macintosh, platformPrint is the printer port; on
712 * Windows, platformPrint is the handle to the printing
716 /***** Insert NPP_Print code here *****\
717 NPWindow* printWindow =
718 &(printInfo->print.embedPrint.window);
719 void* platformPrint =
720 printInfo->print.embedPrint.platformPrint;
721 \**************************************/
726 /******************************************************************************
727 * Windows-only methods
728 *****************************************************************************/
730 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
732 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA));
741 PAINTSTRUCT paintstruct;
745 hdc = BeginPaint( p_hwnd, &paintstruct );
747 GetClientRect( p_hwnd, &rect );
749 FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
750 SetTextColor(hdc, RGB(255, 255, 255));
751 SetBkColor(hdc, RGB(0, 0, 0));
752 DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect,
753 DT_CENTER|DT_VCENTER|DT_SINGLELINE);
755 EndPaint( p_hwnd, &paintstruct );
759 /* delegate to default handler */
760 return CallWindowProc( p_plugin->getWindowProc(), p_hwnd,
766 /******************************************************************************
768 *****************************************************************************/
770 static void Redraw( Widget w, XtPointer closure, XEvent *event )
772 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
773 Window control = p_plugin->getControlWindow();
774 const NPWindow& window = p_plugin->getWindow();
777 unsigned int i_control_height, i_control_width;
779 if( p_plugin->b_toolbar )
780 p_plugin->getToolbarSize( &i_control_width, &i_control_height );
782 i_control_height = i_control_width = 0;
784 Window video = p_plugin->getVideoWindow();
785 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
787 gcv.foreground = BlackPixel( p_display, 0 );
788 gc = XCreateGC( p_display, video, GCForeground, &gcv );
790 XFillRectangle( p_display, video, gc,
791 0, 0, window.width, window.height - i_control_height);
793 gcv.foreground = WhitePixel( p_display, 0 );
794 XChangeGC( p_display, gc, GCForeground, &gcv );
796 XDrawString( p_display, video, gc,
797 window.width / 2 - 40, (window.height - i_control_height) / 2,
798 WINDOW_TEXT, strlen(WINDOW_TEXT) );
799 XFreeGC( p_display, gc );
801 p_plugin->redrawToolbar();
804 static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
806 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
807 const NPWindow& window = p_plugin->getWindow();
809 int i_height = window.height;
810 int i_width = window.width;
811 int i_xPos = event->xbutton.x;
812 int i_yPos = event->xbutton.y;
814 if( p_plugin && p_plugin->b_toolbar )
817 libvlc_exception_t ex;
819 libvlc_exception_init( &ex );
820 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
821 if( libvlc_exception_raised(&ex) )
822 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
823 libvlc_exception_clear( &ex );
825 i_playing = p_plugin->playlist_isplaying( &ex );
826 if( libvlc_exception_raised(&ex) )
827 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
828 libvlc_exception_clear( &ex );
830 vlc_toolbar_clicked_t clicked;
831 clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos );
838 p_plugin->playlist_pause( &ex );
840 p_plugin->playlist_play( &ex );
842 if( libvlc_exception_raised(&ex) )
843 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
844 libvlc_exception_clear( &ex );
850 p_plugin->playlist_stop(&ex);
851 if( libvlc_exception_raised(&ex) )
852 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
853 libvlc_exception_clear( &ex );
857 case clicked_Fullscreen:
859 p_plugin->set_fullscreen( 1, &ex );
860 if( libvlc_exception_raised(&ex) )
861 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
862 libvlc_exception_clear( &ex );
869 libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
870 if( libvlc_exception_raised(&ex) )
871 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
872 libvlc_exception_clear( &ex );
876 case clicked_timeline:
878 /* if a movie is loaded */
882 f_length = libvlc_media_player_get_length( p_md, &ex ) / 100;
883 libvlc_exception_clear( &ex );
885 f_length = (float)f_length *
886 ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) );
888 libvlc_media_player_set_time( p_md, f_length, &ex );
889 if( libvlc_exception_raised(&ex) )
890 fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
891 libvlc_exception_clear( &ex );
898 /* Not implemented yet*/
902 default: /* button_Unknown */
906 Redraw( w, closure, event );
909 static void Resize ( Widget w, XtPointer closure, XEvent *event )
911 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
912 Window control = p_plugin->getControlWindow();
913 const NPWindow& window = p_plugin->getWindow();
914 Window drawable = p_plugin->getVideoWindow();
915 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
918 Window root_return, parent_return, * children_return;
920 unsigned int i_nchildren;
921 unsigned int i_control_height, i_control_width;
923 if( p_plugin->b_toolbar )
925 p_plugin->getToolbarSize( &i_control_width, &i_control_height );
929 i_control_height = i_control_width = 0;
932 #ifdef X11_RESIZE_DEBUG
933 XWindowAttributes attr;
935 if( event && event->type == ConfigureNotify )
937 fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, "
938 "send_event ? %s\n", event->xconfigure.width,
939 event->xconfigure.height,
940 event->xconfigure.send_event ? "TRUE" : "FALSE" );
942 #endif /* X11_RESIZE_DEBUG */
944 if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) )
946 /* size already set */
950 i_ret = XResizeWindow( p_display, drawable,
951 window.width, (window.height - i_control_height) );
953 #ifdef X11_RESIZE_DEBUG
955 "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret );
957 XGetWindowAttributes ( p_display, drawable, &attr );
959 /* X is asynchronous, so the current size reported here is not
960 necessarily the requested size as the Resize request may not
961 yet have been handled by the plugin host */
962 fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n",
963 attr.width, attr.height );
964 #endif /* X11_RESIZE_DEBUG */
966 XQueryTree( p_display, drawable,
967 &root_return, &parent_return, &children_return,
970 if( i_nchildren > 0 )
972 /* XXX: Make assumptions related to the window parenting structure in
973 vlc/modules/video_output/x11/xcommon.c */
974 base_window = children_return[i_nchildren - 1];
976 #ifdef X11_RESIZE_DEBUG
977 fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren );
978 fprintf( stderr, "vlcshell::Resize() got base_window %p\n",
980 #endif /* X11_RESIZE_DEBUG */
982 i_ret = XResizeWindow( p_display, base_window,
983 window.width, ( window.height - i_control_height ) );
985 #ifdef X11_RESIZE_DEBUG
987 "vlcshell::Resize() XResizeWindow(base) returned %d\n",
990 XGetWindowAttributes( p_display, base_window, &attr );
992 fprintf( stderr, "vlcshell::Resize() new size %d x %d\n",
993 attr.width, attr.height );
994 #endif /* X11_RESIZE_DEBUG */