[MPlayer-dev-eng] [PATCH][RFC] runtime toggle for borderless window

Joey Parrish joey at nicewarrior.org
Thu Sep 1 23:33:37 CEST 2005


Hello,

Attached is a patch to toggle the window decorations on and off.
Comes from another feature request from my users.  Includes
documentation, and the vo_directx implementation of this vo ctrl.

Comments?

Thanks,
--Joey

-- 
All philosophy is naïve.
-------------- next part --------------
toggle borderless window at runtime

diff -Nur main.sofar/DOCS/tech/libvo.txt main.dev/DOCS/tech/libvo.txt
--- main.sofar/DOCS/tech/libvo.txt	2004-07-19 17:44:34.000000000 -0500
+++ main.dev/DOCS/tech/libvo.txt	2005-08-29 11:58:41.741856000 -0500
@@ -63,6 +63,8 @@
 		Makes the player window stay-on-top. Only supported (currently)
 		by drivers which use X11, except SDL, as well as directx and
 		gl2 under Windows.
+	 VOCTRL_BORDER
+		Makes the player window borderless.  Only supported by directx.
 
     config():	
       Set up the video system. You get the dimensions and flags.
diff -Nur main.sofar/DOCS/tech/slave.txt main.dev/DOCS/tech/slave.txt
--- main.sofar/DOCS/tech/slave.txt	2005-08-15 10:30:45.752320000 -0500
+++ main.dev/DOCS/tech/slave.txt	2005-08-29 11:58:41.751870400 -0500
@@ -158,6 +158,9 @@
 vo_rootwin
     Toggle playback on the root window.
 
+vo_border
+    Toggle borderless display.
+
 switch_vsync [<value>]
     Toggle vsync (1 == on, 0 == off). If no value is provided,
     vsync status is inverted.
diff -Nur main.sofar/cfg-mplayer.h main.dev/cfg-mplayer.h
--- main.sofar/cfg-mplayer.h	2005-08-05 20:02:44.149942000 -0500
+++ main.dev/cfg-mplayer.h	2005-08-29 11:58:41.761884800 -0500
@@ -44,6 +44,7 @@
 extern int vo_gamma_hue;
 extern char *vo_geometry;
 extern int vo_ontop;
+extern int vo_border;
 extern int vo_keepaspect;
 extern int vo_rootwin;
 
