Commit 3a3937f7 authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

Win32: NPAPI Fullscreen support

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent c9dfaf20
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Building the Mozilla plugin # Building the Mozilla plugin
############################################################################### ###############################################################################
MOSTLYCLEANFILES = MOSTLYCLEANFILES =
CLEANFILES = $(BUILT_SOURCES) CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(DIST_sources) npvlc_rc.rc.in COPYING npvlc.dll.manifest EXTRA_DIST = $(DIST_sources) npvlc_rc.rc.in COPYING npvlc.dll.manifest
...@@ -28,6 +28,10 @@ LIBRARIES_libvlc = $(top_builddir)/src/libvlc.la \ ...@@ -28,6 +28,10 @@ LIBRARIES_libvlc = $(top_builddir)/src/libvlc.la \
if HAVE_WIN32 if HAVE_WIN32
SOURCES_mozilla_common += \
vlc_win32_fullscreen.cpp \
vlc_win32_fullscreen.h
# Under Win32, Mozilla plugins need to be named NP******.DLL, but under Unix # Under Win32, Mozilla plugins need to be named NP******.DLL, but under Unix
# the common naming scheme is lib******plugin.so. Also, we need npwin.cpp # the common naming scheme is lib******plugin.so. Also, we need npwin.cpp
# under Win32 and npunix.cpp under Unix. # under Win32 and npunix.cpp under Unix.
...@@ -67,13 +71,13 @@ CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \ ...@@ -67,13 +71,13 @@ CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
-F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \ -F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
-I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \ -I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \
-Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \ -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \
-DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 -DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0
LDFLAGS_mozilla_EXTRA = -no-undefined -bundle -Wl,-read_only_relocs -Wl,suppress \ LDFLAGS_mozilla_EXTRA = -no-undefined -bundle -Wl,-read_only_relocs -Wl,suppress \
-Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System -Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System
npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support) npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_EXTRA) npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_EXTRA) npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
npvlc_la_DEPENDENCIES = $(LIBRARIES_libvlc) npvlc_la_DEPENDENCIES = $(LIBRARIES_libvlc)
npvlc_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version \ npvlc_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version \
$(LDFLAGS_mozilla_EXTRA) $(LDFLAGS_mozilla_EXTRA)
...@@ -143,7 +147,7 @@ libvlcplugin_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla ...@@ -143,7 +147,7 @@ libvlcplugin_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla
libvlcplugin_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version -shrext $(LIBEXT) libvlcplugin_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version -shrext $(LIBEXT)
libvlcplugin_la_LIBADD = $(LIBRARIES_libvlc) `$(VLC_CONFIG) -libs mozilla` libvlcplugin_la_LIBADD = $(LIBRARIES_libvlc) `$(VLC_CONFIG) -libs mozilla`
# automake gets confused by the ../.. # automake gets confused by the ../..
libvlcplugin_la_DEPENDENCIES = $(AM_LIBADD) libvlcplugin_la_DEPENDENCIES = $(AM_LIBADD)
endif endif
endif endif
endif endif
......
...@@ -41,3 +41,9 @@ BEGIN ...@@ -41,3 +41,9 @@ BEGIN
VALUE "Translation", 0x409, 1252 VALUE "Translation", 0x409, 1252
END END
END END
3 BITMAP DISCARDABLE "pixmaps/defullscreen.bmp"
4 BITMAP DISCARDABLE "pixmaps/play.bmp"
5 BITMAP DISCARDABLE "pixmaps/pause.bmp"
6 BITMAP DISCARDABLE "pixmaps/volume.bmp"
7 BITMAP DISCARDABLE "pixmaps/volume-muted.bmp"
This diff is collapsed.
/*****************************************************************************
* vlc_win32_fullscreen.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2011 the VideoLAN team
* $Id$
*
* Authors: Sergey Radionov <rsatom@gmail.com>
*
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_FULLSCREEN_H
#define VLC_FULLSCREEN_H
#ifdef _WIN32
///////////////////////
//VLCHolderWnd
///////////////////////
class VLCHolderWnd
{
public:
static void RegisterWndClassName(HINSTANCE hInstance);
static void UnRegisterWndClassName();
static VLCHolderWnd* CreateHolderWindow(HWND hParentWnd);
void DestroyWindow()
{::DestroyWindow(_hWnd);};
private:
static LPCTSTR getClassName(void) { return TEXT("VLC ActiveX Window Holder Class"); };
static LRESULT CALLBACK VLCHolderClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
static HINSTANCE _hinstance;
static ATOM _holder_wndclass_atom;
private:
VLCHolderWnd(HWND hWnd)
:_hWnd(hWnd){};
public:
HWND getHWND() const {return _hWnd;}
private:
HWND _hWnd;
};
///////////////////////
//VLCFullScreenWnd
///////////////////////
class VLCWindowsManager;
class VLCFullScreenWnd
{
public:
static void RegisterWndClassName(HINSTANCE hInstance);
static void UnRegisterWndClassName();
static VLCFullScreenWnd* CreateFSWindow(VLCWindowsManager* WM);
void DestroyWindow()
{::DestroyWindow(_hWnd);};
private:
static LPCTSTR getClassName(void) { return TEXT("VLC ActiveX Fullscreen Class"); };
static LRESULT CALLBACK FSWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LPCTSTR getControlsClassName(void) { return TEXT("VLC ActiveX Fullscreen Controls Class"); };
static LRESULT CALLBACK FSControlsWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
static HINSTANCE _hinstance;
static ATOM _fullscreen_wndclass_atom;
static ATOM _fullscreen_controls_wndclass_atom;
private:
VLCFullScreenWnd(HWND hWnd, VLCWindowsManager* WM)
:_hWnd(hWnd), _WindowsManager(WM),
hControlsWnd(0), hToolTipWnd(0), hNewMessageBitmap(0), hFSButtonBitmap(0), hFSButton(0),
hPauseBitmap(0), hPlayBitmap(0), hPlayPauseButton(0), hVideoPosScroll(0),
hMuteButton(0), hVolumeBitmap(0), hVolumeMutedBitmap(0),
hVolumeSlider(0), Last_WM_MOUSEMOVE_lParam(0){};
~VLCFullScreenWnd();
private:
libvlc_media_player_t* getMD();
bool IsPlaying()
{
libvlc_media_player_t* p_md = getMD();
int is_playing = 0;
if( p_md ){
is_playing = libvlc_media_player_is_playing(p_md);
}
return is_playing!=0;
}
private:
void RegisterEvents();
void UnRegisterEvents();
void SetVideoPosScrollRangeByVideoLen();
void SyncVideoPosScrollPosWithVideoPos();
void SetVideoPos(float Pos); //0-start, 1-end
void SyncVolumeSliderWithVLCVolume();
void SetVLCVolumeBySliderPos(int CurScrollPos);
void NeedShowControls();
void NeedHideControls();
private:
void CreateToolTip();
private:
LPARAM Last_WM_MOUSEMOVE_lParam;
private:
VLCWindowsManager* _WindowsManager;
private:
HWND hControlsWnd;
HWND hToolTipWnd;
HICON hNewMessageBitmap;
HANDLE hFSButtonBitmap;
HWND hFSButton;
HANDLE hPauseBitmap;
HANDLE hPlayBitmap;
HWND hPlayPauseButton;
HWND hVideoPosScroll;
HANDLE hVolumeBitmap;
HANDLE hVolumeMutedBitmap;
HWND hMuteButton;
HWND hVolumeSlider;
private:
void SetVideoPosScrollPosByVideoPos(int CurPos);
static bool handle_position_changed_event_enabled;
static void handle_position_changed_event(const libvlc_event_t* event, void *param);
//static void handle_time_changed_event(const libvlc_event_t* event, void *param);
static void handle_input_state_event(const libvlc_event_t* event, void *param);
public:
HWND getHWND() const {return _hWnd;}
private:
HWND _hWnd;
int VideoPosShiftBits;
};
///////////////////////
//VLCWindowsManager
///////////////////////
class VLCWindowsManager
{
public:
VLCWindowsManager(HMODULE hModule);
~VLCWindowsManager();
void CreateWindows(HWND hWindowedParentWnd);
void DestroyWindows();
void LibVlcAttach(libvlc_media_player_t* p_md);
void LibVlcDetach();
void StartFullScreen();
void EndFullScreen();
void ToggleFullScreen();
bool IsFullScreen();
HMODULE getHModule() const {return _hModule;};
VLCHolderWnd* getHolderWnd() const {return _HolderWnd;}
VLCFullScreenWnd* getFullScreenWnd() const {return _FSWnd;}
libvlc_media_player_t* getMD() {return _p_md;}
public:
void setNewMessageFlag(bool Yes)
{_b_new_messages_flag = Yes;};
bool getNewMessageFlag() const
{return _b_new_messages_flag;};
private:
HMODULE _hModule;
HWND _hWindowedParentWnd;
libvlc_media_player_t* _p_md;
VLCHolderWnd* _HolderWnd;
VLCFullScreenWnd* _FSWnd;
bool _b_new_messages_flag;
};
#endif //_WIN32
#endif //VLC_FULLSCREEN_H
...@@ -46,6 +46,34 @@ ...@@ -46,6 +46,34 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef XP_WIN
#include "vlc_win32_fullscreen.h"
static HMODULE hDllModule= 0;
HMODULE DllGetModule()
{
return hDllModule;
};
extern "C"
BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
hDllModule = (HMODULE)hModule;
break;
default:
break;
}
return TRUE;
};
#endif
/***************************************************************************** /*****************************************************************************
* utilitiy functions * utilitiy functions
*****************************************************************************/ *****************************************************************************/
...@@ -124,6 +152,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16_t mode ) : ...@@ -124,6 +152,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16_t mode ) :
psz_baseURL(NULL) psz_baseURL(NULL)
#if defined(XP_WIN) #if defined(XP_WIN)
,pf_wndproc(NULL) ,pf_wndproc(NULL)
,_WindowsManager(DllGetModule())
#endif #endif
#if defined(XP_UNIX) #if defined(XP_UNIX)
,i_width((unsigned)-1) ,i_width((unsigned)-1)
...@@ -510,6 +539,14 @@ VlcPlugin::~VlcPlugin() ...@@ -510,6 +539,14 @@ VlcPlugin::~VlcPlugin()
libvlc_release(libvlc_instance); libvlc_release(libvlc_instance);
} }
void VlcPlugin::setWindow(const NPWindow &window)
{
npwindow = window;
#ifdef XP_WIN
_WindowsManager.CreateWindows((HWND)(getWindow().window));
#endif
};
/***************************************************************************** /*****************************************************************************
* VlcPlugin playlist replacement methods * VlcPlugin playlist replacement methods
*****************************************************************************/ *****************************************************************************/
...@@ -523,8 +560,7 @@ void VlcPlugin::set_player_window() ...@@ -523,8 +560,7 @@ void VlcPlugin::set_player_window()
// XXX FIXME insert appropriate call here // XXX FIXME insert appropriate call here
#endif #endif
#ifdef XP_WIN #ifdef XP_WIN
libvlc_media_player_set_hwnd(libvlc_media_player, _WindowsManager.LibVlcAttach(libvlc_media_player);
getWindow().window);
#endif #endif
} }
...@@ -645,22 +681,47 @@ int VlcPlugin::playlist_count() ...@@ -645,22 +681,47 @@ int VlcPlugin::playlist_count()
void VlcPlugin::toggle_fullscreen() void VlcPlugin::toggle_fullscreen()
{ {
#ifdef XP_WIN
if(!get_fullscreen()){//now in windowed mode
set_fullscreen(true);
}
else if(get_fullscreen()){//now in fullscreen mode
set_fullscreen(false);
}
else {
//and what it meen?
}
#else
if( playlist_isplaying() ) if( playlist_isplaying() )
libvlc_toggle_fullscreen(libvlc_media_player); libvlc_toggle_fullscreen(libvlc_media_player);
#endif
} }
void VlcPlugin::set_fullscreen( int yes ) void VlcPlugin::set_fullscreen( int yes )
{ {
#ifdef XP_WIN
if(yes){
_WindowsManager.StartFullScreen();
}
else{
_WindowsManager.EndFullScreen();
}
#else
if( playlist_isplaying() ) if( playlist_isplaying() )
libvlc_set_fullscreen(libvlc_media_player,yes); libvlc_set_fullscreen(libvlc_media_player,yes);
#endif
} }
int VlcPlugin::get_fullscreen() int VlcPlugin::get_fullscreen()
{ {
#ifdef XP_WIN
return _WindowsManager.IsFullScreen();
#else
int r = 0; int r = 0;
if( playlist_isplaying() ) if( playlist_isplaying() )
r = libvlc_get_fullscreen(libvlc_media_player); r = libvlc_get_fullscreen(libvlc_media_player);
return r; return r;
#endif
} }
bool VlcPlugin::player_has_vout() bool VlcPlugin::player_has_vout()
......
...@@ -182,6 +182,10 @@ private: ...@@ -182,6 +182,10 @@ private:
void unask_for_event(event_t e); void unask_for_event(event_t e);
}; };
#ifdef XP_WIN
HMODULE DllGetModule();
#include "vlc_win32_fullscreen.h"
#endif
class VlcPlugin class VlcPlugin
{ {
...@@ -209,8 +213,7 @@ public: ...@@ -209,8 +213,7 @@ public:
char* getAbsoluteURL(const char *url); char* getAbsoluteURL(const char *url);
NPWindow& getWindow() NPWindow& getWindow()
{ return npwindow; }; { return npwindow; };
void setWindow(const NPWindow &window) void setWindow(const NPWindow &window);
{ npwindow = window; };
NPClass* getScriptClass() NPClass* getScriptClass()
{ return p_scriptClass; }; { return p_scriptClass; };
...@@ -333,6 +336,7 @@ private: ...@@ -333,6 +336,7 @@ private:
NPWindow npwindow; NPWindow npwindow;
#if defined(XP_WIN) #if defined(XP_WIN)
WNDPROC pf_wndproc; WNDPROC pf_wndproc;
VLCWindowsManager _WindowsManager;
#endif #endif
#if defined(XP_UNIX) #if defined(XP_UNIX)
unsigned int i_width, i_height; unsigned int i_width, i_height;
......
...@@ -753,6 +753,20 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa ...@@ -753,6 +753,20 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
EndPaint( p_hwnd, &paintstruct ); EndPaint( p_hwnd, &paintstruct );
return 0L; return 0L;
} }
case WM_SIZE:{
int new_client_width = LOWORD(lpar);
int new_client_height = HIWORD(lpar);
//first child will be resized to client area
HWND hChildWnd = GetWindow(p_hwnd, GW_CHILD);
if(hChildWnd){
MoveWindow(hChildWnd, 0, 0, new_client_width, new_client_height, FALSE);
}
return 0L;
}
case WM_LBUTTONDBLCLK:{
p_plugin->toggle_fullscreen();
return 0L;
}
default: default:
/* delegate to default handler */ /* delegate to default handler */
return CallWindowProc( p_plugin->getWindowProc(), p_hwnd, return CallWindowProc( p_plugin->getWindowProc(), p_hwnd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment