[vlc-devel] Dynamic resize of VLC plugin (using Javascript)

y.brehon at qiplay.com y.brehon at qiplay.com
Sat Oct 11 11:06:16 CEST 2008



In the last 0.9.3 stable release of VLC, a bug would occur when trying to
resize the plugin with a javascript call to plugin.width or .height. 

Instead of properly resizing it would simply crop the video to the new
size. 

Here is a patch for this issue, which has been developed at our company.
This is diffed against the 0.93 stable release. I would have liked to
submit it via trac, but apparently this is not possible. 

Cheers, 

Yannick 

--- tmp/vlc-0.9.3/projects/mozilla/vlcshell.cpp 2008-09-18
23:03:36.000000000 +0200
+++ vlcshell.cpp 2008-10-10 17:09:51.000000000 +0200
@@ -7,6 +7,9 @@
 * Authors: Samuel Hocevar 
 * Jean-Paul Saman 
 *
+ *
+ * Patch for dynamic (Javascript) resize of Mozilla VLC plugin: Frederic
Anger  and Yannick Brhon 
+ *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
@@ -948,6 +951,9 @@

unsigned int i_nchildren;
 unsigned int i_control_height, i_control_width;

+ int i_new_height = 0;
+ int i_new_width = 0;
+
 if( p_plugin->b_toolbar )
 {
 p_plugin->getToolbarSize( &i_control_width, 
@@ -969,15 +975,25 @@
 }
 #endif /* X11_RESIZE_DEBUG */

- if( ! p_plugin->setSize(window.width, (window.height -
i_control_height)) )
+ if( event &
+ i_new_height = event->xconfigure.height - i_control_height;
+ i_new_width = event->xconfigure.width - i_control_width;
+ }
+ else
+ {
+ i_new_height = window.height - i_control_height;
+ i_new_width = window.width - i_control_width;
 }

- i_ret = XResizeWindow( p_display, drawable,
- window.width, (window.height - i_control_height) );
+ if( ! p_plugin->setSize(i_new_width, i_new_height) )
+ {
+ /* size already set */
+ return;
+ }

+ i_ret = XResizeWindow( p_display, drawable, i_new_width, i_new_height );
+ 
 #ifdef X11_RESIZE_DEBUG
 fprintf( stderr,
 "vlcshell::Resize() XResizeWindow(owner) returned %dn", i_ret );
@@ -1008,7 +1024,7 @@

#endif /* X11_RESIZE_DEBUG */

 i_ret = XResizeWindow( p_display, base_window,
- window.width, ( window.height - i_control_height ) );
+ i_new_width , i_new_height );

 #ifdef X11_RESIZE_DEBUG
 fprintf( stderr,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20081011/4ea2bb87/attachment.html>


More information about the vlc-devel mailing list