[vlc-devel] Mozilla plugin resize
y.brehon at qiplay.com
y.brehon at qiplay.com
Wed Nov 18 15:57:04 CET 2009
Yes, did I? Man, was I not on top of my game yesterday! Anyways here it
is.
Sorry for this.
Yannick
On Wed, 18 Nov 2009 15:25:19 +0100, Gregor Fuis <gujs.lists at gmail.com>
wrote:
> Did you forget to attach the corrected patch?
>
> Regards,
> Gregor
-------------- next part --------------
From 6b9dcd9b7c406fa4d498e83ea023bde2fb8bc5b5 Mon Sep 17 00:00:00 2001
From: Yannick Brehon <y.brehon at qiplay.com>
Date: Tue, 17 Nov 2009 15:45:41 +0100
Subject: [PATCH] Mozilla plugin video output can be resized by JS.
---
projects/mozilla/vlcplugin.cpp | 10 ++++++++++
projects/mozilla/vlcplugin.h | 1 +
projects/mozilla/vlcshell.cpp | 27 ++++++++++++++++++++++-----
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/projects/mozilla/vlcplugin.cpp b/projects/mozilla/vlcplugin.cpp
index 34526c0..466067a 100644
--- a/projects/mozilla/vlcplugin.cpp
+++ b/projects/mozilla/vlcplugin.cpp
@@ -78,6 +78,10 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
memset(&npvideo, 0, sizeof(Window));
memset(&npcontrol, 0, sizeof(Window));
#endif
+
+ i_width = 0;
+ i_height = 0;
+
}
static bool boolValue(const char *value) {
@@ -598,6 +602,12 @@ int VlcPlugin::setSize(unsigned width, unsigned height)
return diff;
}
+void VlcPlugin::getSize(unsigned &width, unsigned &height)
+{
+ width = i_width;
+ height = i_height;
+}
+
#define BTN_SPACE ((unsigned int)4)
void VlcPlugin::showToolbar()
{
diff --git a/projects/mozilla/vlcplugin.h b/projects/mozilla/vlcplugin.h
index 517530e..478c183 100644
--- a/projects/mozilla/vlcplugin.h
+++ b/projects/mozilla/vlcplugin.h
@@ -117,6 +117,7 @@ public:
#if XP_UNIX
int setSize(unsigned width, unsigned height);
+ void getSize(unsigned &width, unsigned &height);
Window getVideoWindow()
{ return npvideo; };
void setVideoWindow(Window window)
diff --git a/projects/mozilla/vlcshell.cpp b/projects/mozilla/vlcshell.cpp
index e229bb1..105f1ef 100644
--- a/projects/mozilla/vlcshell.cpp
+++ b/projects/mozilla/vlcshell.cpp
@@ -903,6 +903,8 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
Window base_window;
unsigned int i_nchildren;
unsigned int i_control_height, i_control_width;
+ unsigned int i_new_height = 0;
+ unsigned int i_new_width = 0;
if( p_plugin->b_toolbar )
{
@@ -911,6 +913,9 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
else
{
i_control_height = i_control_width = 0;
+ /* Hide the control window */
+ i_ret = XResizeWindow( p_display, control, window.width, 1 );
+ XMoveWindow( p_display, control, 0, 0 );
}
#ifdef X11_RESIZE_DEBUG
@@ -925,14 +930,26 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
}
#endif /* X11_RESIZE_DEBUG */
- if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) )
+ if (event && event->type == ConfigureNotify)
{
- /* size already set */
- return;
+ if (!p_plugin->setSize(event->xconfigure.width - i_control_width,
+ event->xconfigure.height - i_control_height))
+ {
+ /* size already set.*/
+ return;
+ }
+ }
+
+ p_plugin->getSize(i_new_width, i_new_height);
+ if (i_new_width <= 0 || i_new_height <= 0)
+ {
+ /* if the size given by getSize is invalid. */
+ i_new_width = window.width - i_control_width;
+ i_new_height = window.height - i_control_height;
}
i_ret = XResizeWindow( p_display, drawable,
- window.width, (window.height - i_control_height) );
+ i_new_width, i_new_height );
#ifdef X11_RESIZE_DEBUG
fprintf( stderr,
@@ -964,7 +981,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
#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,
--
1.5.6.3
More information about the vlc-devel
mailing list