Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
662e9375
Commit
662e9375
authored
Jun 18, 2008
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mozilla toolbar button click logic.
parent
ae00feec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
67 deletions
+83
-67
projects/mozilla/vlcplugin.cpp
projects/mozilla/vlcplugin.cpp
+37
-33
projects/mozilla/vlcplugin.h
projects/mozilla/vlcplugin.h
+3
-2
projects/mozilla/vlcshell.cpp
projects/mozilla/vlcshell.cpp
+43
-32
No files found.
projects/mozilla/vlcplugin.cpp
View file @
662e9375
/*****************************************************************************
* vlcplugin.cpp: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-200
5
the VideoLAN team
* Copyright (C) 2002-200
8
the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Damien Fouilleul <damienf.fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* 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
...
...
@@ -423,13 +424,14 @@ int VlcPlugin::setSize(unsigned width, unsigned height)
return
diff
;
}
#define BTN_SPACE ((unsigned int)4)
void
VlcPlugin
::
showToolbar
()
{
const
NPWindow
&
window
=
getWindow
();
Window
control
=
getControlWindow
();
Window
video
=
getVideoWindow
();
Display
*
p_display
=
((
NPSetWindowCallbackStruct
*
)
window
.
ws_info
)
->
display
;
unsigned
int
i_height
=
0
,
i_width
=
0
;
unsigned
int
i_height
=
0
,
i_width
=
BTN_SPACE
;
/* load icons */
if
(
!
p_btnPlay
)
...
...
@@ -438,7 +440,6 @@ void VlcPlugin::showToolbar()
if
(
p_btnPlay
)
{
i_height
=
__MAX
(
i_height
,
p_btnPlay
->
height
);
i_width
+=
p_btnPlay
->
width
;
}
if
(
!
p_btnPause
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/pause.xpm"
,
...
...
@@ -446,15 +447,16 @@ void VlcPlugin::showToolbar()
if
(
p_btnPause
)
{
i_height
=
__MAX
(
i_height
,
p_btnPause
->
height
);
i_width
+=
p_btnPause
->
width
;
}
i_width
+=
__MAX
(
p_btnPause
->
width
,
p_btnPlay
->
width
);
if
(
!
p_btnStop
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/stop.xpm"
,
&
p_btnStop
,
NULL
,
NULL
);
if
(
p_btnStop
)
{
i_height
=
__MAX
(
i_height
,
p_btnStop
->
height
);
i_width
+=
p_btnStop
->
width
;
i_width
+=
BTN_SPACE
+
p_btnStop
->
width
;
}
if
(
!
p_timeline
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/time_line.xpm"
,
...
...
@@ -462,7 +464,7 @@ void VlcPlugin::showToolbar()
if
(
p_timeline
)
{
i_height
=
__MAX
(
i_height
,
p_timeline
->
height
);
i_width
+=
p_timeline
->
width
;
i_width
+=
BTN_SPACE
+
p_timeline
->
width
;
}
if
(
!
p_btnTime
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/time_icon.xpm"
,
...
...
@@ -470,7 +472,7 @@ void VlcPlugin::showToolbar()
if
(
p_btnTime
)
{
i_height
=
__MAX
(
i_height
,
p_btnTime
->
height
);
i_width
+=
p_btnTime
->
width
;
i_width
+=
BTN_SPACE
+
p_btnTime
->
width
;
}
if
(
!
p_btnFullscreen
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/fullscreen.xpm"
,
...
...
@@ -478,7 +480,7 @@ void VlcPlugin::showToolbar()
if
(
p_btnFullscreen
)
{
i_height
=
__MAX
(
i_height
,
p_btnFullscreen
->
height
);
i_width
+=
p_btnFullscreen
->
width
;
i_width
+=
BTN_SPACE
+
p_btnFullscreen
->
width
;
}
if
(
!
p_btnMute
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/volume_max.xpm"
,
...
...
@@ -486,7 +488,6 @@ void VlcPlugin::showToolbar()
if
(
p_btnMute
)
{
i_height
=
__MAX
(
i_height
,
p_btnMute
->
height
);
i_width
+=
p_btnMute
->
width
;
}
if
(
!
p_btnUnmute
)
XpmReadFileToImage
(
p_display
,
DATA_PATH
"/mozilla/volume_mute.xpm"
,
...
...
@@ -494,8 +495,9 @@ void VlcPlugin::showToolbar()
if
(
p_btnUnmute
)
{
i_height
=
__MAX
(
i_height
,
p_btnUnmute
->
height
);
i_width
+=
p_btnUnmute
->
width
;
}
i_width
+=
BTN_SPACE
+
__MAX
(
p_btnUnmute
->
width
,
p_btnMute
->
width
);
setToolbarSize
(
i_width
,
i_height
);
if
(
!
p_btnPlay
||
!
p_btnPause
||
!
p_btnStop
||
!
p_timeline
||
...
...
@@ -560,7 +562,6 @@ void VlcPlugin::redrawToolbar()
GC
gc
;
XGCValues
gcv
;
unsigned
int
i_tb_width
,
i_tb_height
;
#define BTN_SPACE ((unsigned int)4)
/* This method does nothing if toolbar is hidden. */
if
(
!
b_toolbar
)
...
...
@@ -608,7 +609,6 @@ void VlcPlugin::redrawToolbar()
dst_x
=
BTN_SPACE
;
dst_y
=
i_tb_height
>>
1
;
/* baseline = vertical middle */
fprintf
(
stderr
,
">>>>>> is playing = %d
\n
"
,
i_playing
);
if
(
p_btnPause
&&
(
i_playing
==
1
)
)
{
XPutImage
(
p_display
,
control
,
gc
,
p_btnPause
,
0
,
0
,
dst_x
,
...
...
@@ -675,12 +675,16 @@ void VlcPlugin::redrawToolbar()
vlc_toolbar_clicked_t
VlcPlugin
::
getToolbarButtonClicked
(
int
i_xpos
,
int
i_ypos
)
{
unsigned
int
i_dest
=
0
;
unsigned
int
i_dest
=
BTN_SPACE
;
//(i_tb_height >> 1)
;
int
i_playing
=
0
;
bool
b_mute
=
false
;
libvlc_exception_t
ex
;
if
(
i_xpos
>=
i_tb_height
)
fprintf
(
stderr
,
"ToolbarButtonClicked:: "
"trying to match (%d,%d) (%d,%d)
\n
"
,
i_xpos
,
i_ypos
,
i_tb_height
,
i_tb_width
);
if
(
i_ypos
>=
i_tb_width
)
return
clicked_Unknown
;
/* Note: the order of testing is dependend on the original
...
...
@@ -698,38 +702,38 @@ vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos
b_mute
=
libvlc_audio_get_mute
(
getVLC
(),
&
ex
);
libvlc_exception_clear
(
&
ex
);
/* is Pause of Play button clicked */
if
(
(
i_playing
!=
1
)
&&
(
i_
ypos
>=
BTN_SPACE
>>
1
)
&&
(
i_
ypos
<=
p_btnPlay
->
width
+
(
BTN_SPACE
>>
1
))
)
(
i_
xpos
>=
(
BTN_SPACE
>>
1
)
)
&&
(
i_
xpos
<=
i_dest
+
p_btnPlay
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Play
;
else
if
(
(
i_
ypos
>=
BTN_SPACE
>>
1
)
&&
(
i_
ypos
<=
p_btnPause
->
width
)
)
else
if
(
(
i_
xpos
>=
(
BTN_SPACE
>>
1
)
)
&&
(
i_
xpos
<=
i_dest
+
p_btnPause
->
width
)
)
return
clicked_Pause
;
/* is Stop button clicked */
if
(
i_playing
!=
1
)
i_dest
+=
BTN_SPACE
+
p_btnPause
->
width
+
(
BTN_SPACE
>>
1
);
i_dest
+=
(
p_btnPlay
->
width
+
(
BTN_SPACE
>>
1
)
);
else
i_dest
+=
BTN_SPACE
+
p_btnPlay
->
width
+
(
BTN_SPACE
>>
1
);
if
(
(
i_ypos
>=
i_dest
)
&&
(
i_ypos
<=
p_btnStop
->
width
+
(
BTN_SPACE
>>
1
))
)
i_dest
+=
(
p_btnPause
->
width
+
(
BTN_SPACE
>>
1
));
if
(
(
i_xpos
>=
i_dest
)
&&
(
i_xpos
<=
i_dest
+
p_btnStop
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Stop
;
/* is Fullscreen button clicked */
i_dest
+=
(
p_btnStop
->
width
+
(
BTN_SPACE
>>
1
));
if
(
(
i_
y
pos
>=
i_dest
)
&&
(
i_
ypos
<=
p_btnFullscreen
->
width
+
(
BTN_SPACE
>>
1
))
)
if
(
(
i_
x
pos
>=
i_dest
)
&&
(
i_
xpos
<=
i_dest
+
p_btnFullscreen
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Fullscreen
;
/* is Mute or Unmute button clicked */
i_dest
+=
(
p_btnFullscreen
->
width
+
(
BTN_SPACE
>>
1
));
if
(
!
b_mute
&&
(
i_
y
pos
>=
i_dest
)
&&
(
i_
ypos
<=
p_btnMute
->
width
+
(
BTN_SPACE
>>
1
))
)
if
(
!
b_mute
&&
(
i_
x
pos
>=
i_dest
)
&&
(
i_
xpos
<=
i_dest
+
p_btnMute
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Mute
;
else
if
(
(
i_
y
pos
>=
i_dest
)
&&
(
i_
ypos
<=
p_btnUnmute
->
width
+
(
BTN_SPACE
>>
1
))
)
else
if
(
(
i_
x
pos
>=
i_dest
)
&&
(
i_
xpos
<=
i_dest
+
p_btnUnmute
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Unmute
;
/* is timeline clicked */
...
...
@@ -737,14 +741,14 @@ vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos
i_dest
+=
(
p_btnMute
->
width
+
(
BTN_SPACE
>>
1
));
else
i_dest
+=
(
p_btnUnmute
->
width
+
(
BTN_SPACE
>>
1
));
if
(
(
i_
y
pos
>=
i_dest
)
&&
(
i_
ypos
<=
p_timeline
->
width
+
(
BTN_SPACE
>>
1
))
)
if
(
(
i_
x
pos
>=
i_dest
)
&&
(
i_
xpos
<=
i_dest
+
p_timeline
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_timeline
;
/* is time button clicked */
i_dest
+=
(
p_timeline
->
width
+
(
BTN_SPACE
>>
1
));
if
(
(
i_
y
pos
>=
i_dest
)
&&
(
i_
ypos
<=
p_btnTime
->
width
+
(
BTN_SPACE
>>
1
))
)
if
(
(
i_
x
pos
>=
i_dest
)
&&
(
i_
xpos
<=
i_dest
+
p_btnTime
->
width
+
(
BTN_SPACE
>>
1
))
)
return
clicked_Time
;
return
clicked_Unknown
;
...
...
projects/mozilla/vlcplugin.h
View file @
662e9375
/*****************************************************************************
* vlcplugin.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-200
6
the VideoLAN team
* Copyright (C) 2002-200
8
the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
Damien Fouilleul <damienf@videolan.org>
* Damien Fouilleul <damienf@videolan.org>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* 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
...
...
projects/mozilla/vlcshell.cpp
View file @
662e9375
/*****************************************************************************
* vlcshell.cpp: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-200
5
the VideoLAN team
* Copyright (C) 2002-200
8
the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* 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
...
...
@@ -836,30 +837,37 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
if
(
p_plugin
&&
p_plugin
->
b_toolbar
)
{
int
i_playing
;
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
libvlc_media_player_t
*
p_md
=
libvlc_playlist_get_media_player
(
p_plugin
->
getVLC
(),
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
libvlc_exception_init
(
&
ex
);
i_playing
=
libvlc_playlist_isplaying
(
p_plugin
->
getVLC
(),
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
vlc_toolbar_clicked_t
clicked
;
clicked
=
p_plugin
->
getToolbarButtonClicked
(
i_xPos
,
i_yPos
);
switch
(
clicked
)
{
case
clicked_Play
:
case
clicked_Pause
:
{
int
i_playing
;
libvlc_exception_init
(
&
ex
);
i_playing
=
libvlc_playlist_isplaying
(
p_plugin
->
getVLC
(),
&
ex
);
libvlc_exception_clear
(
&
ex
);
libvlc_exception_init
(
&
ex
);
if
(
i_playing
==
1
)
libvlc_playlist_pause
(
p_plugin
->
getVLC
(),
&
ex
);
else
libvlc_playlist_play
(
p_plugin
->
getVLC
(),
-
1
,
0
,
NULL
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
}
break
;
...
...
@@ -868,6 +876,32 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
{
libvlc_exception_init
(
&
ex
);
libvlc_playlist_stop
(
p_plugin
->
getVLC
(),
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
}
break
;
case
clicked_Fullscreen
:
{
if
(
(
i_playing
==
1
)
&&
p_md
)
{
libvlc_exception_init
(
&
ex
);
libvlc_set_fullscreen
(
p_md
,
1
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
}
}
break
;
case
clicked_Mute
:
case
clicked_Unmute
:
{
libvlc_exception_init
(
&
ex
);
libvlc_audio_toggle_mute
(
p_plugin
->
getVLC
(),
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
}
break
;
...
...
@@ -887,6 +921,8 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
libvlc_exception_init
(
&
ex
);
libvlc_media_player_set_time
(
p_md
,
f_length
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
fprintf
(
stderr
,
"%s
\n
"
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
}
}
...
...
@@ -898,31 +934,6 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
}
break
;
case
clicked_Fullscreen
:
{
int
i_playing
;
libvlc_exception_init
(
&
ex
);
i_playing
=
libvlc_playlist_isplaying
(
p_plugin
->
getVLC
(),
&
ex
);
libvlc_exception_clear
(
&
ex
);
if
(
(
i_playing
==
1
)
&&
p_md
)
{
libvlc_exception_init
(
&
ex
);
libvlc_set_fullscreen
(
p_md
,
1
,
&
ex
);
libvlc_exception_clear
(
&
ex
);
}
}
break
;
case
clicked_Mute
:
case
clicked_Unmute
:
{
libvlc_exception_init
(
&
ex
);
libvlc_audio_toggle_mute
(
p_plugin
->
getVLC
(),
&
ex
);
libvlc_exception_clear
(
&
ex
);
}
break
;
default:
/* button_Unknown */
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment