[MPlayer-dev-eng] [PATCH] libvo: implement fs-borders.

Nicolas George george at nsup.org
Thu Feb 5 16:29:01 CET 2015


Allow to specify extra borders in full screen mode.
This is useful if part of the screen is unusuable,
for example with a video projector overlapping on the
furniture.
---
 DOCS/man/en/mplayer.1 | 12 ++++++++++++
 cfg-mplayer.h         |  4 ++++
 libvo/video_out.c     |  4 ++++
 libvo/video_out.h     |  4 ++++
 libvo/vo_gl.c         |  2 ++
 libvo/x11_common.c    | 21 ++++++++++++++++++++-
 6 files changed, 46 insertions(+), 1 deletion(-)


I have tried to refactor the geometry computation to get this working
with several VOs directly, but it became too many different changes at once.


diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 2da668d..19560c9 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -3511,6 +3511,18 @@ Fixes fullscreen switching on OpenBox 1.x.
 .PD 1
 .
 .TP
+.B \-fs-border-left   <pixels>
+.TP
+.B \-fs-border-right  <pixels>
+.TP
+.B \-fs-border-top    <pixels>
+.TP
+.B \-fs-border-bottom <pixels>
+Specify extra borders in full screen mode.
+The borders apply to all displayed elements: video, OSD and EOSD.
+The number of pixels is specified in terms of screen resolution.
+Currently only supported with by the gl video output driver.
+.TP
 .B \-gamma <\-100\-100>
 Adjust the gamma of the video signal (default: 0).
 Not supported by all video output drivers.
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index b57ac0d..041361a 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -175,6 +175,10 @@ const m_option_t mplayer_opts[]={
     {"panscanrange", &vo_panscanrange, CONF_TYPE_FLOAT, CONF_RANGE, -19.0, 99.0, NULL},
     {"border-pos-x", &vo_border_pos_x, CONF_TYPE_FLOAT, CONF_RANGE, -1, 2, NULL},
     {"border-pos-y", &vo_border_pos_y, CONF_TYPE_FLOAT, CONF_RANGE, -1, 2, NULL},
+    {"fs-border-left",   &vo_fs_border_l, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
+    {"fs-border-right",  &vo_fs_border_r, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
+    {"fs-border-top",    &vo_fs_border_t, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
+    {"fs-border-bottom", &vo_fs_border_b, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
     {"monitor-orientation", &vo_rotate, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 
     {"grabpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 0, 1, NULL},
diff --git a/libvo/video_out.c b/libvo/video_out.c
index fbf9009..bcf5174 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -67,6 +67,10 @@ int vo_fsmode = 0;
 float vo_panscan = 0.0f;
 float vo_border_pos_x = 0.5;
 float vo_border_pos_y = 0.5;
+int vo_fs_border_l = 0;
+int vo_fs_border_r = 0;
+int vo_fs_border_t = 0;
+int vo_fs_border_b = 0;
 int vo_rotate;
 int vo_ontop = 0;
 int vo_adapter_num=0;
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 712703e..3b9555a 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -233,6 +233,10 @@ extern int vo_fsmode;
 extern float vo_panscan;
 extern float vo_border_pos_x;
 extern float vo_border_pos_y;
+extern int vo_fs_border_l;
+extern int vo_fs_border_r;
+extern int vo_fs_border_t;
+extern int vo_fs_border_b;
 extern int vo_rotate;
 extern int vo_adapter_num;
 extern int vo_refresh_rate;
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index ac0cec6..0cef308 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -203,6 +203,8 @@ static void resize(void) {
     geometry(&left, &top, &w, &h, vo_dwidth, vo_dheight);
     top = vo_dheight - h - top;
     mpglViewport(left, top, w, h);
+  } else if (vo_fs) {
+    mpglViewport(vo_fs_border_l, vo_fs_border_b, vo_dwidth, vo_dheight);
   } else
     mpglViewport(0, 0, vo_dwidth, vo_dheight);
 
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 151a082..ab3e412 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -963,6 +963,19 @@ int vo_x11_check_events(Display * mydisplay)
     return ret;
 }
 
+static void vo_x11_update_fs_borders(void)
+{
+    if (!vo_fs)
+        return;
+    if (vo_dwidth  <= vo_fs_border_l + vo_fs_border_r ||
+        vo_dheight <= vo_fs_border_t + vo_fs_border_b) {
+        mp_msg(MSGT_VO, MSGL_ERR, "[x11] borders too wide, ignored.\n");
+        return;
+    }
+    vo_dwidth  -= vo_fs_border_l + vo_fs_border_r;
+    vo_dheight -= vo_fs_border_t + vo_fs_border_b;
+}
+
 /**
  * \brief sets the size and position of the non-fullscreen window.
  */
@@ -1145,6 +1158,7 @@ void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
     vo_fs = 0;
     vo_dwidth = width;
     vo_dheight = height;
+    vo_x11_update_fs_borders();
     vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual,
                       x, y, width, height, vis->depth, col_map);
     window_state = VOFLAG_HIDDEN;
@@ -1189,6 +1203,7 @@ void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
     // set the size values right.
     vo_dwidth  = vo_screenwidth;
     vo_dheight = vo_screenheight;
+    vo_x11_update_fs_borders();
   }
 final:
   if (vo_gc != None)
@@ -1381,7 +1396,11 @@ int vo_x11_update_geometry(void) {
     Window dummy_win;
     XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int,
                  &w, &h, &dummy_int, &depth);
-    if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; }
+    if (w <= INT_MAX && h <= INT_MAX) {
+        vo_dwidth = w;
+        vo_dheight = h;
+        vo_x11_update_fs_borders();
+    }
     XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
                           &dummy_win);
 
-- 
2.1.4



More information about the MPlayer-dev-eng mailing list