diff mbox

[FFmpeg-devel] ffplay: added option always on top for video window

Message ID 20190513090015.27775-1-daniel.kucera@gmail.com
State Accepted
Headers show

Commit Message

Daniel Kucera May 13, 2019, 9 a.m. UTC
From: Daniel Kucera <github@danman.eu>

Signed-off-by: Daniel Kucera <github@danman.eu>
---
 doc/ffplay.texi  | 2 ++
 fftools/ffplay.c | 8 ++++++++
 2 files changed, 10 insertions(+)

Comments

Carl Eugen Hoyos May 13, 2019, 10:35 a.m. UTC | #1
Am Mo., 13. Mai 2019 um 11:00 Uhr schrieb Daniel Kucera
<daniel.kucera@gmail.com>:

> +#ifdef SDL_WINDOW_ALWAYS_ON_TOP
> +    { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
> +#endif

You could remove the condition here...

>      { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
>      { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
>      { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" },
> @@ -3722,6 +3726,10 @@ int main(int argc, char **argv)
>
>      if (!display_disable) {
>          int flags = SDL_WINDOW_HIDDEN;
> +#ifdef SDL_WINDOW_ALWAYS_ON_TOP
> +        if (alwaysontop)
> +            flags |= SDL_WINDOW_ALWAYS_ON_TOP;

... and add an #else here with a warning message to reduce confusion.
(and switch lines "#ifdef" and "if (alwaysontop)")

> +#endif

Carl Eugen
diff mbox

Patch

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index c305465078..a487c0de8d 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -66,6 +66,8 @@  Set custom interval, in seconds, for seeking using left/right keys. Default is 1
 Disable graphical display.
 @item -noborder
 Borderless window.
+@item -alwaysontop
+Window always on top. Available on: X11 with SDL >= 2.0.5, Windows SDL >= 2.0.6.
 @item -volume
 Set the startup volume. 0 means silence, 100 means no volume reduction or
 amplification. Negative values are treated as 0, values above 100 are treated
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 8f050e16e6..2af5f0386a 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -324,6 +324,7 @@  static int seek_by_bytes = -1;
 static float seek_interval = 10;
 static int display_disable;
 static int borderless;
+static int alwaysontop;
 static int startup_volume = 100;
 static int show_status = 1;
 static int av_sync_type = AV_SYNC_AUDIO_MASTER;
@@ -3581,6 +3582,9 @@  static const OptionDef options[] = {
     { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" },
     { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
     { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
+#ifdef SDL_WINDOW_ALWAYS_ON_TOP
+    { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
+#endif
     { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
     { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
     { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" },
@@ -3722,6 +3726,10 @@  int main(int argc, char **argv)
 
     if (!display_disable) {
         int flags = SDL_WINDOW_HIDDEN;
+#ifdef SDL_WINDOW_ALWAYS_ON_TOP
+        if (alwaysontop)
+            flags |= SDL_WINDOW_ALWAYS_ON_TOP;
+#endif
         if (borderless)
             flags |= SDL_WINDOW_BORDERLESS;
         else