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,
99 *((char **)value) = psz_desc;
100 return NPERR_NO_ERROR;
103 /* move on to instance variables ... */
107 if( instance == NULL )
109 return NPERR_INVALID_INSTANCE_ERROR;
112 /* plugin instance variables */
114 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
115 if( NULL == p_plugin )
117 // plugin has not been initialized yet !
118 return NPERR_INVALID_INSTANCE_ERROR;
123 case NPPVpluginScriptableNPObject:
125 /* retrieve plugin root class */
126 NPClass *scriptClass = p_plugin->getScriptClass();
129 /* create an instance and return it */
130 *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
131 return NPERR_NO_ERROR;
139 return NPERR_GENERIC_ERROR;
143 * there is some confusion in gecko headers regarding definition of this API
144 * NPPVariable is wrongly defined as NPNVariable, which sounds incorrect.
147 NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value )
149 return NPERR_GENERIC_ERROR;
152 /******************************************************************************
154 *****************************************************************************/
156 int16 NPP_HandleEvent( NPP instance, void * event )
158 static UInt32 lastMouseUp = 0;
160 if( instance == NULL )
165 VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
167 if( p_plugin == NULL )
172 EventRecord *myEvent = (EventRecord*)event;
174 switch( myEvent->what )
180 if( (myEvent->when - lastMouseUp) < GetDblTime() )
183 libvlc_instance_t *p_vlc = p_plugin->getVLC();
187 if( libvlc_playlist_isplaying(p_vlc, NULL) )
189 libvlc_media_instance_t *p_md =
190 libvlc_playlist_get_media_instance(p_vlc, NULL);
193 libvlc_toggle_fullscreen(p_md, NULL);
194 libvlc_media_instance_release(p_md);
202 lastMouseUp = myEvent->when;
210 const NPWindow& npwindow = p_plugin->getWindow();
211 if( npwindow.window )
214 libvlc_instance_t *p_vlc = p_plugin->getVLC();
218 if( libvlc_playlist_isplaying(p_vlc, NULL) )
220 libvlc_media_instance_t *p_md =
221 libvlc_playlist_get_media_instance(p_vlc, NULL);
224 hasVout = libvlc_media_instance_has_vout(p_md,
228 libvlc_rectangle_t area;
231 area.right = npwindow.width;
232 area.bottom = npwindow.height;
233 libvlc_video_redraw_rectangle(p_md, &area,
236 libvlc_media_instance_release(p_md);
243 /* draw the beautiful "No Picture" */
245 ForeColor(blackColor);
248 /* seems that firefox forgets to set the following
249 * on occasion (reload) */
250 SetOrigin(((NP_Port *)npwindow.window)->portx,
251 ((NP_Port *)npwindow.window)->porty);
256 rect.right = npwindow.width;
257 rect.bottom = npwindow.height;
260 ForeColor(whiteColor);
261 MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
262 DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
269 case NPEventType_GetFocusEvent:
270 case NPEventType_LoseFocusEvent:
272 case NPEventType_AdjustCursorEvent:
274 case NPEventType_MenuCommandEvent:
276 case NPEventType_ClippingChangedEvent:
278 case NPEventType_ScrollingBeginsEvent:
280 case NPEventType_ScrollingEndsEvent:
287 #endif /* XP_MACOSX */
289 /******************************************************************************
290 * General Plug-in Calls
291 *****************************************************************************/
292 NPError NPP_Initialize( void )
294 return NPERR_NO_ERROR;
297 jref NPP_GetJavaClass( void )
302 void NPP_Shutdown( void )
307 NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
308 char* argn[], char* argv[], NPSavedData* saved )
312 if( instance == NULL )
314 return NPERR_INVALID_INSTANCE_ERROR;
317 VlcPlugin * p_plugin = new VlcPlugin( instance, mode );
318 if( NULL == p_plugin )
320 return NPERR_OUT_OF_MEMORY_ERROR;
323 status = p_plugin->init(argc, argn, argv);
324 if( NPERR_NO_ERROR == status )
326 instance->pdata = reinterpret_cast<void*>(p_plugin);
328 NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false);
329 NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false);
339 NPError NPP_Destroy( NPP instance, NPSavedData** save )
341 if( NULL == instance )
342 return NPERR_INVALID_INSTANCE_ERROR;
344 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
345 if( NULL == p_plugin )
346 return NPERR_NO_ERROR;
348 instance->pdata = NULL;
351 HWND win = (HWND)p_plugin->getWindow().window;
352 WNDPROC winproc = p_plugin->getWindowProc();
356 SetWindowLong( win, GWL_WNDPROC, (LONG)winproc );
362 return NPERR_NO_ERROR;
365 NPError NPP_SetWindow( NPP instance, NPWindow* window )
368 unsigned int i_control_height = 0, i_control_width = 0;
372 return NPERR_INVALID_INSTANCE_ERROR;
375 /* NPP_SetWindow may be called before NPP_New (Opera) */
376 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
377 if( NULL == p_plugin )
379 /* we should probably show a splash screen here */
380 return NPERR_NO_ERROR;
382 control = p_plugin->getControlWindow();
384 libvlc_instance_t *p_vlc = p_plugin->getVLC();
388 * Before setting window to point to the
389 * new window, you may wish to compare the new window
390 * info to the previous window (if any) to note window
394 /* retrieve current window */
395 NPWindow& curwin = p_plugin->getWindow();
398 if( window && window->window )
400 /* check if plugin has a new parent window */
401 CGrafPtr drawable = (((NP_Port*) (window->window))->port);
402 if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
404 /* set/change parent window */
405 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
408 /* as MacOS X video output is windowless, set viewport */
409 libvlc_rectangle_t view, clip;
412 ** browser sets port origin to top-left location of plugin
413 ** relative to GrafPort window origin is set relative to document,
414 ** which of little use for drawing
416 view.top = ((NP_Port*) (window->window))->porty;
417 view.left = ((NP_Port*) (window->window))->portx;
418 view.bottom = window->height+view.top;
419 view.right = window->width+view.left;
420 /* clipRect coordinates are also relative to GrafPort */
421 clip.top = window->clipRect.top;
422 clip.left = window->clipRect.left;
423 clip.bottom = window->clipRect.bottom;
424 clip.right = window->clipRect.right;
426 libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
428 /* remember new window */
429 p_plugin->setWindow(*window);
431 else if( curwin.window ) {
432 /* change/set parent */
433 libvlc_video_set_parent(p_vlc, 0, NULL);
434 curwin.window = NULL;
436 #endif /* XP_MACOSX */
439 if( window && window->window )
441 /* check if plugin has a new parent window */
442 HWND drawable = (HWND) (window->window);
443 if( !curwin.window || drawable != curwin.window )
445 /* reset previous window settings */
446 HWND oldwin = (HWND)p_plugin->getWindow().window;
447 WNDPROC oldproc = p_plugin->getWindowProc();
451 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );
453 /* attach our plugin object */
454 SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,
455 reinterpret_cast<LONG_PTR>(p_plugin));
457 /* install our WNDPROC */
458 p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,
459 GWL_WNDPROC, (LONG)Manage ) );
461 /* change window style to our liking */
462 LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);
463 style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
464 SetWindowLong((HWND)drawable, GWL_STYLE, style);
466 /* change/set parent */
467 libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
469 /* remember new window */
470 p_plugin->setWindow(*window);
473 InvalidateRect( (HWND)drawable, NULL, TRUE );
474 UpdateWindow( (HWND)drawable );
477 else if ( curwin.window )
480 HWND oldwin = (HWND)curwin.window;
481 SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
482 p_plugin->setWindowProc(NULL);
483 /* change/set parent */
484 libvlc_video_set_parent(p_vlc, 0, NULL);
485 curwin.window = NULL;
490 if( p_plugin->b_toolbar )
492 p_plugin->getToolbarSize( &i_control_width, &i_control_height );
496 i_control_height = i_control_width = 0;
499 if( window && window->window )
501 Window parent = (Window) window->window;
502 if( !curwin.window || (parent != (Window)curwin.window) )
504 Display *p_display = ( (NPSetWindowCallbackStruct *)
505 window->ws_info )->display;
507 XResizeWindow( p_display, parent, window->width, window->height );
509 int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
512 Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
513 window->width, window->height - i_control_height,
514 0, i_blackColor, i_blackColor );
515 Window controls = (Window) NULL;
516 if( p_plugin->b_toolbar )
518 controls = XCreateSimpleWindow( p_display, parent,
519 0, window->height - i_control_height-1,
520 window->width, i_control_height-1,
521 0, i_blackColor, i_blackColor );
524 XMapWindow( p_display, parent );
525 XMapWindow( p_display, video );
526 if( controls ) { XMapWindow( p_display, controls ); }
531 Widget w = XtWindowToWidget( p_display, parent );
533 XtAddEventHandler( w, ExposureMask, FALSE,
534 (XtEventHandler)Redraw, p_plugin );
535 XtAddEventHandler( w, StructureNotifyMask, FALSE,
536 (XtEventHandler)Resize, p_plugin );
537 XtAddEventHandler( w, ButtonReleaseMask, FALSE,
538 (XtEventHandler)ControlHandler, p_plugin );
542 libvlc_media_instance_t *p_md;
544 libvlc_exception_t ex;
545 libvlc_exception_init(& ex );
546 p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
547 libvlc_exception_init( &ex );
548 libvlc_event_attach( libvlc_media_instance_event_manager( p_md, &ex ),
549 libvlc_MediaInstancePositionChanged, Redraw, NULL, &ex );
552 /* set/change parent window */
553 libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );
555 /* remember window */
556 p_plugin->setWindow( *window );
557 p_plugin->setVideoWindow( video );
558 if( controls ) { p_plugin->setControlWindow( controls ); }
560 Redraw( w, (XtPointer)p_plugin, NULL );
563 else if ( curwin.window )
565 /* change/set parent */
566 libvlc_video_set_parent(p_vlc, 0, NULL);
567 curwin.window = NULL;
571 if( !p_plugin->b_stream )
573 if( p_plugin->psz_target )
575 if( libvlc_playlist_add( p_vlc, p_plugin->psz_target,
578 if( p_plugin->b_autoplay )
580 libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
583 p_plugin->b_stream = VLC_TRUE;
586 return NPERR_NO_ERROR;
589 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
590 NPBool seekable, uint16 *stype )
592 if( NULL == instance )
594 return NPERR_INVALID_INSTANCE_ERROR;
597 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
598 if( NULL == p_plugin )
600 return NPERR_INVALID_INSTANCE_ERROR;
604 ** Firefox/Mozilla may decide to open a stream from the URL specified
605 ** in the SRC parameter of the EMBED tag and pass it to us
607 ** since VLC will open the SRC URL as well, we're not interested in
608 ** that stream. Otherwise, we'll take it and queue it up in the playlist
610 if( !p_plugin->psz_target || strcmp(stream->url, p_plugin->psz_target) )
612 /* TODO: use pipes !!!! */
613 *stype = NP_ASFILEONLY;
614 return NPERR_NO_ERROR;
616 return NPERR_GENERIC_ERROR;
619 int32 NPP_WriteReady( NPP instance, NPStream *stream )
626 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
627 int32 len, void *buffer )
634 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
636 if( instance == NULL )
638 return NPERR_INVALID_INSTANCE_ERROR;
640 return NPERR_NO_ERROR;
644 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
646 if( instance == NULL )
651 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
652 if( NULL == p_plugin )
657 if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL )
660 if( p_plugin->b_autoplay )
662 libvlc_playlist_play( p_plugin->getVLC(), 0, 0, NULL, NULL);
668 void NPP_URLNotify( NPP instance, const char* url,
669 NPReason reason, void* notifyData )
671 /***** Insert NPP_URLNotify code here *****\
672 PluginInstance* p_plugin;
673 if (instance != NULL)
674 p_plugin = (PluginInstance*) instance->pdata;
675 \*********************************************/
679 void NPP_Print( NPP instance, NPPrint* printInfo )
681 if( printInfo == NULL )
686 if( instance != NULL )
688 /***** Insert NPP_Print code here *****\
689 PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
690 \**************************************/
692 if( printInfo->mode == NP_FULL )
696 * If your plugin would like to take over
697 * printing completely when it is in full-screen mode,
698 * set printInfo->pluginPrinted to TRUE and print your
699 * plugin as you see fit. If your plugin wants Netscape
700 * to handle printing in this case, set
701 * printInfo->pluginPrinted to FALSE (the default) and
702 * do nothing. If you do want to handle printing
703 * yourself, printOne is true if the print button
704 * (as opposed to the print menu) was clicked.
705 * On the Macintosh, platformPrint is a THPrint; on
706 * Windows, platformPrint is a structure
707 * (defined in npapi.h) containing the printer name, port,
711 /***** Insert NPP_Print code here *****\
712 void* platformPrint =
713 printInfo->print.fullPrint.platformPrint;
715 printInfo->print.fullPrint.printOne;
716 \**************************************/
719 printInfo->print.fullPrint.pluginPrinted = FALSE;
723 /* If not fullscreen, we must be embedded */
726 * If your plugin is embedded, or is full-screen
727 * but you returned false in pluginPrinted above, NPP_Print
728 * will be called with mode == NP_EMBED. The NPWindow
729 * in the printInfo gives the location and dimensions of
730 * the embedded plugin on the printed page. On the
731 * Macintosh, platformPrint is the printer port; on
732 * Windows, platformPrint is the handle to the printing
736 /***** Insert NPP_Print code here *****\
737 NPWindow* printWindow =
738 &(printInfo->print.embedPrint.window);
739 void* platformPrint =
740 printInfo->print.embedPrint.platformPrint;
741 \**************************************/
746 /******************************************************************************
747 * Windows-only methods
748 *****************************************************************************/
750 static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
752 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA));
761 PAINTSTRUCT paintstruct;
765 hdc = BeginPaint( p_hwnd, &paintstruct );
767 GetClientRect( p_hwnd, &rect );
769 FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
770 SetTextColor(hdc, RGB(255, 255, 255));
771 SetBkColor(hdc, RGB(0, 0, 0));
772 DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect,
773 DT_CENTER|DT_VCENTER|DT_SINGLELINE);
775 EndPaint( p_hwnd, &paintstruct );
779 /* delegate to default handler */
780 return CallWindowProc( p_plugin->getWindowProc(), p_hwnd,
786 /******************************************************************************
788 *****************************************************************************/
790 static void Redraw( Widget w, XtPointer closure, XEvent *event )
792 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
793 Window control = p_plugin->getControlWindow();
794 const NPWindow& window = p_plugin->getWindow();
797 unsigned int i_control_height, i_control_width;
799 if( p_plugin->b_toolbar )
801 p_plugin->showToolbar();
802 p_plugin->getToolbarSize( &i_control_width, &i_control_height );
805 i_control_height = i_control_width = 0;
807 Window video = p_plugin->getVideoWindow();
808 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
810 gcv.foreground = BlackPixel( p_display, 0 );
811 gc = XCreateGC( p_display, video, GCForeground, &gcv );
813 XFillRectangle( p_display, video, gc,
814 0, 0, window.width, window.height - i_control_height);
816 gcv.foreground = WhitePixel( p_display, 0 );
817 XChangeGC( p_display, gc, GCForeground, &gcv );
819 XDrawString( p_display, video, gc,
820 window.width / 2 - 40, (window.height - i_control_height) / 2,
821 WINDOW_TEXT, strlen(WINDOW_TEXT) );
822 XFreeGC( p_display, gc );
824 if( p_plugin->b_toolbar )
826 p_plugin->redrawToolbar();
827 p_plugin->hideToolbar();
831 static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
833 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
834 const NPWindow& window = p_plugin->getWindow();
836 int i_height = window.height;
837 int i_width = window.width;
838 int i_xPos = event->xbutton.x;
839 int i_yPos = event->xbutton.y;
841 if( p_plugin && p_plugin->b_toolbar )
843 libvlc_exception_t ex;
844 libvlc_exception_init( &ex );
845 libvlc_media_instance_t *p_md =
846 libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex);
847 libvlc_exception_clear( &ex );
849 /* jump in the movie */
850 if( i_yPos <= (i_height-30) )
852 /* if a movie is loaded */
855 vlc_int64_t f_length;
856 libvlc_exception_init( &ex );
857 f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100;
858 libvlc_exception_clear( &ex );
860 f_length = (float)f_length *
861 ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );
863 libvlc_exception_init( &ex );
864 libvlc_media_instance_set_time( p_md, f_length, &ex );
865 libvlc_exception_clear( &ex );
869 /* play/pause toggle */
870 if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) )
873 libvlc_exception_init( &ex );
874 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
875 libvlc_exception_clear( &ex );
877 libvlc_exception_init( &ex );
879 libvlc_playlist_pause( p_plugin->getVLC(), &ex );
881 libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
882 libvlc_exception_clear( &ex );
886 if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) )
888 libvlc_exception_init( &ex );
889 libvlc_playlist_stop( p_plugin->getVLC(), &ex );
890 libvlc_exception_clear( &ex );
894 if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) )
897 libvlc_exception_init( &ex );
898 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
899 libvlc_exception_clear( &ex );
901 if( (i_playing == 1) && p_md )
903 libvlc_exception_init( &ex );
904 libvlc_set_fullscreen( p_md, 1, &ex );
905 libvlc_exception_clear( &ex );
910 if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109))
912 libvlc_exception_init( &ex );
913 libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
914 libvlc_exception_clear( &ex );
917 if( p_md ) libvlc_media_instance_release( p_md );
919 Redraw( w, closure, event );
922 static void Resize ( Widget w, XtPointer closure, XEvent *event )
924 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
925 Window control = p_plugin->getControlWindow();
926 const NPWindow& window = p_plugin->getWindow();
927 Window drawable = p_plugin->getVideoWindow();
928 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
931 Window root_return, parent_return, * children_return;
933 unsigned int i_nchildren;
934 unsigned int i_control_height, i_control_width;
936 if( p_plugin->b_toolbar )
938 p_plugin->getToolbarSize( &i_control_width, &i_control_height );
942 i_control_height = i_control_width = 0;
945 #ifdef X11_RESIZE_DEBUG
946 XWindowAttributes attr;
948 if( event && event->type == ConfigureNotify )
950 fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, "
951 "send_event ? %s\n", event->xconfigure.width,
952 event->xconfigure.height,
953 event->xconfigure.send_event ? "TRUE" : "FALSE" );
955 #endif /* X11_RESIZE_DEBUG */
957 if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) )
959 /* size already set */
963 i_ret = XResizeWindow( p_display, drawable,
964 window.width, (window.height - i_control_height) );
966 #ifdef X11_RESIZE_DEBUG
968 "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret );
970 XGetWindowAttributes ( p_display, drawable, &attr );
972 /* X is asynchronous, so the current size reported here is not
973 necessarily the requested size as the Resize request may not
974 yet have been handled by the plugin host */
975 fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n",
976 attr.width, attr.height );
977 #endif /* X11_RESIZE_DEBUG */
979 XQueryTree( p_display, drawable,
980 &root_return, &parent_return, &children_return,
983 if( i_nchildren > 0 )
985 /* XXX: Make assumptions related to the window parenting structure in
986 vlc/modules/video_output/x11/xcommon.c */
987 base_window = children_return[i_nchildren - 1];
989 #ifdef X11_RESIZE_DEBUG
990 fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren );
991 fprintf( stderr, "vlcshell::Resize() got base_window %p\n",
993 #endif /* X11_RESIZE_DEBUG */
995 i_ret = XResizeWindow( p_display, base_window,
996 window.width, ( window.height - i_control_height ) );
998 #ifdef X11_RESIZE_DEBUG
1000 "vlcshell::Resize() XResizeWindow(base) returned %d\n",
1003 XGetWindowAttributes( p_display, base_window, &attr );
1005 fprintf( stderr, "vlcshell::Resize() new size %d x %d\n",
1006 attr.width, attr.height );
1007 #endif /* X11_RESIZE_DEBUG */
1011 #endif /* XP_UNIX */