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 && !p_vout->b_fullscreen )
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_aspect = p_vout->fmt_in.i_aspect;
228 p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
229 p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
230 p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
231 UpdateRects( p_vout, true );
234 /* We used to call the Win32 PeekMessage function here to read the window
235 * messages. But since window can stay blocked into this function for a
236 * long time (for example when you move your window on the screen), I
237 * decided to isolate PeekMessage in another thread. */
242 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
243 || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
245 Win32ToggleFullscreen( p_vout );
247 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
248 p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
254 EventThreadMouseAutoHide( p_vout->p_sys->p_event );
257 * "Always on top" status change
259 if( p_vout->p_sys->b_on_top_change )
261 HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
262 bool b = var_GetBool( p_vout, "video-on-top" );
264 /* Set the window on top if necessary */
265 if( b && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
268 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
269 MF_BYCOMMAND | MFS_CHECKED );
270 SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,
271 SWP_NOSIZE | SWP_NOMOVE );
274 /* The window shouldn't be on top */
275 if( !b && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
278 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
279 MF_BYCOMMAND | MFS_UNCHECKED );
280 SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
281 SWP_NOSIZE | SWP_NOMOVE );
284 p_vout->p_sys->b_on_top_change = false;
288 /*****************************************************************************
289 * UpdateRects: update clipping rectangles
290 *****************************************************************************
291 * This function is called when the window position or size are changed, and
292 * its job is to update the source and destination RECTs used to display the
294 *****************************************************************************/
295 void UpdateRects( vout_thread_t *p_vout, bool b_force )
297 #define rect_src p_vout->p_sys->rect_src
298 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
299 #define rect_dest p_vout->p_sys->rect_dest
300 #define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
302 unsigned int i_width, i_height, i_x, i_y;
307 /* Retrieve the window size */
308 GetClientRect( p_vout->p_sys->hwnd, &rect );
310 /* Retrieve the window position */
311 point.x = point.y = 0;
312 ClientToScreen( p_vout->p_sys->hwnd, &point );
314 /* If nothing changed, we can return */
316 EventThreadUpdateWindowPosition( p_vout->p_sys->p_event, &b_changed,
318 rect.right, rect.bottom );
319 if( !b_force && !b_changed )
322 /* Update the window position and size */
323 vout_PlacePicture( p_vout, rect.right, rect.bottom,
324 &i_x, &i_y, &i_width, &i_height );
326 if( p_vout->p_sys->hvideownd )
327 SetWindowPos( p_vout->p_sys->hvideownd, 0,
328 i_x, i_y, i_width, i_height,
329 SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS );
331 /* Destination image position and dimensions */
332 #if defined(MODULE_NAME_IS_direct3d)
334 rect_dest.right = i_width;
336 rect_dest.bottom = i_height;
338 rect_dest.left = point.x + i_x;
339 rect_dest.right = rect_dest.left + i_width;
340 rect_dest.top = point.y + i_y;
341 rect_dest.bottom = rect_dest.top + i_height;
343 #ifdef MODULE_NAME_IS_directx
344 /* Apply overlay hardware constraints */
345 if( p_vout->p_sys->b_using_overlay )
347 if( p_vout->p_sys->i_align_dest_boundary )
348 rect_dest.left = ( rect_dest.left +
349 p_vout->p_sys->i_align_dest_boundary / 2 ) &
350 ~p_vout->p_sys->i_align_dest_boundary;
352 if( p_vout->p_sys->i_align_dest_size )
353 rect_dest.right = (( rect_dest.right - rect_dest.left +
354 p_vout->p_sys->i_align_dest_size / 2 ) &
355 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
361 #if defined(MODULE_NAME_IS_directx) || defined(MODULE_NAME_IS_direct3d)
362 /* UpdateOverlay directdraw function doesn't automatically clip to the
363 * display size so we need to do it otherwise it will fail
364 * It is also needed for d3d to avoid exceding our surface size */
366 /* Clip the destination window */
367 if( !IntersectRect( &rect_dest_clipped, &rect_dest,
368 &p_vout->p_sys->rect_display ) )
370 SetRectEmpty( &rect_src_clipped );
375 msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
377 rect_dest_clipped.left, rect_dest_clipped.top,
378 rect_dest_clipped.right, rect_dest_clipped.bottom );
383 /* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
384 rect_dest_clipped = rect_dest;
388 /* the 2 following lines are to fix a bug when clicking on the desktop */
389 if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
390 (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
392 SetRectEmpty( &rect_src_clipped );
396 /* src image dimensions */
399 rect_src.right = p_vout->render.i_width;
400 rect_src.bottom = p_vout->render.i_height;
402 /* Clip the source image */
403 rect_src_clipped.left = p_vout->fmt_out.i_x_offset +
404 (rect_dest_clipped.left - rect_dest.left) *
405 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
406 rect_src_clipped.right = p_vout->fmt_out.i_x_offset +
407 p_vout->fmt_out.i_visible_width -
408 (rect_dest.right - rect_dest_clipped.right) *
409 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
410 rect_src_clipped.top = p_vout->fmt_out.i_y_offset +
411 (rect_dest_clipped.top - rect_dest.top) *
412 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
413 rect_src_clipped.bottom = p_vout->fmt_out.i_y_offset +
414 p_vout->fmt_out.i_visible_height -
415 (rect_dest.bottom - rect_dest_clipped.bottom) *
416 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
418 #ifdef MODULE_NAME_IS_directx
419 /* Apply overlay hardware constraints */
420 if( p_vout->p_sys->b_using_overlay )
422 if( p_vout->p_sys->i_align_src_boundary )
423 rect_src_clipped.left = ( rect_src_clipped.left +
424 p_vout->p_sys->i_align_src_boundary / 2 ) &
425 ~p_vout->p_sys->i_align_src_boundary;
427 if( p_vout->p_sys->i_align_src_size )
428 rect_src_clipped.right = (( rect_src_clipped.right -
429 rect_src_clipped.left +
430 p_vout->p_sys->i_align_src_size / 2 ) &
431 ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
433 #elif defined(MODULE_NAME_IS_direct3d)
434 /* Needed at least with YUV content */
435 rect_src_clipped.left &= ~1;
436 rect_src_clipped.right &= ~1;
437 rect_src_clipped.top &= ~1;
438 rect_src_clipped.bottom &= ~1;
442 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
443 " coords: %li,%li,%li,%li",
444 rect_src_clipped.left, rect_src_clipped.top,
445 rect_src_clipped.right, rect_src_clipped.bottom );
448 #ifdef MODULE_NAME_IS_directx
449 /* The destination coordinates need to be relative to the current
450 * directdraw primary surface (display) */
451 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
452 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
453 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
454 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
456 if( p_vout->p_sys->b_using_overlay )
457 DirectDrawUpdateOverlay( p_vout );
461 /* Windows 7 taskbar thumbnail code */
462 LPTASKBARLIST3 p_taskbl;
463 OSVERSIONINFO winVer;
464 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
465 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
469 if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
470 NULL, CLSCTX_INPROC_SERVER,
474 RECT rect_video, rect_parent, rect_relative;
475 HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
477 p_taskbl->vt->HrInit(p_taskbl);
478 GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
479 GetWindowRect(hroot, &rect_parent);
480 rect_relative.left = rect_video.left - rect_parent.left - 8;
481 rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
482 rect_relative.top = rect_video.top - rect_parent.top - 10;
483 rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
485 if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
486 msg_Err( p_vout, "SetThumbNailClip failed");
488 p_taskbl->vt->Release(p_taskbl);
493 /* Signal the change in size/position */
494 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
497 #undef rect_src_clipped
499 #undef rect_dest_clipped
502 /*****************************************************************************
503 * Control: control facility for the vout
504 *****************************************************************************/
505 int Control( vout_thread_t *p_vout, int i_query, va_list args )
512 if( p_vout->p_sys->parent_window )
513 return vaControlParentWindow( p_vout, i_query, args );
515 /* Update dimensions */
516 rect_window.top = rect_window.left = 0;
517 rect_window.right = va_arg( args, unsigned int );
518 rect_window.bottom = va_arg( args, unsigned int );
519 if( !rect_window.right ) rect_window.right = p_vout->i_window_width;
520 if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height;
521 AdjustWindowRect( &rect_window, EventThreadGetWindowStyle( p_vout->p_sys->p_event ), 0 );
523 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
524 rect_window.right - rect_window.left,
525 rect_window.bottom - rect_window.top, SWP_NOMOVE );
529 case VOUT_SET_STAY_ON_TOP:
530 if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
531 return vaControlParentWindow( p_vout, i_query, args );
533 p_vout->p_sys->b_on_top_change = true;
542 /* Internal wrapper over GetWindowPlacement */
543 static WINDOWPLACEMENT getWindowState(HWND hwnd)
545 WINDOWPLACEMENT window_placement;
546 window_placement.length = sizeof(WINDOWPLACEMENT);
547 GetWindowPlacement( hwnd, &window_placement );
548 return window_placement;
551 /* Internal wrapper to call vout_ControlWindow for hparent */
552 static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
559 const unsigned i_width = va_arg(args, unsigned);
560 const unsigned i_height = va_arg(args, unsigned);
561 return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
563 case VOUT_SET_STAY_ON_TOP:
565 const bool is_on_top = va_arg(args, int);
566 return vout_window_SetOnTop( p_vout->p_sys->parent_window, is_on_top );
574 static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
579 va_start( args, i_query );
580 ret = vaControlParentWindow( p_vout, i_query, args );
586 void ExitFullscreen( vout_thread_t *p_vout )
588 if( p_vout->b_fullscreen )
590 msg_Dbg( p_vout, "Quitting fullscreen" );
591 Win32ToggleFullscreen( p_vout );
592 /* Force fullscreen in the core for the next video */
593 var_SetBool( p_vout, "fullscreen", true );
597 void Win32ToggleFullscreen( vout_thread_t *p_vout )
599 HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
600 p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
602 /* Save the current windows placement/placement to restore
603 when fullscreen is over */
604 WINDOWPLACEMENT window_placement = getWindowState( hwnd );
606 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
608 /* We want to go to Fullscreen */
609 if( p_vout->b_fullscreen )
611 msg_Dbg( p_vout, "entering fullscreen mode" );
613 /* Change window style, no borders and no title bar */
614 int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
615 SetWindowLong( hwnd, GWL_STYLE, i_style );
617 if( p_vout->p_sys->hparent )
622 ClientToScreen( p_vout->p_sys->hwnd, &point );
623 GetClientRect( p_vout->p_sys->hwnd, &rect );
624 SetWindowPos( hwnd, 0, point.x, point.y,
625 rect.right, rect.bottom,
626 SWP_NOZORDER|SWP_FRAMECHANGED );
628 /* Retrieve current window position so fullscreen will happen
629 *on the right screen */
630 HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
631 MONITOR_DEFAULTTONEAREST);
633 mi.cbSize = sizeof(MONITORINFO);
634 if (GetMonitorInfo(hmon, &mi))
635 SetWindowPos( hwnd, 0,
638 mi.rcMonitor.right - mi.rcMonitor.left,
639 mi.rcMonitor.bottom - mi.rcMonitor.top,
640 SWP_NOZORDER|SWP_FRAMECHANGED );
645 /* Maximize non embedded window */
646 ShowWindow( hwnd, SW_SHOWMAXIMIZED );
649 if( p_vout->p_sys->hparent )
651 /* Hide the previous window */
653 GetClientRect( hwnd, &rect );
654 SetParent( p_vout->p_sys->hwnd, hwnd );
655 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
656 rect.right, rect.bottom,
657 SWP_NOZORDER|SWP_FRAMECHANGED );
660 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
662 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
664 ShowWindow( topLevelParent, SW_HIDE );
667 SetForegroundWindow( hwnd );
671 msg_Dbg( p_vout, "leaving fullscreen mode" );
672 /* Change window style, no borders and no title bar */
673 SetWindowLong( hwnd, GWL_STYLE, EventThreadGetWindowStyle( p_vout->p_sys->p_event ) );
675 if( p_vout->p_sys->hparent )
678 GetClientRect( p_vout->p_sys->hparent, &rect );
679 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
680 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
681 rect.right, rect.bottom,
682 SWP_NOZORDER|SWP_FRAMECHANGED );
685 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
687 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
689 ShowWindow( topLevelParent, SW_SHOW );
690 SetForegroundWindow( p_vout->p_sys->hparent );
691 ShowWindow( hwnd, SW_HIDE );
695 /* return to normal window for non embedded vout */
696 SetWindowPlacement( hwnd, &window_placement );
697 ShowWindow( hwnd, SW_SHOWNORMAL );
700 /* Make sure the mouse cursor is displayed */
701 EventThreadMouseShow( p_vout->p_sys->p_event );
704 /* Update the object variable and trigger callback */
705 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
709 void DisableScreensaver( vout_thread_t *p_vout )
711 /* disable screensaver by temporarily changing system settings */
712 p_vout->p_sys->i_spi_lowpowertimeout = 0;
713 p_vout->p_sys->i_spi_powerofftimeout = 0;
714 p_vout->p_sys->i_spi_screensavetimeout = 0;
715 if( var_GetBool( p_vout, "disable-screensaver" ) )
717 msg_Dbg(p_vout, "disabling screen saver");
718 SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
719 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
720 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
721 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
723 SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
724 &(p_vout->p_sys->i_spi_powerofftimeout), 0);
725 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
726 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
728 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
729 &(p_vout->p_sys->i_spi_screensavetimeout), 0);
730 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
731 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
736 void RestoreScreensaver( vout_thread_t *p_vout )
738 /* restore screensaver system settings */
739 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
740 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
741 p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
743 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
744 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
745 p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
747 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
748 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
749 p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);