1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001-2009 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 /*****************************************************************************
26 * Preamble: This file contains the functions related to the creation of
27 * a window and the handling of its messages (events).
28 *****************************************************************************/
33 #include <vlc_common.h>
35 #include <vlc_vout_window.h>
41 #ifdef MODULE_NAME_IS_directx
44 #ifdef MODULE_NAME_IS_direct3d
47 #ifdef MODULE_NAME_IS_glwin32
54 #include <vlc_windows_interfaces.h>
59 //WINSHELLAPI BOOL WINAPI SHFullScreen(HWND hwndRequester, DWORD dwState);
62 static int vaControlParentWindow( vout_thread_t *, int, va_list );
65 int CommonInit( vout_thread_t *p_vout )
67 vout_sys_t *p_sys = p_vout->p_sys;
70 p_sys->hvideownd = NULL;
71 p_sys->hparent = NULL;
74 SetRectEmpty( &p_sys->rect_display );
75 SetRectEmpty( &p_sys->rect_parent );
77 var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
79 /* Set main window's size */
80 vout_window_cfg_t wnd_cfg;
82 memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
83 wnd_cfg.type = VOUT_WINDOW_TYPE_HWND;
86 wnd_cfg.width = p_vout->i_window_width;
87 wnd_cfg.height = p_vout->i_window_height;
89 p_sys->p_event = EventThreadCreate( p_vout, &wnd_cfg );
94 memset(&cfg, 0, sizeof(cfg));
95 #ifdef MODULE_NAME_IS_direct3d
96 cfg.use_desktop = p_vout->p_sys->b_desktop;
98 #ifdef MODULE_NAME_IS_directx
99 cfg.use_overlay = p_vout->p_sys->b_using_overlay;
102 if( EventThreadStart( p_sys->p_event, &hwnd, &cfg ) )
105 p_sys->parent_window = hwnd.parent_window;
106 p_sys->hparent = hwnd.hparent;
107 p_sys->hwnd = hwnd.hwnd;
108 p_sys->hvideownd = hwnd.hvideownd;
109 p_sys->hfswnd = hwnd.hfswnd;
111 /* Variable to indicate if the window should be on top of others */
112 /* Trigger a callback right now */
113 var_TriggerCallback( p_vout, "video-on-top" );
115 /* Why not with glwin32 */
116 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
117 var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
118 DisableScreensaver ( p_vout );
125 void CommonClean( vout_thread_t *p_vout )
127 vout_sys_t *p_sys = p_vout->p_sys;
129 ExitFullscreen( p_vout );
132 EventThreadStop( p_sys->p_event );
133 EventThreadDestroy( p_sys->p_event );
136 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
137 RestoreScreensaver( p_vout );
141 void CommonManage( vout_thread_t *p_vout )
143 /* If we do not control our window, we check for geometry changes
144 * ourselves because the parent might not send us its events. */
145 if( p_vout->p_sys->hparent )
150 GetClientRect( p_vout->p_sys->hparent, &rect_parent );
151 point.x = point.y = 0;
152 ClientToScreen( p_vout->p_sys->hparent, &point );
153 OffsetRect( &rect_parent, point.x, point.y );
155 if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )
157 p_vout->p_sys->rect_parent = rect_parent;
159 /* FIXME I find such #ifdef quite weirds. Are they really needed ? */
161 #if defined(MODULE_NAME_IS_direct3d)
162 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
163 rect_parent.right - rect_parent.left,
164 rect_parent.bottom - rect_parent.top,
166 UpdateRects( p_vout, true );
168 /* This one is to force the update even if only
169 * the position has changed */
170 SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,
171 rect_parent.right - rect_parent.left,
172 rect_parent.bottom - rect_parent.top, 0 );
174 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
175 rect_parent.right - rect_parent.left,
176 rect_parent.bottom - rect_parent.top, 0 );
178 #if defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
179 unsigned int i_x, i_y, i_width, i_height;
180 vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left,
181 rect_parent.bottom - rect_parent.top,
182 &i_x, &i_y, &i_width, &i_height );
184 SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,
185 i_x, i_y, i_width, i_height, 0 );
192 p_vout->p_sys->i_changes |= EventThreadRetreiveChanges( p_vout->p_sys->p_event );
194 /* autoscale toggle */
195 if( p_vout->i_changes & VOUT_SCALE_CHANGE )
197 p_vout->i_changes &= ~VOUT_SCALE_CHANGE;
199 p_vout->b_autoscale = var_GetBool( p_vout, "autoscale" );
200 p_vout->i_zoom = (int) ZOOM_FP_FACTOR;
202 UpdateRects( p_vout, true );
206 if( p_vout->i_changes & VOUT_ZOOM_CHANGE )
208 p_vout->i_changes &= ~VOUT_ZOOM_CHANGE;
210 p_vout->b_autoscale = false;
212 (int)( ZOOM_FP_FACTOR * var_GetFloat( p_vout, "scale" ) );
213 UpdateRects( p_vout, true );
216 /* Check for cropping / aspect changes */
217 if( p_vout->i_changes & VOUT_CROP_CHANGE ||
218 p_vout->i_changes & VOUT_ASPECT_CHANGE )
220 p_vout->i_changes &= ~VOUT_CROP_CHANGE;
221 p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
223 p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
224 p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
225 p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
226 p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
227 p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
228 p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
229 p_vout->output.i_aspect = (int64_t)VOUT_ASPECT_FACTOR *
230 p_vout->fmt_in.i_sar_num * p_vout->fmt_in.i_width /
231 (p_vout->fmt_in.i_sar_den * p_vout->fmt_in.i_height);
232 UpdateRects( p_vout, true );
235 /* We used to call the Win32 PeekMessage function here to read the window
236 * messages. But since window can stay blocked into this function for a
237 * long time (for example when you move your window on the screen), I
238 * decided to isolate PeekMessage in another thread. */
243 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
244 || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
246 Win32ToggleFullscreen( p_vout );
248 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
249 p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
255 EventThreadMouseAutoHide( p_vout->p_sys->p_event );
258 * "Always on top" status change
260 if( p_vout->p_sys->b_on_top_change )
262 HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
263 bool b = var_GetBool( p_vout, "video-on-top" );
265 /* Set the window on top if necessary */
266 if( b && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
269 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
270 MF_BYCOMMAND | MFS_CHECKED );
271 SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,
272 SWP_NOSIZE | SWP_NOMOVE );
275 /* The window shouldn't be on top */
276 if( !b && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
279 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
280 MF_BYCOMMAND | MFS_UNCHECKED );
281 SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
282 SWP_NOSIZE | SWP_NOMOVE );
285 p_vout->p_sys->b_on_top_change = false;
289 /*****************************************************************************
290 * UpdateRects: update clipping rectangles
291 *****************************************************************************
292 * This function is called when the window position or size are changed, and
293 * its job is to update the source and destination RECTs used to display the
295 *****************************************************************************/
296 void UpdateRects( vout_thread_t *p_vout, bool b_force )
298 #define rect_src p_vout->p_sys->rect_src
299 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
300 #define rect_dest p_vout->p_sys->rect_dest
301 #define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
303 unsigned int i_width, i_height, i_x, i_y;
308 /* Retrieve the window size */
309 GetClientRect( p_vout->p_sys->hwnd, &rect );
311 /* Retrieve the window position */
312 point.x = point.y = 0;
313 ClientToScreen( p_vout->p_sys->hwnd, &point );
315 /* If nothing changed, we can return */
317 EventThreadUpdateWindowPosition( p_vout->p_sys->p_event, &b_changed,
319 rect.right, rect.bottom );
320 if( !b_force && !b_changed )
323 /* Update the window position and size */
324 vout_PlacePicture( p_vout, rect.right, rect.bottom,
325 &i_x, &i_y, &i_width, &i_height );
327 if( p_vout->p_sys->hvideownd )
328 SetWindowPos( p_vout->p_sys->hvideownd, 0,
329 i_x, i_y, i_width, i_height,
330 SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS );
332 /* Destination image position and dimensions */
333 #if defined(MODULE_NAME_IS_direct3d)
335 rect_dest.right = i_width;
337 rect_dest.bottom = i_height;
339 rect_dest.left = point.x + i_x;
340 rect_dest.right = rect_dest.left + i_width;
341 rect_dest.top = point.y + i_y;
342 rect_dest.bottom = rect_dest.top + i_height;
344 #ifdef MODULE_NAME_IS_directx
345 /* Apply overlay hardware constraints */
346 if( p_vout->p_sys->b_using_overlay )
348 if( p_vout->p_sys->i_align_dest_boundary )
349 rect_dest.left = ( rect_dest.left +
350 p_vout->p_sys->i_align_dest_boundary / 2 ) &
351 ~p_vout->p_sys->i_align_dest_boundary;
353 if( p_vout->p_sys->i_align_dest_size )
354 rect_dest.right = (( rect_dest.right - rect_dest.left +
355 p_vout->p_sys->i_align_dest_size / 2 ) &
356 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
362 #if defined(MODULE_NAME_IS_directx) || defined(MODULE_NAME_IS_direct3d)
363 /* UpdateOverlay directdraw function doesn't automatically clip to the
364 * display size so we need to do it otherwise it will fail
365 * It is also needed for d3d to avoid exceding our surface size */
367 /* Clip the destination window */
368 if( !IntersectRect( &rect_dest_clipped, &rect_dest,
369 &p_vout->p_sys->rect_display ) )
371 SetRectEmpty( &rect_src_clipped );
376 msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
378 rect_dest_clipped.left, rect_dest_clipped.top,
379 rect_dest_clipped.right, rect_dest_clipped.bottom );
384 /* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
385 rect_dest_clipped = rect_dest;
389 /* the 2 following lines are to fix a bug when clicking on the desktop */
390 if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
391 (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
393 SetRectEmpty( &rect_src_clipped );
397 /* src image dimensions */
400 rect_src.right = p_vout->render.i_width;
401 rect_src.bottom = p_vout->render.i_height;
403 /* Clip the source image */
404 rect_src_clipped.left = p_vout->fmt_out.i_x_offset +
405 (rect_dest_clipped.left - rect_dest.left) *
406 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
407 rect_src_clipped.right = p_vout->fmt_out.i_x_offset +
408 p_vout->fmt_out.i_visible_width -
409 (rect_dest.right - rect_dest_clipped.right) *
410 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
411 rect_src_clipped.top = p_vout->fmt_out.i_y_offset +
412 (rect_dest_clipped.top - rect_dest.top) *
413 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
414 rect_src_clipped.bottom = p_vout->fmt_out.i_y_offset +
415 p_vout->fmt_out.i_visible_height -
416 (rect_dest.bottom - rect_dest_clipped.bottom) *
417 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
419 #ifdef MODULE_NAME_IS_directx
420 /* Apply overlay hardware constraints */
421 if( p_vout->p_sys->b_using_overlay )
423 if( p_vout->p_sys->i_align_src_boundary )
424 rect_src_clipped.left = ( rect_src_clipped.left +
425 p_vout->p_sys->i_align_src_boundary / 2 ) &
426 ~p_vout->p_sys->i_align_src_boundary;
428 if( p_vout->p_sys->i_align_src_size )
429 rect_src_clipped.right = (( rect_src_clipped.right -
430 rect_src_clipped.left +
431 p_vout->p_sys->i_align_src_size / 2 ) &
432 ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
434 #elif defined(MODULE_NAME_IS_direct3d)
435 /* Needed at least with YUV content */
436 rect_src_clipped.left &= ~1;
437 rect_src_clipped.right &= ~1;
438 rect_src_clipped.top &= ~1;
439 rect_src_clipped.bottom &= ~1;
443 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
444 " coords: %li,%li,%li,%li",
445 rect_src_clipped.left, rect_src_clipped.top,
446 rect_src_clipped.right, rect_src_clipped.bottom );
449 #ifdef MODULE_NAME_IS_directx
450 /* The destination coordinates need to be relative to the current
451 * directdraw primary surface (display) */
452 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
453 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
454 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
455 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
457 if( p_vout->p_sys->b_using_overlay )
458 DirectDrawUpdateOverlay( p_vout );
462 /* Windows 7 taskbar thumbnail code */
463 LPTASKBARLIST3 p_taskbl;
464 OSVERSIONINFO winVer;
465 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
466 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
470 if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
471 NULL, CLSCTX_INPROC_SERVER,
475 RECT rect_video, rect_parent, rect_relative;
476 HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
478 p_taskbl->vt->HrInit(p_taskbl);
479 GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
480 GetWindowRect(hroot, &rect_parent);
481 rect_relative.left = rect_video.left - rect_parent.left - 8;
482 rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
483 rect_relative.top = rect_video.top - rect_parent.top - 10;
484 rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
486 if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
487 msg_Err( p_vout, "SetThumbNailClip failed");
489 p_taskbl->vt->Release(p_taskbl);
494 /* Signal the change in size/position */
495 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
498 #undef rect_src_clipped
500 #undef rect_dest_clipped
503 /*****************************************************************************
504 * Control: control facility for the vout
505 *****************************************************************************/
506 int Control( vout_thread_t *p_vout, int i_query, va_list args )
513 if( p_vout->p_sys->parent_window )
514 return vaControlParentWindow( p_vout, i_query, args );
516 /* Update dimensions */
517 rect_window.top = rect_window.left = 0;
518 rect_window.right = va_arg( args, unsigned int );
519 rect_window.bottom = va_arg( args, unsigned int );
520 if( !rect_window.right ) rect_window.right = p_vout->i_window_width;
521 if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height;
522 AdjustWindowRect( &rect_window, EventThreadGetWindowStyle( p_vout->p_sys->p_event ), 0 );
524 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
525 rect_window.right - rect_window.left,
526 rect_window.bottom - rect_window.top, SWP_NOMOVE );
530 case VOUT_SET_STAY_ON_TOP:
531 if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
532 return vaControlParentWindow( p_vout, i_query, args );
534 p_vout->p_sys->b_on_top_change = true;
543 /* Internal wrapper over GetWindowPlacement */
544 static WINDOWPLACEMENT getWindowState(HWND hwnd)
546 WINDOWPLACEMENT window_placement;
547 window_placement.length = sizeof(WINDOWPLACEMENT);
548 GetWindowPlacement( hwnd, &window_placement );
549 return window_placement;
552 /* Internal wrapper to call vout_ControlWindow for hparent */
553 static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
560 const unsigned i_width = va_arg(args, unsigned);
561 const unsigned i_height = va_arg(args, unsigned);
562 return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
564 case VOUT_SET_STAY_ON_TOP:
566 const bool is_on_top = va_arg(args, int);
567 return vout_window_SetState( p_vout->p_sys->parent_window, is_on_top );
575 static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
580 va_start( args, i_query );
581 ret = vaControlParentWindow( p_vout, i_query, args );
587 void ExitFullscreen( vout_thread_t *p_vout )
589 if( p_vout->b_fullscreen )
591 msg_Dbg( p_vout, "Quitting fullscreen" );
592 Win32ToggleFullscreen( p_vout );
593 /* Force fullscreen in the core for the next video */
594 var_SetBool( p_vout, "fullscreen", true );
598 void Win32ToggleFullscreen( vout_thread_t *p_vout )
600 HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
601 p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
603 /* Save the current windows placement/placement to restore
604 when fullscreen is over */
605 WINDOWPLACEMENT window_placement = getWindowState( hwnd );
607 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
609 if( p_vout->p_sys->parent_window )
611 vout_window_SetFullScreen( p_vout->p_sys->parent_window,
612 p_vout->b_fullscreen );
616 /* We want to go to Fullscreen */
617 if( p_vout->b_fullscreen )
619 msg_Dbg( p_vout, "entering fullscreen mode" );
621 /* Change window style, no borders and no title bar */
622 int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
623 SetWindowLong( hwnd, GWL_STYLE, i_style );
625 if( p_vout->p_sys->hparent )
630 ClientToScreen( p_vout->p_sys->hwnd, &point );
631 GetClientRect( p_vout->p_sys->hwnd, &rect );
632 SetWindowPos( hwnd, 0, point.x, point.y,
633 rect.right, rect.bottom,
634 SWP_NOZORDER|SWP_FRAMECHANGED );
636 /* Retrieve current window position so fullscreen will happen
637 *on the right screen */
638 HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
639 MONITOR_DEFAULTTONEAREST);
641 mi.cbSize = sizeof(MONITORINFO);
642 if (GetMonitorInfo(hmon, &mi))
643 SetWindowPos( hwnd, 0,
646 mi.rcMonitor.right - mi.rcMonitor.left,
647 mi.rcMonitor.bottom - mi.rcMonitor.top,
648 SWP_NOZORDER|SWP_FRAMECHANGED );
653 /* Maximize non embedded window */
654 ShowWindow( hwnd, SW_SHOWMAXIMIZED );
657 if( p_vout->p_sys->hparent )
659 /* Hide the previous window */
661 GetClientRect( hwnd, &rect );
662 SetParent( p_vout->p_sys->hwnd, hwnd );
663 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
664 rect.right, rect.bottom,
665 SWP_NOZORDER|SWP_FRAMECHANGED );
668 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
670 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
672 ShowWindow( topLevelParent, SW_HIDE );
675 SetForegroundWindow( hwnd );
679 msg_Dbg( p_vout, "leaving fullscreen mode" );
680 /* Change window style, no borders and no title bar */
681 SetWindowLong( hwnd, GWL_STYLE, EventThreadGetWindowStyle( p_vout->p_sys->p_event ) );
683 if( p_vout->p_sys->hparent )
686 GetClientRect( p_vout->p_sys->hparent, &rect );
687 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
688 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
689 rect.right, rect.bottom,
690 SWP_NOZORDER|SWP_FRAMECHANGED );
693 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
695 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
697 ShowWindow( topLevelParent, SW_SHOW );
698 SetForegroundWindow( p_vout->p_sys->hparent );
699 ShowWindow( hwnd, SW_HIDE );
703 /* return to normal window for non embedded vout */
704 SetWindowPlacement( hwnd, &window_placement );
705 ShowWindow( hwnd, SW_SHOWNORMAL );
708 /* Make sure the mouse cursor is displayed */
709 EventThreadMouseShow( p_vout->p_sys->p_event );
712 /* Update the object variable and trigger callback */
713 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
717 void DisableScreensaver( vout_thread_t *p_vout )
719 /* disable screensaver by temporarily changing system settings */
720 p_vout->p_sys->i_spi_lowpowertimeout = 0;
721 p_vout->p_sys->i_spi_powerofftimeout = 0;
722 p_vout->p_sys->i_spi_screensavetimeout = 0;
723 if( var_GetBool( p_vout, "disable-screensaver" ) )
725 msg_Dbg(p_vout, "disabling screen saver");
726 SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
727 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
728 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
729 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
731 SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
732 &(p_vout->p_sys->i_spi_powerofftimeout), 0);
733 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
734 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
736 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
737 &(p_vout->p_sys->i_spi_screensavetimeout), 0);
738 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
739 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
744 void RestoreScreensaver( vout_thread_t *p_vout )
746 /* restore screensaver system settings */
747 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
748 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
749 p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
751 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
752 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
753 p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
755 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
756 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
757 p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);