[MPlayer-cvslog] CVS: main/libvo w32_common.h,1.4,1.5
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Apr 12 16:35:42 CEST 2006
Hi,
On Wed, Apr 12, 2006 at 04:20:53PM +0200, Reimar DXffinger CVS wrote:
> Modified Files:
> w32_common.h
> Log Message:
> fixes and cleanup for windows fullscreen switching (restore old position,
> fullscreen on current monitor).
Due to a connection timeout, there were no commit messages created for
most of this patch. No idea what would be the best way to "fix" this, so
here is the full patch for this commit...
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- libvo/vo_gl.c 26 Mar 2006 10:43:56 -0000 1.117
+++ libvo/vo_gl.c 12 Apr 2006 14:11:26 -0000 1.118
@@ -327,13 +327,7 @@
}
#endif
#ifdef GL_WIN32
- o_dwidth = d_width;
- o_dheight = d_height;
- vo_fs = flags & VOFLAG_FULLSCREEN;
- vo_vm = flags & VOFLAG_MODESWITCHING;
- vo_dwidth = d_width;
- vo_dheight = d_height;
- if (!createRenderingContext())
+ if (!vo_w32_config(d_width, d_height, flags))
return -1;
#else
if (WinID >= 0) {
Index: libvo/vo_gl2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl2.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- libvo/vo_gl2.c 9 Feb 2006 14:07:59 -0000 1.87
+++ libvo/vo_gl2.c 12 Apr 2006 14:11:26 -0000 1.88
@@ -595,15 +595,7 @@
#ifdef GL_WIN32
static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) {
- o_dwidth = d_width;
- o_dheight = d_height;
- vo_fs = flags & VOFLAG_FULLSCREEN;
- vo_vm = flags & VOFLAG_MODESWITCHING;
-
- vo_dwidth = d_width;
- vo_dheight = d_height;
-
- if (!createRenderingContext())
+ if (!vo_w32_config(d_width, d_height, flags))
return -1;
if (vo_fs)
Index: libvo/w32_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/w32_common.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- libvo/w32_common.c 7 Dec 2005 15:53:02 -0000 1.19
+++ libvo/w32_common.c 12 Apr 2006 14:11:26 -0000 1.20
@@ -15,6 +15,16 @@
int vo_vm = 0;
HDC vo_hdc = 0;
+// last non-fullscreen extends
+int prev_width;
+int prev_height;
+int prev_x;
+int prev_y;
+
+// top left coordinates of current monitor
+int vo_screenx;
+int vo_screeny;
+
uint32_t o_dwidth;
uint32_t o_dheight;
@@ -23,15 +33,28 @@
static int cursor = 1;
static int event_flags;
+static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD);
+static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO);
+
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ RECT r;
+ POINT p;
switch (message) {
case WM_PAINT:
event_flags |= VO_EVENT_EXPOSE;
break;
+ case WM_MOVE:
+ p.x = 0;
+ p.y = 0;
+ ClientToScreen(vo_window, &p);
+ vo_dx = p.x;
+ vo_dy = p.y;
+ break;
case WM_SIZE:
event_flags |= VO_EVENT_RESIZE;
- vo_dwidth = lParam & 0xffff;
- vo_dheight = lParam >> 16;
+ GetClientRect(vo_window, &r);
+ vo_dwidth = r.right;
+ vo_dheight = r.bottom;
break;
case WM_CLOSE:
mplayer_put_key(KEY_CLOSE_WIN);
@@ -122,6 +145,15 @@
vo_screenheight = dm.dmPelsHeight;
vo_depthonscreen = dm.dmBitsPerPel;
aspect_save_screenres(vo_screenwidth, vo_screenheight);
+ vo_screenx = vo_screeny = 0;
+ if (myMonitorFromWindow && myGetMonitorInfo) {
+ MONITORINFO mi;
+ HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
+ mi.cbSize = sizeof(mi);
+ myGetMonitorInfo(m, &mi);
+ vo_screenx = mi.rcMonitor.left;
+ vo_screeny = mi.rcMonitor.top;
+ }
}
static void changeMode(void) {
@@ -162,7 +194,7 @@
ChangeDisplaySettings(0, 0);
}
-int createRenderingContext(void) {
+static int createRenderingContext(void) {
HWND layer = HWND_NOTOPMOST;
PIXELFORMATDESCRIPTOR pfd;
RECT r;
@@ -187,11 +219,24 @@
updateScreenProperties();
ShowWindow(vo_window, SW_HIDE);
SetWindowLong(vo_window, GWL_STYLE, style);
- vo_dwidth = vo_fs ? vo_screenwidth : o_dwidth;
- vo_dheight = vo_fs ? vo_screenheight : o_dheight;
- r.left = vo_fs ? 0 : vo_dy;
+ if (vo_fs) {
+ prev_width = vo_dwidth;
+ prev_height = vo_dheight;
+ prev_x = vo_dx;
+ prev_y = vo_dy;
+ vo_dwidth = vo_screenwidth;
+ vo_dheight = vo_screenheight;
+ vo_dx = vo_screenx;
+ vo_dy = vo_screeny;
+ } else {
+ vo_dwidth = prev_width;
+ vo_dheight = prev_height;
+ vo_dx = prev_x;
+ vo_dy = prev_y;
+ }
+ r.left = vo_dx;
r.right = r.left + vo_dwidth;
- r.top = vo_fs ? 0 : vo_dx;
+ r.top = vo_dy;
r.bottom = r.top + vo_dheight;
AdjustWindowRect(&r, style, 0);
SetWindowPos(vo_window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW);
@@ -216,9 +261,25 @@
return 1;
}
+int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) {
+ // store original size for videomode switching
+ o_dwidth = width;
+ o_dheight = height;
+
+ prev_width = width;
+ prev_height = height;
+ prev_x = vo_dx;
+ prev_y = vo_dy;
+
+ vo_fs = flags & VOFLAG_FULLSCREEN;
+ vo_vm = flags & VOFLAG_MODESWITCHING;
+ return createRenderingContext();
+}
+
int vo_init(void) {
HICON mplayerIcon = 0;
char exedir[MAX_PATH];
+ HINSTANCE user32;
if (vo_window)
return 1;
@@ -253,6 +314,13 @@
vo_hdc = GetDC(vo_window);
+ myMonitorFromWindow = NULL;
+ myGetMonitorInfo = NULL;
+ user32 = GetModuleHandle("user32.dll");
+ if (user32) {
+ myMonitorFromWindow = GetProcAddress(user32, "MonitorFromWindow");
+ myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
+ }
updateScreenProperties();
return 1;
Index: libvo/w32_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/w32_common.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- libvo/w32_common.h 26 Jul 2005 13:47:18 -0000 1.4
+++ libvo/w32_common.h 12 Apr 2006 14:20:51 -0000 1.5
@@ -14,5 +14,5 @@
extern void vo_w32_ontop(void);
extern void vo_w32_fullscreen(void);
extern int vo_w32_check_events(void);
-extern int createRenderingContext(void);
+extern int vo_w32_config(uint32_t, uint32_t, uint32_t);
extern void destroyRenderingContext(void);
More information about the MPlayer-cvslog
mailing list