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 <errno.h> /* ENOMEM */
34 #include <ctype.h> /* tolower() */
37 # define _WIN32_WINNT 0x0500
40 #include <vlc_common.h>
41 #include <vlc_interface.h>
42 #include <vlc_playlist.h>
44 #include <vlc_vout_window.h>
51 #ifdef MODULE_NAME_IS_directx
54 #ifdef MODULE_NAME_IS_direct3d
57 #ifdef MODULE_NAME_IS_glwin32
65 #include <vlc_windows_interfaces.h>
70 //WINSHELLAPI BOOL WINAPI SHFullScreen(HWND hwndRequester, DWORD dwState);
73 static int vaControlParentWindow( vout_thread_t *, int, va_list );
76 int CommonInit( vout_thread_t *p_vout )
78 vout_sys_t *p_sys = p_vout->p_sys;
81 p_sys->hvideownd = NULL;
82 p_sys->hparent = NULL;
85 SetRectEmpty( &p_sys->rect_display );
86 SetRectEmpty( &p_sys->rect_parent );
87 vlc_mutex_init( &p_sys->lock );
89 var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
91 /* Set main window's size */
92 vout_window_cfg_t wnd_cfg;
94 memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
95 wnd_cfg.type = VOUT_WINDOW_TYPE_HWND;
98 wnd_cfg.width = p_vout->i_window_width;
99 wnd_cfg.height = p_vout->i_window_height;
101 p_sys->p_event = EventThreadCreate( p_vout, &wnd_cfg );
102 if( !p_sys->p_event )
106 memset(&cfg, 0, sizeof(cfg));
107 #ifdef MODULE_NAME_IS_direct3d
108 cfg.use_desktop = p_vout->p_sys->b_desktop;
110 #ifdef MODULE_NAME_IS_directx
111 cfg.use_overlay = p_vout->p_sys->b_using_overlay;
114 if( EventThreadStart( p_sys->p_event, &hwnd, &cfg ) )
117 p_sys->parent_window = hwnd.parent_window;
118 p_sys->hparent = hwnd.hparent;
119 p_sys->hwnd = hwnd.hwnd;
120 p_sys->hvideownd = hwnd.hvideownd;
121 p_sys->hfswnd = hwnd.hfswnd;
123 /* Variable to indicate if the window should be on top of others */
124 /* Trigger a callback right now */
125 var_TriggerCallback( p_vout, "video-on-top" );
127 /* Why not with glwin32 */
128 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
129 var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
130 DisableScreensaver ( p_vout );
137 void CommonClean( vout_thread_t *p_vout )
139 vout_sys_t *p_sys = p_vout->p_sys;
141 ExitFullscreen( p_vout );
144 EventThreadStop( p_sys->p_event );
145 EventThreadDestroy( p_sys->p_event );
148 vlc_mutex_destroy( &p_sys->lock );
150 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
151 RestoreScreensaver( p_vout );
155 void CommonManage( vout_thread_t *p_vout )
157 /* If we do not control our window, we check for geometry changes
158 * ourselves because the parent might not send us its events. */
159 vlc_mutex_lock( &p_vout->p_sys->lock );
160 if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )
165 vlc_mutex_unlock( &p_vout->p_sys->lock );
167 GetClientRect( p_vout->p_sys->hparent, &rect_parent );
168 point.x = point.y = 0;
169 ClientToScreen( p_vout->p_sys->hparent, &point );
170 OffsetRect( &rect_parent, point.x, point.y );
172 if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )
174 p_vout->p_sys->rect_parent = rect_parent;
176 /* FIXME I find such #ifdef quite weirds. Are they really needed ? */
178 #if defined(MODULE_NAME_IS_direct3d)
179 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
180 rect_parent.right - rect_parent.left,
181 rect_parent.bottom - rect_parent.top,
183 UpdateRects( p_vout, true );
185 /* This one is to force the update even if only
186 * the position has changed */
187 SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,
188 rect_parent.right - rect_parent.left,
189 rect_parent.bottom - rect_parent.top, 0 );
191 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
192 rect_parent.right - rect_parent.left,
193 rect_parent.bottom - rect_parent.top, 0 );
195 #if defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
196 unsigned int i_x, i_y, i_width, i_height;
197 vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left,
198 rect_parent.bottom - rect_parent.top,
199 &i_x, &i_y, &i_width, &i_height );
201 SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,
202 i_x, i_y, i_width, i_height, 0 );
209 vlc_mutex_unlock( &p_vout->p_sys->lock );
213 p_vout->p_sys->i_changes |= EventThreadRetreiveChanges( p_vout->p_sys->p_event );
215 /* autoscale toggle */
216 if( p_vout->i_changes & VOUT_SCALE_CHANGE )
218 p_vout->i_changes &= ~VOUT_SCALE_CHANGE;
220 p_vout->b_autoscale = var_GetBool( p_vout, "autoscale" );
221 p_vout->i_zoom = (int) ZOOM_FP_FACTOR;
223 UpdateRects( p_vout, true );
227 if( p_vout->i_changes & VOUT_ZOOM_CHANGE )
229 p_vout->i_changes &= ~VOUT_ZOOM_CHANGE;
231 p_vout->b_autoscale = false;
233 (int)( ZOOM_FP_FACTOR * var_GetFloat( p_vout, "scale" ) );
234 UpdateRects( p_vout, true );
237 /* Check for cropping / aspect changes */
238 if( p_vout->i_changes & VOUT_CROP_CHANGE ||
239 p_vout->i_changes & VOUT_ASPECT_CHANGE )
241 p_vout->i_changes &= ~VOUT_CROP_CHANGE;
242 p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
244 p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
245 p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
246 p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
247 p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
248 p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
249 p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
250 p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
251 p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
252 UpdateRects( p_vout, true );
255 /* We used to call the Win32 PeekMessage function here to read the window
256 * messages. But since window can stay blocked into this function for a
257 * long time (for example when you move your window on the screen), I
258 * decided to isolate PeekMessage in another thread. */
263 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
264 || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
266 Win32ToggleFullscreen( p_vout );
268 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
269 p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
275 EventThreadMouseAutoHide( p_vout->p_sys->p_event );
278 * "Always on top" status change
280 if( p_vout->p_sys->b_on_top_change )
282 HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
283 bool b = var_GetBool( p_vout, "video-on-top" );
285 /* Set the window on top if necessary */
286 if( b && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
289 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
290 MF_BYCOMMAND | MFS_CHECKED );
291 SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,
292 SWP_NOSIZE | SWP_NOMOVE );
295 /* The window shouldn't be on top */
296 if( !b && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
299 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
300 MF_BYCOMMAND | MFS_UNCHECKED );
301 SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
302 SWP_NOSIZE | SWP_NOMOVE );
305 p_vout->p_sys->b_on_top_change = false;
309 /*****************************************************************************
310 * UpdateRects: update clipping rectangles
311 *****************************************************************************
312 * This function is called when the window position or size are changed, and
313 * its job is to update the source and destination RECTs used to display the
315 *****************************************************************************/
316 void UpdateRects( vout_thread_t *p_vout, bool b_force )
318 #define rect_src p_vout->p_sys->rect_src
319 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
320 #define rect_dest p_vout->p_sys->rect_dest
321 #define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
323 unsigned int i_width, i_height, i_x, i_y;
328 /* Retrieve the window size */
329 GetClientRect( p_vout->p_sys->hwnd, &rect );
331 /* Retrieve the window position */
332 point.x = point.y = 0;
333 ClientToScreen( p_vout->p_sys->hwnd, &point );
335 /* If nothing changed, we can return */
337 EventThreadUpdateWindowPosition( p_vout->p_sys->p_event, &b_changed,
339 rect.right, rect.bottom );
340 if( !b_force && !b_changed )
343 /* Update the window position and size */
344 vout_PlacePicture( p_vout, rect.right, rect.bottom,
345 &i_x, &i_y, &i_width, &i_height );
347 if( p_vout->p_sys->hvideownd )
348 SetWindowPos( p_vout->p_sys->hvideownd, 0,
349 i_x, i_y, i_width, i_height,
350 SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS );
352 /* Destination image position and dimensions */
353 rect_dest.left = point.x + i_x;
354 rect_dest.right = rect_dest.left + i_width;
355 rect_dest.top = point.y + i_y;
356 rect_dest.bottom = rect_dest.top + i_height;
358 #ifdef MODULE_NAME_IS_directx
359 /* Apply overlay hardware constraints */
360 if( p_vout->p_sys->b_using_overlay )
362 if( p_vout->p_sys->i_align_dest_boundary )
363 rect_dest.left = ( rect_dest.left +
364 p_vout->p_sys->i_align_dest_boundary / 2 ) &
365 ~p_vout->p_sys->i_align_dest_boundary;
367 if( p_vout->p_sys->i_align_dest_size )
368 rect_dest.right = (( rect_dest.right - rect_dest.left +
369 p_vout->p_sys->i_align_dest_size / 2 ) &
370 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
373 /* UpdateOverlay directdraw function doesn't automatically clip to the
374 * display size so we need to do it otherwise it will fail */
376 /* Clip the destination window */
377 if( !IntersectRect( &rect_dest_clipped, &rect_dest,
378 &p_vout->p_sys->rect_display ) )
380 SetRectEmpty( &rect_src_clipped );
385 msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
387 rect_dest_clipped.left, rect_dest_clipped.top,
388 rect_dest_clipped.right, rect_dest_clipped.bottom );
391 #else /* MODULE_NAME_IS_directx */
393 /* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
394 rect_dest_clipped = rect_dest;
398 /* the 2 following lines are to fix a bug when clicking on the desktop */
399 if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
400 (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
402 SetRectEmpty( &rect_src_clipped );
406 /* src image dimensions */
409 rect_src.right = p_vout->render.i_width;
410 rect_src.bottom = p_vout->render.i_height;
412 /* Clip the source image */
413 rect_src_clipped.left = p_vout->fmt_out.i_x_offset +
414 (rect_dest_clipped.left - rect_dest.left) *
415 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
416 rect_src_clipped.right = p_vout->fmt_out.i_x_offset +
417 p_vout->fmt_out.i_visible_width -
418 (rect_dest.right - rect_dest_clipped.right) *
419 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
420 rect_src_clipped.top = p_vout->fmt_out.i_y_offset +
421 (rect_dest_clipped.top - rect_dest.top) *
422 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
423 rect_src_clipped.bottom = p_vout->fmt_out.i_y_offset +
424 p_vout->fmt_out.i_visible_height -
425 (rect_dest.bottom - rect_dest_clipped.bottom) *
426 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
428 #ifdef MODULE_NAME_IS_directx
429 /* Apply overlay hardware constraints */
430 if( p_vout->p_sys->b_using_overlay )
432 if( p_vout->p_sys->i_align_src_boundary )
433 rect_src_clipped.left = ( rect_src_clipped.left +
434 p_vout->p_sys->i_align_src_boundary / 2 ) &
435 ~p_vout->p_sys->i_align_src_boundary;
437 if( p_vout->p_sys->i_align_src_size )
438 rect_src_clipped.right = (( rect_src_clipped.right -
439 rect_src_clipped.left +
440 p_vout->p_sys->i_align_src_size / 2 ) &
441 ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
446 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
447 " coords: %li,%li,%li,%li",
448 rect_src_clipped.left, rect_src_clipped.top,
449 rect_src_clipped.right, rect_src_clipped.bottom );
452 #ifdef MODULE_NAME_IS_directx
453 /* The destination coordinates need to be relative to the current
454 * directdraw primary surface (display) */
455 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
456 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
457 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
458 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
460 if( p_vout->p_sys->b_using_overlay )
461 DirectDrawUpdateOverlay( p_vout );
465 /* Windows 7 taskbar thumbnail code */
466 LPTASKBARLIST3 p_taskbl;
467 OSVERSIONINFO winVer;
468 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
469 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
473 if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
474 NULL, CLSCTX_INPROC_SERVER,
478 RECT rect_video, rect_parent, rect_relative;
479 HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
481 p_taskbl->vt->HrInit(p_taskbl);
482 GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
483 GetWindowRect(hroot, &rect_parent);
484 rect_relative.left = rect_video.left - rect_parent.left - 8;
485 rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
486 rect_relative.top = rect_video.top - rect_parent.top - 10;
487 rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
489 if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
490 msg_Err( p_vout, "SetThumbNailClip failed");
492 p_taskbl->vt->Release(p_taskbl);
497 /* Signal the change in size/position */
498 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
501 #undef rect_src_clipped
503 #undef rect_dest_clipped
506 /*****************************************************************************
507 * Control: control facility for the vout
508 *****************************************************************************/
509 int Control( vout_thread_t *p_vout, int i_query, va_list args )
516 if( p_vout->p_sys->parent_window )
517 return vaControlParentWindow( p_vout, i_query, args );
519 /* Update dimensions */
520 rect_window.top = rect_window.left = 0;
521 rect_window.right = va_arg( args, unsigned int );
522 rect_window.bottom = va_arg( args, unsigned int );
523 if( !rect_window.right ) rect_window.right = p_vout->i_window_width;
524 if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height;
525 AdjustWindowRect( &rect_window, EventThreadGetWindowStyle( p_vout->p_sys->p_event ), 0 );
527 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
528 rect_window.right - rect_window.left,
529 rect_window.bottom - rect_window.top, SWP_NOMOVE );
533 case VOUT_SET_STAY_ON_TOP:
534 if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
535 return vaControlParentWindow( p_vout, i_query, args );
537 p_vout->p_sys->b_on_top_change = true;
546 /* Internal wrapper over GetWindowPlacement */
547 static WINDOWPLACEMENT getWindowState(HWND hwnd)
549 WINDOWPLACEMENT window_placement;
550 window_placement.length = sizeof(WINDOWPLACEMENT);
551 GetWindowPlacement( hwnd, &window_placement );
552 return window_placement;
555 /* Internal wrapper to call vout_ControlWindow for hparent */
556 static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
563 const unsigned i_width = va_arg(args, unsigned);
564 const unsigned i_height = va_arg(args, unsigned);
565 return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
567 case VOUT_SET_STAY_ON_TOP:
569 const bool is_on_top = va_arg(args, int);
570 return vout_window_SetOnTop( p_vout->p_sys->parent_window, is_on_top );
578 static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
583 va_start( args, i_query );
584 ret = vaControlParentWindow( p_vout, i_query, args );
590 void ExitFullscreen( vout_thread_t *p_vout )
592 if( p_vout->b_fullscreen )
594 msg_Dbg( p_vout, "Quitting fullscreen" );
595 Win32ToggleFullscreen( p_vout );
596 /* Force fullscreen in the core for the next video */
597 var_SetBool( p_vout, "fullscreen", true );
601 void Win32ToggleFullscreen( vout_thread_t *p_vout )
603 HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
604 p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
606 /* Save the current windows placement/placement to restore
607 when fullscreen is over */
608 WINDOWPLACEMENT window_placement = getWindowState( hwnd );
610 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
612 /* We want to go to Fullscreen */
613 if( p_vout->b_fullscreen )
615 msg_Dbg( p_vout, "entering fullscreen mode" );
617 /* Change window style, no borders and no title bar */
618 int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
619 SetWindowLong( hwnd, GWL_STYLE, i_style );
621 if( p_vout->p_sys->hparent )
626 ClientToScreen( p_vout->p_sys->hwnd, &point );
627 GetClientRect( p_vout->p_sys->hwnd, &rect );
628 SetWindowPos( hwnd, 0, point.x, point.y,
629 rect.right, rect.bottom,
630 SWP_NOZORDER|SWP_FRAMECHANGED );
632 /* Retrieve current window position so fullscreen will happen
633 *on the right screen */
634 HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
635 MONITOR_DEFAULTTONEAREST);
637 if (GetMonitorInfo(hmon, &mi))
638 SetWindowPos( hwnd, 0,
641 mi.rcMonitor.right - mi.rcMonitor.left,
642 mi.rcMonitor.bottom - mi.rcMonitor.top,
643 SWP_NOZORDER|SWP_FRAMECHANGED );
648 /* Maximize non embedded window */
649 ShowWindow( hwnd, SW_SHOWMAXIMIZED );
652 if( p_vout->p_sys->hparent )
654 /* Hide the previous window */
656 GetClientRect( hwnd, &rect );
657 SetParent( p_vout->p_sys->hwnd, hwnd );
658 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
659 rect.right, rect.bottom,
660 SWP_NOZORDER|SWP_FRAMECHANGED );
663 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
665 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
667 ShowWindow( topLevelParent, SW_HIDE );
670 SetForegroundWindow( hwnd );
674 msg_Dbg( p_vout, "leaving fullscreen mode" );
675 /* Change window style, no borders and no title bar */
676 SetWindowLong( hwnd, GWL_STYLE, EventThreadGetWindowStyle( p_vout->p_sys->p_event ) );
678 if( p_vout->p_sys->hparent )
681 GetClientRect( p_vout->p_sys->hparent, &rect );
682 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
683 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
684 rect.right, rect.bottom,
685 SWP_NOZORDER|SWP_FRAMECHANGED );
688 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
690 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
692 ShowWindow( topLevelParent, SW_SHOW );
693 SetForegroundWindow( p_vout->p_sys->hparent );
694 ShowWindow( hwnd, SW_HIDE );
698 /* return to normal window for non embedded vout */
699 SetWindowPlacement( hwnd, &window_placement );
700 ShowWindow( hwnd, SW_SHOWNORMAL );
703 /* Make sure the mouse cursor is displayed */
704 EventThreadMouseShow( p_vout->p_sys->p_event );
707 /* Update the object variable and trigger callback */
708 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
712 void DisableScreensaver( vout_thread_t *p_vout )
714 /* disable screensaver by temporarily changing system settings */
715 p_vout->p_sys->i_spi_lowpowertimeout = 0;
716 p_vout->p_sys->i_spi_powerofftimeout = 0;
717 p_vout->p_sys->i_spi_screensavetimeout = 0;
718 if( var_GetBool( p_vout, "disable-screensaver" ) )
720 msg_Dbg(p_vout, "disabling screen saver");
721 SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
722 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
723 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
724 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
726 SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
727 &(p_vout->p_sys->i_spi_powerofftimeout), 0);
728 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
729 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
731 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
732 &(p_vout->p_sys->i_spi_screensavetimeout), 0);
733 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
734 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
739 void RestoreScreensaver( vout_thread_t *p_vout )
741 /* restore screensaver system settings */
742 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
743 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
744 p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
746 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
747 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
748 p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
750 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
751 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
752 p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);