1 /*
2 * This file is part of MPlayer.
3 *
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 /* video window */
20
21 #include <string.h>
22
23 #include "libvo/x11_common.h"
24 #include "help_mp.h"
25 #include "mp_msg.h"
26 #include "mp_core.h"
27
28 #include "ui.h"
29 #include "gui/app/app.h"
30 #include "gui/app/gui.h"
31 #include "gui/interface.h"
32 #include "gui/dialog/dialog.h"
33 #include "gui/wm/ws.h"
34 #include "gui/wm/wsxdnd.h"
35
36 int videoVisible = 0;
37
uiVideoDraw(void)38 static void uiVideoDraw( void )
39 {
40 if ( guiApp.videoWindow.State == wsWindowClosed ) mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 );
41
42 if ( guiApp.videoWindow.State == wsWindowFocusIn ) videoVisible++;
43 if ( guiApp.videoWindow.State == wsWindowFocusOut && metacity_hack != 3 ) videoVisible--;
44
45 if ( !guiApp.videoWindow.Mapped ||
46 guiApp.videoWindow.Visible == wsWindowNotVisible ||
47 guiInfo.Playing) return;
48
49 if ( guiApp.videoWindow.State == wsWindowExpose )
50 {
51 wsWindowBackground(&guiApp.videoWindow, guiApp.video.R, guiApp.video.G, guiApp.video.B);
52 if ( guiApp.video.Bitmap.Image ) wsImageDraw( &guiApp.videoWindow );
53 }
54 }
55
uiVideoMouse(int Button,int X,int Y,int RX,int RY)56 static void uiVideoMouse( int Button,int X,int Y,int RX,int RY )
57 {
58 static int mplVideoMoved = 0;
59 static int msButton = 0;
60
61 uiPlaybarShow( Y );
62
63 switch( Button )
64 {
65 case wsRRMouseButton:
66 gtkShow( ivShowPopUpMenu, (void *) wVideo );
67 break;
68 case wsPMMouseButton:
69 gtkShow( ivHidePopUpMenu,NULL );
70 uiMenuShow( RX,RY );
71 msButton=wsPMMouseButton;
72 break;
73 case wsRMMouseButton:
74 uiMenuHide( RX,RY,1 );
75 msButton=0;
76 break;
77 /* --- */
78 case wsPLMouseButton:
79 gtkShow( ivHidePopUpMenu,NULL );
80 sx=X; sy=Y;
81 msButton=wsPLMouseButton;
82 mplVideoMoved=0;
83 break;
84 case wsMoveMouse:
85 switch ( msButton )
86 {
87 case wsPLMouseButton:
88 mplVideoMoved=1;
89 if ( !guiApp.videoWindow.isFullScreen )
90 {
91 wsWindowMove( &guiApp.videoWindow,True,RX - sx,RY - sy );
92 }
93 break;
94 case wsPMMouseButton:
95 if (guiApp.menuIsPresent) guiApp.menuWindow.MouseHandler( 0,RX,RY,0,0 );
96 break;
97 default: uiPlaybarShow( Y ); break;
98 }
99 break;
100 case wsRLMouseButton:
101 if ( ( !mplVideoMoved )&&( guiApp.videoWindow.isFullScreen ) )
102 {
103 // NOTE TO MYSELF: this doesn't work, fix later with wsWindowLayer()?
104 if( videoVisible++%2 ) wsWindowRaiseTop( wsDisplay,guiApp.mainWindow.WindowID );
105 else wsWindowRaiseTop( wsDisplay,guiApp.videoWindow.WindowID );
106 }
107 msButton=0;
108 mplVideoMoved=0;
109 break;
110 }
111 }
112
uiVideoInit(void)113 void uiVideoInit (void)
114 {
115 wsWindowCreate(&guiApp.videoWindow, guiApp.video.x, guiApp.video.y, guiApp.video.width, guiApp.video.height, wsShowFrame | wsHideWindow | wsAspect, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, MPlayer" - Video");
116 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[video] videoWindow ID: 0x%x\n", (int) guiApp.videoWindow.WindowID);
117 wsWindowIcon(wsDisplay, guiApp.videoWindow.WindowID, &guiIcon);
118 if (guiApp.video.Bitmap.Image)
119 {
120 wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height);
121 wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image);
122 }
123 wsXDNDMakeAwareness(&guiApp.videoWindow);
124 guiApp.videoWindow.DrawHandler = uiVideoDraw;
125 guiApp.videoWindow.MouseHandler = uiVideoMouse;
126 guiApp.videoWindow.KeyHandler = guiApp.mainWindow.KeyHandler;
127 guiApp.videoWindow.DNDHandler = guiApp.mainWindow.DNDHandler;
128 }
129
uiVideoDone(void)130 void uiVideoDone (void)
131 {
132 wsWindowDestroy(&guiApp.videoWindow);
133 wsEvents();
134 }
135