Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 33960:1cd81338af07
Rework fullscreen handling.
This should fix all problems the GUI had with fullscreen handling.
In interface.c:
1. Remove disabled code.
2. Set background of inactive video window to black (which prevents
some flashing when starting the playback in fullscreen mode).
3. Set the state of the fullscreen button according to next playback
mode (normal or fullscreen).
4. Make the video window invisible if there is no video, but don't
make it visible that early if there is video.
5. Set the global fullscreen variable to get aspect scaling. (Hack)
6. In GUI_SETUP_VIDEO_WINDOW:
a. First set the video size,
b. then resize and reposition,
c. then make the window visible,
d. switch to/from fullscreen, if necessary.
(This minimizes disturbances and the display stays in fullscreen
mode and is smoothly black as often as possible.)
7. When playback ends, either act as in 6. or make video window
quickly invisible if requested.
In actions.c:
8. Allow calling uiFullScreen() even if not playing.
9. Remove unnecessary (and misplaced) repositioning (but not properly
resizing) code from uiFullScreen().
10. Don't call wsFullScreen() conditionally.
11. Only set global variable vo_fs, not the global fullscreen
variable.
author | ib |
---|---|
date | Thu, 01 Sep 2011 20:15:40 +0000 |
parents | 349e1fc4b6f2 |
children | 81aaa1420337 |
rev | line source |
---|---|
26458 | 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 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 | |
33556 | 22 #include "actions.h" |
32881 | 23 #include "gmplayer.h" |
24 #include "gui/app.h" | |
25 #include "gui/interface.h" | |
26 #include "gui/skin/font.h" | |
27 #include "gui/skin/skin.h" | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
28 #include "gui/util/list.h" |
33739 | 29 #include "gui/util/mem.h" |
33737 | 30 #include "gui/util/string.h" |
32881 | 31 #include "gui/wm/wsxdnd.h" |
32 #include "widgets.h" | |
23077 | 33 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
34 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "help_mp.h" |
32881 | 36 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
37 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/video_out.h" |
32881 | 39 #include "mp_core.h" |
23077 | 40 #include "stream/stream.h" |
41 | |
33555 | 42 int uiGotoTheNext = 1; |
23077 | 43 |
33555 | 44 void uiFullScreen(void) |
23077 | 45 { |
33960 | 46 if (!guiInfo.VideoWindow) |
32881 | 47 return; |
48 | |
33960 | 49 wsFullScreen(&guiApp.subWindow); |
23077 | 50 |
33960 | 51 vo_fs = guiApp.subWindow.isFullScreen; |
23077 | 52 |
33555 | 53 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
32881 | 54 |
33555 | 55 if (guiApp.menuIsPresent) |
56 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 57 |
33555 | 58 if (guiInfo.Playing) |
59 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
32881 | 60 else |
33555 | 61 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); |
23077 | 62 } |
63 | |
33555 | 64 void uiPlay(void) |
23077 | 65 { |
33555 | 66 if (!guiInfo.Filename || |
67 (guiInfo.Filename[0] == 0) || | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
68 (guiInfo.Playing == GUI_PLAY)) |
32881 | 69 return; |
23077 | 70 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
71 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 72 uiPause(); |
32881 | 73 return; |
74 } | |
75 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
76 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
33555 | 77 uiSubRender = 0; |
78 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
79 wsClearWindow(guiApp.subWindow); | |
23077 | 80 } |
81 | |
33555 | 82 void uiPause(void) |
23077 | 83 { |
33555 | 84 if (!guiInfo.Playing) |
32881 | 85 return; |
86 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
87 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 88 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
89 cmd->id = MP_CMD_PAUSE; | |
90 cmd->name = strdup("pause"); | |
91 mp_input_queue_cmd(cmd); | |
92 } else | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
93 guiInfo.Playing = GUI_PLAY; |
23077 | 94 } |
95 | |
33555 | 96 void uiState(void) |
32881 | 97 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
98 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
32881 | 99 btnModify(evPlaySwitchToPause, btnReleased); |
100 btnModify(evPauseSwitchToPlay, btnDisabled); | |
101 } else { | |
102 btnModify(evPlaySwitchToPause, btnDisabled); | |
103 btnModify(evPauseSwitchToPlay, btnReleased); | |
104 } | |
23077 | 105 } |
106 | |
33555 | 107 void uiRelSeek(float sec) |
32881 | 108 { |
32971 | 109 rel_seek_secs = sec; |
32881 | 110 abs_seek_pos = 0; |
111 } | |
112 | |
33555 | 113 void uiAbsSeek(float percent) |
32881 | 114 { |
33555 | 115 if (guiInfo.StreamType == STREAMTYPE_STREAM) |
32881 | 116 return; |
117 | |
32971 | 118 rel_seek_secs = percent / 100.0; |
32881 | 119 abs_seek_pos = 3; |
23077 | 120 } |
121 | |
33555 | 122 void uiChangeSkin(char *name) |
23077 | 123 { |
32893 | 124 int prev, bprev; |
32881 | 125 |
33555 | 126 prev = guiApp.menuIsPresent; |
127 bprev = guiApp.playbarIsPresent; | |
32881 | 128 |
129 mainVisible = 0; | |
130 | |
32893 | 131 if (skinRead(name) != 0) { |
132 if (skinRead(skinName) != 0) { | |
32894 | 133 mainVisible = 1; |
134 return; | |
32893 | 135 } |
32881 | 136 } |
137 | |
138 // reload menu window | |
23077 | 139 |
33555 | 140 if (prev && guiApp.menuIsPresent) { |
141 free(menuDrawBuffer); | |
142 menuDrawBuffer = calloc(1, guiApp.menu.Bitmap.ImageSize); | |
32881 | 143 |
33555 | 144 if (!menuDrawBuffer) { |
33530 | 145 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 146 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 147 } |
23077 | 148 |
33555 | 149 wsResizeWindow(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); |
150 wsResizeImage(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); | |
151 wsSetShape(&guiApp.menuWindow, guiApp.menu.Mask.Image); | |
152 wsVisibleWindow(&guiApp.menuWindow, wsHideWindow); | |
32881 | 153 } else |
33555 | 154 uiMenuInit(); |
32881 | 155 |
156 // reload sub window | |
23077 | 157 |
33555 | 158 if (guiApp.sub.Bitmap.Image) |
159 wsResizeImage(&guiApp.subWindow, guiApp.sub.Bitmap.Width, guiApp.sub.Bitmap.Height); | |
32881 | 160 |
33555 | 161 if (!guiApp.subWindow.isFullScreen && !guiInfo.Playing) { |
162 wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); | |
163 wsMoveWindow(&guiApp.subWindow, True, guiApp.sub.x, guiApp.sub.y); | |
32881 | 164 } |
165 | |
33555 | 166 if (guiApp.sub.Bitmap.Image) |
167 wsConvert(&guiApp.subWindow, guiApp.sub.Bitmap.Image); | |
23077 | 168 |
33555 | 169 if (!guiInfo.Playing) { |
170 uiSubRender = 1; | |
171 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); | |
172 wsClearWindow(guiApp.subWindow); | |
173 wsPostRedisplay(&guiApp.subWindow); | |
32881 | 174 } |
175 | |
33555 | 176 // reload playbar |
32881 | 177 |
178 if (bprev) | |
33555 | 179 wsDestroyWindow(&guiApp.playbarWindow); |
32881 | 180 |
33555 | 181 uiPlaybarInit(); |
23077 | 182 |
32881 | 183 // reload main window |
184 | |
33555 | 185 free(mainDrawBuffer); |
186 mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize); | |
23077 | 187 |
33555 | 188 if (!mainDrawBuffer) { |
33530 | 189 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 190 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 191 } |
23077 | 192 |
33555 | 193 wsDestroyWindow(&guiApp.mainWindow); |
32881 | 194 |
33555 | 195 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); |
196 wsCreateImage(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height); | |
197 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
198 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); | |
23077 | 199 |
33555 | 200 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
201 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
202 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
203 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
32881 | 204 |
33555 | 205 wsXDNDMakeAwareness(&guiApp.mainWindow); |
23077 | 206 |
33555 | 207 if (!guiApp.mainDecoration) |
208 wsWindowDecoration(&guiApp.mainWindow, 0); | |
32881 | 209 |
33555 | 210 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
32881 | 211 mainVisible = 1; |
212 | |
33555 | 213 btnModify(evSetVolume, guiInfo.Volume); |
214 btnModify(evSetBalance, guiInfo.Balance); | |
215 btnModify(evSetMoviePosition, guiInfo.Position); | |
33957 | 216 btnModify(evFullScreen, guiApp.subWindow.isFullScreen ? btnPressed : btnReleased); |
23077 | 217 |
33555 | 218 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
219 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 220 } |
221 | |
33555 | 222 void uiSetFileName(char *dir, char *name, int type) |
32881 | 223 { |
224 if (!name) | |
225 return; | |
23077 | 226 |
32881 | 227 if (!dir) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
228 setdup(&guiInfo.Filename, name); |
32881 | 229 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
230 setddup(&guiInfo.Filename, dir, name); |
23077 | 231 |
33555 | 232 guiInfo.StreamType = type; |
33897 | 233 nfree(guiInfo.AudioFilename); |
234 nfree(guiInfo.SubtitleFilename); | |
23077 | 235 } |
236 | |
33555 | 237 void uiCurr(void) |
23077 | 238 { |
32881 | 239 plItem *curr; |
240 int stop = 0; | |
23077 | 241 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
242 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 243 return; |
23077 | 244 |
33555 | 245 switch (guiInfo.StreamType) { |
32881 | 246 #ifdef CONFIG_DVDREAD |
247 case STREAMTYPE_DVD: | |
248 break; | |
32953 | 249 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
250 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
251 #ifdef CONFIG_VCD |
32881 | 252 case STREAMTYPE_VCD: |
253 break; | |
32953 | 254 #endif |
32881 | 255 |
256 default: | |
257 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
258 curr = listSet(gtkGetCurrPlItem, NULL); |
32881 | 259 |
260 if (curr) { | |
33555 | 261 uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE); |
262 uiGotoTheNext = 0; | |
32881 | 263 break; |
264 } | |
265 | |
266 return; | |
267 } | |
268 | |
269 if (stop) | |
33555 | 270 uiEventHandling(evStop, 0); |
32881 | 271 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
272 if (guiInfo.Playing == GUI_PLAY) |
33555 | 273 uiEventHandling(evPlay, 0); |
23077 | 274 } |
275 | |
33555 | 276 void uiPrev(void) |
23077 | 277 { |
32881 | 278 plItem *prev; |
279 int stop = 0; | |
280 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
281 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 282 return; |
283 | |
33555 | 284 switch (guiInfo.StreamType) { |
32881 | 285 #ifdef CONFIG_DVDREAD |
286 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
287 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
288 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
289 guiInfo.Chapter = 1; |
32881 | 290 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
291 if (--guiInfo.Track <= 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
292 guiInfo.Track = 1; |
32881 | 293 stop = 1; |
294 } | |
295 } | |
296 | |
297 break; | |
32953 | 298 #endif |
32881 | 299 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
300 #ifdef CONFIG_VCD |
32881 | 301 case STREAMTYPE_VCD: |
33874 | 302 if (--guiInfo.Track == 1) { |
303 guiInfo.Track = 2; | |
32881 | 304 stop = 1; |
305 } | |
306 break; | |
32953 | 307 #endif |
32881 | 308 |
309 default: | |
310 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
311 prev = listSet(gtkGetPrevPlItem, NULL); |
32881 | 312 |
313 if (prev) { | |
33555 | 314 uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE); |
315 uiGotoTheNext = 0; | |
33898 | 316 guiInfo.Track--; |
32881 | 317 break; |
318 } | |
319 | |
320 return; | |
321 } | |
322 | |
323 if (stop) | |
33555 | 324 uiEventHandling(evStop, 0); |
32881 | 325 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
326 if (guiInfo.Playing == GUI_PLAY) |
33555 | 327 uiEventHandling(evPlay, 0); |
23077 | 328 } |
329 | |
33555 | 330 void uiNext(void) |
23077 | 331 { |
32881 | 332 int stop = 0; |
333 plItem *next; | |
23077 | 334 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
335 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 336 return; |
337 | |
33555 | 338 switch (guiInfo.StreamType) { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
339 #ifdef CONFIG_DVDREAD |
32881 | 340 case STREAMTYPE_DVD: |
341 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
342 if (guiInfo.Chapter++ == guiInfo.Chapters) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
343 guiInfo.Chapter = 1; |
32881 | 344 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
345 if (++guiInfo.Track > guiInfo.Tracks) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
346 guiInfo.Track = guiInfo.Tracks; |
32881 | 347 stop = 1; |
348 } | |
349 } | |
350 | |
351 break; | |
32953 | 352 #endif |
32881 | 353 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
354 #ifdef CONFIG_VCD |
32881 | 355 case STREAMTYPE_VCD: |
33003 | 356 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
357 if (++guiInfo.Track >= guiInfo.Tracks) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
358 stop = (guiInfo.Track > guiInfo.Tracks); |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
359 guiInfo.Track = FFMAX(2, guiInfo.Tracks); |
32881 | 360 } |
33003 | 361 |
32881 | 362 break; |
32953 | 363 #endif |
32881 | 364 |
365 default: | |
366 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
367 next = listSet(gtkGetNextPlItem, NULL); |
32881 | 368 |
369 if (next) { | |
33555 | 370 uiSetFileName(next->path, next->name, STREAMTYPE_FILE); |
371 uiGotoTheNext = 0; | |
33898 | 372 guiInfo.Track++; |
32881 | 373 break; |
374 } | |
375 | |
376 return; | |
377 } | |
378 | |
379 if (stop) | |
33555 | 380 uiEventHandling(evStop, 0); |
32881 | 381 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
382 if (guiInfo.Playing == GUI_PLAY) |
33555 | 383 uiEventHandling(evPlay, 0); |
23077 | 384 } |