@@ -143,6 +144,8 @@
 	{"ontop", &vo_ontop, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noontop", &vo_ontop, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 	{"rootwin", &vo_rootwin, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+	{"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+	{"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 
 	{"aop", "-aop is deprecated, use -af instead.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 	{"dsp", "Use -ao oss:dsp_path.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
diff -Nur main.sofar/input/input.c main.dev/input/input.c
--- main.sofar/input/input.c	2005-08-15 10:30:49.507720000 -0500
+++ main.dev/input/input.c	2005-08-29 11:58:41.771899200 -0500
@@ -107,6 +107,7 @@
   { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {-1,{0}} } },
   { MP_CMD_VO_ONTOP, "vo_ontop", 0, { {-1,{0}} } },
   { MP_CMD_VO_ROOTWIN, "vo_rootwin", 0, { {-1,{0}} } },
+  { MP_CMD_VO_BORDER, "vo_border", 0, { {-1,{0}} } },
   { MP_CMD_SCREENSHOT, "screenshot", 0, { {-1,{0}} } },
   { MP_CMD_PANSCAN, "panscan",1,  { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_SWITCH_VSYNC, "switch_vsync", 0, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
diff -Nur main.sofar/input/input.h main.dev/input/input.h
--- main.sofar/input/input.h	2005-08-05 20:02:53.623564000 -0500
+++ main.dev/input/input.h	2005-08-29 11:58:41.781913600 -0500
@@ -67,6 +67,7 @@
 #define MP_CMD_GET_TIME_POS 63
 #define MP_CMD_SUB_LOAD 64
 #define MP_CMD_SUB_REMOVE 65
+#define MP_CMD_VO_BORDER 127
 
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
diff -Nur main.sofar/libvo/video_out.c main.dev/libvo/video_out.c
--- main.sofar/libvo/video_out.c	2005-08-15 10:30:51.360384000 -0500
+++ main.dev/libvo/video_out.c	2005-08-29 11:58:41.791928000 -0500
@@ -45,6 +45,7 @@
 int vo_refresh_rate=0;
 int vo_keepaspect=1;
 int vo_rootwin=0;
+int vo_border=1;
 int WinID = -1;
 
 int vo_pts=0; // for hw decoding
diff -Nur main.sofar/libvo/video_out.h main.dev/libvo/video_out.h
--- main.sofar/libvo/video_out.h	2005-08-05 20:03:00.443371000 -0500
+++ main.dev/libvo/video_out.h	2005-08-29 11:58:41.791928000 -0500
@@ -57,6 +57,7 @@
 
 #define VOCTRL_ONTOP 25
 #define VOCTRL_ROOTWIN 26
+#define VOCTRL_BORDER 27
 
 // Vo can be used by xover
 #define VOCTRL_XOVERLAY_SUPPORT 22
diff -Nur main.sofar/libvo/vo_directx.c main.dev/libvo/vo_directx.c
--- main.sofar/libvo/vo_directx.c	2005-08-05 20:03:00.843947000 -0500
+++ main.dev/libvo/vo_directx.c	2005-08-29 11:58:41.811956800 -0500
@@ -43,6 +43,7 @@
 
 #define WNDCLASSNAME_WINDOWED	"MPlayer - The Movie Player"
 #define WNDCLASSNAME_FULLSCREEN	"MPlayer - Fullscreen"
+#define WINDOW_STYLE (WS_OVERLAPPEDWINDOW|WS_SIZEBOX)
 
 static LPDIRECTDRAWCOLORCONTROL	g_cc = NULL;		//color control interface
 static LPDIRECTDRAW7        g_lpdd = NULL;          //DirectDraw Object
@@ -83,6 +84,7 @@
 extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 extern int vo_doublebuffering;                      //tribblebuffering    
 extern int vo_fs;
+extern int vo_border;
 extern int vo_directrendering;
 extern int vo_ontop;
 extern int vo_rootwin;
@@ -676,7 +678,8 @@
     if(!vidmode && !vo_fs){
       if(WinID == -1) {
           RECT rdw=rd;
-          AdjustWindowRect(&rdw,WS_OVERLAPPEDWINDOW|WS_SIZEBOX,FALSE);
+	  if (vo_border)
+          AdjustWindowRect(&rdw,WINDOW_STYLE,FALSE);
 //          printf("window: %i %i %ix%i\n",rdw.left,rdw.top,rdw.right - rdw.left,rdw.bottom - rdw.top);      
 		  rdw.left += monitor_rect.left; /* move to global coordinate space */
           rdw.top += monitor_rect.top;
@@ -1044,7 +1047,7 @@
     if (WinID != -1) hWnd = WinID;
     else
     hWnd = CreateWindowEx(vidmode?WS_EX_TOPMOST:0,
-        WNDCLASSNAME_WINDOWED,"",(vidmode)?WS_POPUP:WS_OVERLAPPEDWINDOW| WS_SIZEBOX,
+        WNDCLASSNAME_WINDOWED,"",(vidmode || !vo_border)?WS_POPUP:WINDOW_STYLE,
         CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,NULL,NULL,hInstance,NULL);
     wc.hbrBackground = blackbrush;
     wc.lpszClassName = WNDCLASSNAME_FULLSCREEN;
@@ -1300,7 +1303,8 @@
         rd.right = rd.left + d_image_width;
         rd.bottom = rd.top + d_image_height;
         if (WinID == -1) {
-        AdjustWindowRect(&rd,WS_OVERLAPPEDWINDOW|WS_SIZEBOX,FALSE);  
+		if (vo_border)
+        AdjustWindowRect(&rd,WINDOW_STYLE,FALSE);  
         SetWindowPos(hWnd,NULL, vo_dx, vo_dy,rd.right-rd.left,rd.bottom-rd.top,SWP_SHOWWINDOW|SWP_NOOWNERZORDER); 
         }
     }
@@ -1454,6 +1458,28 @@
         return query_format(*((uint32_t*)data));
 	case VOCTRL_DRAW_IMAGE:
         return put_image(data);
+    case VOCTRL_BORDER:
+			if(WinID != -1) return VO_TRUE;
+	        if(vidmode)
+			{
+				mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>border has no meaning in exclusive mode\n");
+			}
+	        else
+			{
+				if(vo_border) {
+					vo_border = 0;
+					SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
+				} else {
+					vo_border = 1;
+					SetWindowLong(hWnd, GWL_STYLE, WINDOW_STYLE);
+				}
+				if (!vo_fs) {
+					ShowWindow(hWnd,SW_HIDE);
+					ShowWindow(hWnd,SW_SHOW);
+				}
+				Directx_ManageDisplay();
+			}
+		return VO_TRUE;
     case VOCTRL_ONTOP:
 			if(WinID != -1) return VO_TRUE;
 	        if(vidmode)
diff -Nur main.sofar/mplayer.c main.dev/mplayer.c
--- main.sofar/mplayer.c	2005-08-29 11:58:41.010804800 -0500
+++ main.dev/mplayer.c	2005-08-29 11:58:41.821971200 -0500
@@ -1043,6 +1043,7 @@
 int osd_show_tv_channel = 25;
 int osd_show_ontop = 0;
 int osd_show_rootwin = 0;
+int osd_show_border = 0;
 int osd_show_framedropping = 0;
 int osd_show_status = 0;
 
@@ -3361,6 +3362,17 @@
      }
 
     } break;
+    case MP_CMD_VO_BORDER:
+    {
+     if(video_out && vo_config_count) {
+       video_out->control(VOCTRL_BORDER, 0);
+#ifdef USE_OSD
+       osd_show_border=10;
+       vo_osd_changed(OSDTYPE_SUBTITLE);
+#endif
+     }
+
+    } break;
     case MP_CMD_PANSCAN : {
       if ( !video_out ) break;
       if ( video_out->control( VOCTRL_GET_PANSCAN,NULL ) == VO_TRUE )
@@ -4123,6 +4135,9 @@
       } else if (osd_show_rootwin) {
 	  snprintf(osd_text_tmp, 63, "Rootwin: %sabled", vo_rootwin?"en":"dis");
 	  osd_show_rootwin--;
+      } else if (osd_show_border) {
+	  snprintf(osd_text_tmp, 63, "Border: %sabled", vo_border?"en":"dis");
+	  osd_show_border--;
       } else if (osd_show_framedropping) {
 	  snprintf(osd_text_tmp, 63, "Framedropping: %s",
 	     (frame_dropping == 1 ? "on" :


More information about the MPlayer-dev-eng mailing list