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 );
88 var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
90 /* Set main window's size */
91 vout_window_cfg_t wnd_cfg;
93 memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
94 wnd_cfg.type = VOUT_WINDOW_TYPE_HWND;
97 wnd_cfg.width = p_vout->i_window_width;
98 wnd_cfg.height = p_vout->i_window_height;
100 p_sys->p_event = EventThreadCreate( p_vout, &wnd_cfg );
101 if( !p_sys->p_event )
105 memset(&cfg, 0, sizeof(cfg));
106 #ifdef MODULE_NAME_IS_direct3d
107 cfg.use_desktop = p_vout->p_sys->b_desktop;
109 #ifdef MODULE_NAME_IS_directx
110 cfg.use_overlay = p_vout->p_sys->b_using_overlay;
113 if( EventThreadStart( p_sys->p_event, &hwnd, &cfg ) )
116 p_sys->parent_window = hwnd.parent_window;
117 p_sys->hparent = hwnd.hparent;
118 p_sys->hwnd = hwnd.hwnd;
119 p_sys->hvideownd = hwnd.hvideownd;
120 p_sys->hfswnd = hwnd.hfswnd;
122 /* Variable to indicate if the window should be on top of others */
123 /* Trigger a callback right now */
124 var_TriggerCallback( p_vout, "video-on-top" );
126 /* Why not with glwin32 */
127 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
128 var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
129 DisableScreensaver ( p_vout );
136 void CommonClean( vout_thread_t *p_vout )
138 vout_sys_t *p_sys = p_vout->p_sys;
140 ExitFullscreen( p_vout );
143 EventThreadStop( p_sys->p_event );
144 EventThreadDestroy( p_sys->p_event );
147 #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
148 RestoreScreensaver( p_vout );
152 void CommonManage( vout_thread_t *p_vout )
154 /* If we do not control our window, we check for geometry changes
155 * ourselves because the parent might not send us its events. */
156 if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )
161 GetClientRect( p_vout->p_sys->hparent, &rect_parent );
162 point.x = point.y = 0;
163 ClientToScreen( p_vout->p_sys->hparent, &point );
164 OffsetRect( &rect_parent, point.x, point.y );
166 if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )
168 p_vout->p_sys->rect_parent = rect_parent;
170 /* FIXME I find such #ifdef quite weirds. Are they really needed ? */
172 #if defined(MODULE_NAME_IS_direct3d)
173 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
174 rect_parent.right - rect_parent.left,
175 rect_parent.bottom - rect_parent.top,
177 UpdateRects( p_vout, true );
179 /* This one is to force the update even if only
180 * the position has changed */
181 SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,
182 rect_parent.right - rect_parent.left,
183 rect_parent.bottom - rect_parent.top, 0 );
185 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
186 rect_parent.right - rect_parent.left,
187 rect_parent.bottom - rect_parent.top, 0 );
189 #if defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
190 unsigned int i_x, i_y, i_width, i_height;
191 vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left,
192 rect_parent.bottom - rect_parent.top,
193 &i_x, &i_y, &i_width, &i_height );
195 SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,
196 i_x, i_y, i_width, i_height, 0 );
203 p_vout->p_sys->i_changes |= EventThreadRetreiveChanges( p_vout->p_sys->p_event );
205 /* autoscale toggle */
206 if( p_vout->i_changes & VOUT_SCALE_CHANGE )
208 p_vout->i_changes &= ~VOUT_SCALE_CHANGE;
210 p_vout->b_autoscale = var_GetBool( p_vout, "autoscale" );
211 p_vout->i_zoom = (int) ZOOM_FP_FACTOR;
213 UpdateRects( p_vout, true );
217 if( p_vout->i_changes & VOUT_ZOOM_CHANGE )
219 p_vout->i_changes &= ~VOUT_ZOOM_CHANGE;
221 p_vout->b_autoscale = false;
223 (int)( ZOOM_FP_FACTOR * var_GetFloat( p_vout, "scale" ) );
224 UpdateRects( p_vout, true );
227 /* Check for cropping / aspect changes */
228 if( p_vout->i_changes & VOUT_CROP_CHANGE ||
229 p_vout->i_changes & VOUT_ASPECT_CHANGE )
231 p_vout->i_changes &= ~VOUT_CROP_CHANGE;
232 p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
234 p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
235 p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
236 p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
237 p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
238 p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
239 p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
240 p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
241 p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
242 UpdateRects( p_vout, true );
245 /* We used to call the Win32 PeekMessage function here to read the window
246 * messages. But since window can stay blocked into this function for a
247 * long time (for example when you move your window on the screen), I
248 * decided to isolate PeekMessage in another thread. */
253 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
254 || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
256 Win32ToggleFullscreen( p_vout );
258 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
259 p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
265 EventThreadMouseAutoHide( p_vout->p_sys->p_event );
268 * "Always on top" status change
270 if( p_vout->p_sys->b_on_top_change )
272 HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
273 bool b = var_GetBool( p_vout, "video-on-top" );
275 /* Set the window on top if necessary */
276 if( b && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
279 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
280 MF_BYCOMMAND | MFS_CHECKED );
281 SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,
282 SWP_NOSIZE | SWP_NOMOVE );
285 /* The window shouldn't be on top */
286 if( !b && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
289 CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
290 MF_BYCOMMAND | MFS_UNCHECKED );
291 SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
292 SWP_NOSIZE | SWP_NOMOVE );
295 p_vout->p_sys->b_on_top_change = false;
299 /*****************************************************************************
300 * UpdateRects: update clipping rectangles
301 *****************************************************************************
302 * This function is called when the window position or size are changed, and
303 * its job is to update the source and destination RECTs used to display the
305 *****************************************************************************/
306 void UpdateRects( vout_thread_t *p_vout, bool b_force )
308 #define rect_src p_vout->p_sys->rect_src
309 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
310 #define rect_dest p_vout->p_sys->rect_dest
311 #define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
313 unsigned int i_width, i_height, i_x, i_y;
318 /* Retrieve the window size */
319 GetClientRect( p_vout->p_sys->hwnd, &rect );
321 /* Retrieve the window position */
322 point.x = point.y = 0;
323 ClientToScreen( p_vout->p_sys->hwnd, &point );
325 /* If nothing changed, we can return */
327 EventThreadUpdateWindowPosition( p_vout->p_sys->p_event, &b_changed,
329 rect.right, rect.bottom );
330 if( !b_force && !b_changed )
333 /* Update the window position and size */
334 vout_PlacePicture( p_vout, rect.right, rect.bottom,
335 &i_x, &i_y, &i_width, &i_height );
337 if( p_vout->p_sys->hvideownd )
338 SetWindowPos( p_vout->p_sys->hvideownd, 0,
339 i_x, i_y, i_width, i_height,
340 SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS );
342 /* Destination image position and dimensions */
343 rect_dest.left = point.x + i_x;
344 rect_dest.right = rect_dest.left + i_width;
345 rect_dest.top = point.y + i_y;
346 rect_dest.bottom = rect_dest.top + i_height;
348 #ifdef MODULE_NAME_IS_directx
349 /* Apply overlay hardware constraints */
350 if( p_vout->p_sys->b_using_overlay )
352 if( p_vout->p_sys->i_align_dest_boundary )
353 rect_dest.left = ( rect_dest.left +
354 p_vout->p_sys->i_align_dest_boundary / 2 ) &
355 ~p_vout->p_sys->i_align_dest_boundary;
357 if( p_vout->p_sys->i_align_dest_size )
358 rect_dest.right = (( rect_dest.right - rect_dest.left +
359 p_vout->p_sys->i_align_dest_size / 2 ) &
360 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
363 /* UpdateOverlay directdraw function doesn't automatically clip to the
364 * display size so we need to do it otherwise it will fail */
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 );
381 #else /* MODULE_NAME_IS_directx */
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;
436 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
437 " coords: %li,%li,%li,%li",
438 rect_src_clipped.left, rect_src_clipped.top,
439 rect_src_clipped.right, rect_src_clipped.bottom );
442 #ifdef MODULE_NAME_IS_directx
443 /* The destination coordinates need to be relative to the current
444 * directdraw primary surface (display) */
445 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
446 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
447 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
448 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
450 if( p_vout->p_sys->b_using_overlay )
451 DirectDrawUpdateOverlay( p_vout );
455 /* Windows 7 taskbar thumbnail code */
456 LPTASKBARLIST3 p_taskbl;
457 OSVERSIONINFO winVer;
458 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
459 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
463 if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
464 NULL, CLSCTX_INPROC_SERVER,
468 RECT rect_video, rect_parent, rect_relative;
469 HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
471 p_taskbl->vt->HrInit(p_taskbl);
472 GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
473 GetWindowRect(hroot, &rect_parent);
474 rect_relative.left = rect_video.left - rect_parent.left - 8;
475 rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
476 rect_relative.top = rect_video.top - rect_parent.top - 10;
477 rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
479 if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
480 msg_Err( p_vout, "SetThumbNailClip failed");
482 p_taskbl->vt->Release(p_taskbl);
487 /* Signal the change in size/position */
488 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
491 #undef rect_src_clipped
493 #undef rect_dest_clipped
496 /*****************************************************************************
497 * Control: control facility for the vout
498 *****************************************************************************/
499 int Control( vout_thread_t *p_vout, int i_query, va_list args )
506 if( p_vout->p_sys->parent_window )
507 return vaControlParentWindow( p_vout, i_query, args );
509 /* Update dimensions */
510 rect_window.top = rect_window.left = 0;
511 rect_window.right = va_arg( args, unsigned int );
512 rect_window.bottom = va_arg( args, unsigned int );
513 if( !rect_window.right ) rect_window.right = p_vout->i_window_width;
514 if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height;
515 AdjustWindowRect( &rect_window, EventThreadGetWindowStyle( p_vout->p_sys->p_event ), 0 );
517 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
518 rect_window.right - rect_window.left,
519 rect_window.bottom - rect_window.top, SWP_NOMOVE );
523 case VOUT_SET_STAY_ON_TOP:
524 if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
525 return vaControlParentWindow( p_vout, i_query, args );
527 p_vout->p_sys->b_on_top_change = true;
536 /* Internal wrapper over GetWindowPlacement */
537 static WINDOWPLACEMENT getWindowState(HWND hwnd)
539 WINDOWPLACEMENT window_placement;
540 window_placement.length = sizeof(WINDOWPLACEMENT);
541 GetWindowPlacement( hwnd, &window_placement );
542 return window_placement;
545 /* Internal wrapper to call vout_ControlWindow for hparent */
546 static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
553 const unsigned i_width = va_arg(args, unsigned);
554 const unsigned i_height = va_arg(args, unsigned);
555 return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
557 case VOUT_SET_STAY_ON_TOP:
559 const bool is_on_top = va_arg(args, int);
560 return vout_window_SetOnTop( p_vout->p_sys->parent_window, is_on_top );
568 static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
573 va_start( args, i_query );
574 ret = vaControlParentWindow( p_vout, i_query, args );
580 void ExitFullscreen( vout_thread_t *p_vout )
582 if( p_vout->b_fullscreen )
584 msg_Dbg( p_vout, "Quitting fullscreen" );
585 Win32ToggleFullscreen( p_vout );
586 /* Force fullscreen in the core for the next video */
587 var_SetBool( p_vout, "fullscreen", true );
591 void Win32ToggleFullscreen( vout_thread_t *p_vout )
593 HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
594 p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
596 /* Save the current windows placement/placement to restore
597 when fullscreen is over */
598 WINDOWPLACEMENT window_placement = getWindowState( hwnd );
600 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
602 /* We want to go to Fullscreen */
603 if( p_vout->b_fullscreen )
605 msg_Dbg( p_vout, "entering fullscreen mode" );
607 /* Change window style, no borders and no title bar */
608 int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
609 SetWindowLong( hwnd, GWL_STYLE, i_style );
611 if( p_vout->p_sys->hparent )
616 ClientToScreen( p_vout->p_sys->hwnd, &point );
617 GetClientRect( p_vout->p_sys->hwnd, &rect );
618 SetWindowPos( hwnd, 0, point.x, point.y,
619 rect.right, rect.bottom,
620 SWP_NOZORDER|SWP_FRAMECHANGED );
622 /* Retrieve current window position so fullscreen will happen
623 *on the right screen */
624 HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
625 MONITOR_DEFAULTTONEAREST);
627 mi.cbSize = sizeof(MONITORINFO);
628 if (GetMonitorInfo(hmon, &mi))
629 SetWindowPos( hwnd, 0,
632 mi.rcMonitor.right - mi.rcMonitor.left,
633 mi.rcMonitor.bottom - mi.rcMonitor.top,
634 SWP_NOZORDER|SWP_FRAMECHANGED );
639 /* Maximize non embedded window */
640 ShowWindow( hwnd, SW_SHOWMAXIMIZED );
643 if( p_vout->p_sys->hparent )
645 /* Hide the previous window */
647 GetClientRect( hwnd, &rect );
648 SetParent( p_vout->p_sys->hwnd, hwnd );
649 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
650 rect.right, rect.bottom,
651 SWP_NOZORDER|SWP_FRAMECHANGED );
654 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
656 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
658 ShowWindow( topLevelParent, SW_HIDE );
661 SetForegroundWindow( hwnd );
665 msg_Dbg( p_vout, "leaving fullscreen mode" );
666 /* Change window style, no borders and no title bar */
667 SetWindowLong( hwnd, GWL_STYLE, EventThreadGetWindowStyle( p_vout->p_sys->p_event ) );
669 if( p_vout->p_sys->hparent )
672 GetClientRect( p_vout->p_sys->hparent, &rect );
673 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
674 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
675 rect.right, rect.bottom,
676 SWP_NOZORDER|SWP_FRAMECHANGED );
679 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
681 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
683 ShowWindow( topLevelParent, SW_SHOW );
684 SetForegroundWindow( p_vout->p_sys->hparent );
685 ShowWindow( hwnd, SW_HIDE );
689 /* return to normal window for non embedded vout */
690 SetWindowPlacement( hwnd, &window_placement );
691 ShowWindow( hwnd, SW_SHOWNORMAL );
694 /* Make sure the mouse cursor is displayed */
695 EventThreadMouseShow( p_vout->p_sys->p_event );
698 /* Update the object variable and trigger callback */
699 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
703 void DisableScreensaver( vout_thread_t *p_vout )
705 /* disable screensaver by temporarily changing system settings */
706 p_vout->p_sys->i_spi_lowpowertimeout = 0;
707 p_vout->p_sys->i_spi_powerofftimeout = 0;
708 p_vout->p_sys->i_spi_screensavetimeout = 0;
709 if( var_GetBool( p_vout, "disable-screensaver" ) )
711 msg_Dbg(p_vout, "disabling screen saver");
712 SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
713 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
714 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
715 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
717 SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
718 &(p_vout->p_sys->i_spi_powerofftimeout), 0);
719 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
720 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
722 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
723 &(p_vout->p_sys->i_spi_screensavetimeout), 0);
724 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
725 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
730 void RestoreScreensaver( vout_thread_t *p_vout )
732 /* restore screensaver system settings */
733 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
734 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
735 p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
737 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
738 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
739 p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
741 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
742 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
743 p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);