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 #if defined(MODULE_NAME_IS_direct3d)
345 rect_dest.right = i_width;
347 rect_dest.bottom = i_height;
349 rect_dest.left = point.x + i_x;
350 rect_dest.right = rect_dest.left + i_width;
351 rect_dest.top = point.y + i_y;
352 rect_dest.bottom = rect_dest.top + i_height;
354 #ifdef MODULE_NAME_IS_directx
355 /* Apply overlay hardware constraints */
356 if( p_vout->p_sys->b_using_overlay )
358 if( p_vout->p_sys->i_align_dest_boundary )
359 rect_dest.left = ( rect_dest.left +
360 p_vout->p_sys->i_align_dest_boundary / 2 ) &
361 ~p_vout->p_sys->i_align_dest_boundary;
363 if( p_vout->p_sys->i_align_dest_size )
364 rect_dest.right = (( rect_dest.right - rect_dest.left +
365 p_vout->p_sys->i_align_dest_size / 2 ) &
366 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
372 #if defined(MODULE_NAME_IS_directx) || defined(MODULE_NAME_IS_direct3d)
373 /* UpdateOverlay directdraw function doesn't automatically clip to the
374 * display size so we need to do it otherwise it will fail
375 * It is also needed for d3d to avoid exceding our surface size */
377 /* Clip the destination window */
378 if( !IntersectRect( &rect_dest_clipped, &rect_dest,
379 &p_vout->p_sys->rect_display ) )
381 SetRectEmpty( &rect_src_clipped );
386 msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
388 rect_dest_clipped.left, rect_dest_clipped.top,
389 rect_dest_clipped.right, rect_dest_clipped.bottom );
394 /* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
395 rect_dest_clipped = rect_dest;
399 /* the 2 following lines are to fix a bug when clicking on the desktop */
400 if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
401 (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
403 SetRectEmpty( &rect_src_clipped );
407 /* src image dimensions */
410 rect_src.right = p_vout->render.i_width;
411 rect_src.bottom = p_vout->render.i_height;
413 /* Clip the source image */
414 rect_src_clipped.left = p_vout->fmt_out.i_x_offset +
415 (rect_dest_clipped.left - rect_dest.left) *
416 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
417 rect_src_clipped.right = p_vout->fmt_out.i_x_offset +
418 p_vout->fmt_out.i_visible_width -
419 (rect_dest.right - rect_dest_clipped.right) *
420 p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
421 rect_src_clipped.top = p_vout->fmt_out.i_y_offset +
422 (rect_dest_clipped.top - rect_dest.top) *
423 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
424 rect_src_clipped.bottom = p_vout->fmt_out.i_y_offset +
425 p_vout->fmt_out.i_visible_height -
426 (rect_dest.bottom - rect_dest_clipped.bottom) *
427 p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
429 #ifdef MODULE_NAME_IS_directx
430 /* Apply overlay hardware constraints */
431 if( p_vout->p_sys->b_using_overlay )
433 if( p_vout->p_sys->i_align_src_boundary )
434 rect_src_clipped.left = ( rect_src_clipped.left +
435 p_vout->p_sys->i_align_src_boundary / 2 ) &
436 ~p_vout->p_sys->i_align_src_boundary;
438 if( p_vout->p_sys->i_align_src_size )
439 rect_src_clipped.right = (( rect_src_clipped.right -
440 rect_src_clipped.left +
441 p_vout->p_sys->i_align_src_size / 2 ) &
442 ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
444 #elif defined(MODULE_NAME_IS_direct3d)
445 /* Needed at least with YUV content */
446 rect_src_clipped.left &= ~1;
447 rect_src_clipped.right &= ~1;
448 rect_src_clipped.top &= ~1;
449 rect_src_clipped.bottom &= ~1;
453 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
454 " coords: %li,%li,%li,%li",
455 rect_src_clipped.left, rect_src_clipped.top,
456 rect_src_clipped.right, rect_src_clipped.bottom );
459 #ifdef MODULE_NAME_IS_directx
460 /* The destination coordinates need to be relative to the current
461 * directdraw primary surface (display) */
462 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
463 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
464 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
465 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
467 if( p_vout->p_sys->b_using_overlay )
468 DirectDrawUpdateOverlay( p_vout );
472 /* Windows 7 taskbar thumbnail code */
473 LPTASKBARLIST3 p_taskbl;
474 OSVERSIONINFO winVer;
475 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
476 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
480 if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
481 NULL, CLSCTX_INPROC_SERVER,
485 RECT rect_video, rect_parent, rect_relative;
486 HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
488 p_taskbl->vt->HrInit(p_taskbl);
489 GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
490 GetWindowRect(hroot, &rect_parent);
491 rect_relative.left = rect_video.left - rect_parent.left - 8;
492 rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
493 rect_relative.top = rect_video.top - rect_parent.top - 10;
494 rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
496 if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
497 msg_Err( p_vout, "SetThumbNailClip failed");
499 p_taskbl->vt->Release(p_taskbl);
504 /* Signal the change in size/position */
505 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
508 #undef rect_src_clipped
510 #undef rect_dest_clipped
513 /*****************************************************************************
514 * Control: control facility for the vout
515 *****************************************************************************/
516 int Control( vout_thread_t *p_vout, int i_query, va_list args )
523 if( p_vout->p_sys->parent_window )
524 return vaControlParentWindow( p_vout, i_query, args );
526 /* Update dimensions */
527 rect_window.top = rect_window.left = 0;
528 rect_window.right = va_arg( args, unsigned int );
529 rect_window.bottom = va_arg( args, unsigned int );
530 if( !rect_window.right ) rect_window.right = p_vout->i_window_width;
531 if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height;
532 AdjustWindowRect( &rect_window, EventThreadGetWindowStyle( p_vout->p_sys->p_event ), 0 );
534 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
535 rect_window.right - rect_window.left,
536 rect_window.bottom - rect_window.top, SWP_NOMOVE );
540 case VOUT_SET_STAY_ON_TOP:
541 if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
542 return vaControlParentWindow( p_vout, i_query, args );
544 p_vout->p_sys->b_on_top_change = true;
553 /* Internal wrapper over GetWindowPlacement */
554 static WINDOWPLACEMENT getWindowState(HWND hwnd)
556 WINDOWPLACEMENT window_placement;
557 window_placement.length = sizeof(WINDOWPLACEMENT);
558 GetWindowPlacement( hwnd, &window_placement );
559 return window_placement;
562 /* Internal wrapper to call vout_ControlWindow for hparent */
563 static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
570 const unsigned i_width = va_arg(args, unsigned);
571 const unsigned i_height = va_arg(args, unsigned);
572 return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
574 case VOUT_SET_STAY_ON_TOP:
576 const bool is_on_top = va_arg(args, int);
577 return vout_window_SetOnTop( p_vout->p_sys->parent_window, is_on_top );
585 static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
590 va_start( args, i_query );
591 ret = vaControlParentWindow( p_vout, i_query, args );
597 void ExitFullscreen( vout_thread_t *p_vout )
599 if( p_vout->b_fullscreen )
601 msg_Dbg( p_vout, "Quitting fullscreen" );
602 Win32ToggleFullscreen( p_vout );
603 /* Force fullscreen in the core for the next video */
604 var_SetBool( p_vout, "fullscreen", true );
608 void Win32ToggleFullscreen( vout_thread_t *p_vout )
610 HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
611 p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
613 /* Save the current windows placement/placement to restore
614 when fullscreen is over */
615 WINDOWPLACEMENT window_placement = getWindowState( hwnd );
617 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
619 /* We want to go to Fullscreen */
620 if( p_vout->b_fullscreen )
622 msg_Dbg( p_vout, "entering fullscreen mode" );
624 /* Change window style, no borders and no title bar */
625 int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
626 SetWindowLong( hwnd, GWL_STYLE, i_style );
628 if( p_vout->p_sys->hparent )
633 ClientToScreen( p_vout->p_sys->hwnd, &point );
634 GetClientRect( p_vout->p_sys->hwnd, &rect );
635 SetWindowPos( hwnd, 0, point.x, point.y,
636 rect.right, rect.bottom,
637 SWP_NOZORDER|SWP_FRAMECHANGED );
639 /* Retrieve current window position so fullscreen will happen
640 *on the right screen */
641 HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
642 MONITOR_DEFAULTTONEAREST);
644 mi.cbSize = sizeof(MONITORINFO);
645 if (GetMonitorInfo(hmon, &mi))
646 SetWindowPos( hwnd, 0,
649 mi.rcMonitor.right - mi.rcMonitor.left,
650 mi.rcMonitor.bottom - mi.rcMonitor.top,
651 SWP_NOZORDER|SWP_FRAMECHANGED );
656 /* Maximize non embedded window */
657 ShowWindow( hwnd, SW_SHOWMAXIMIZED );
660 if( p_vout->p_sys->hparent )
662 /* Hide the previous window */
664 GetClientRect( hwnd, &rect );
665 SetParent( p_vout->p_sys->hwnd, hwnd );
666 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
667 rect.right, rect.bottom,
668 SWP_NOZORDER|SWP_FRAMECHANGED );
671 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
673 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
675 ShowWindow( topLevelParent, SW_HIDE );
678 SetForegroundWindow( hwnd );
682 msg_Dbg( p_vout, "leaving fullscreen mode" );
683 /* Change window style, no borders and no title bar */
684 SetWindowLong( hwnd, GWL_STYLE, EventThreadGetWindowStyle( p_vout->p_sys->p_event ) );
686 if( p_vout->p_sys->hparent )
689 GetClientRect( p_vout->p_sys->hparent, &rect );
690 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
691 SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
692 rect.right, rect.bottom,
693 SWP_NOZORDER|SWP_FRAMECHANGED );
696 HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
698 HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
700 ShowWindow( topLevelParent, SW_SHOW );
701 SetForegroundWindow( p_vout->p_sys->hparent );
702 ShowWindow( hwnd, SW_HIDE );
706 /* return to normal window for non embedded vout */
707 SetWindowPlacement( hwnd, &window_placement );
708 ShowWindow( hwnd, SW_SHOWNORMAL );
711 /* Make sure the mouse cursor is displayed */
712 EventThreadMouseShow( p_vout->p_sys->p_event );
715 /* Update the object variable and trigger callback */
716 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
720 void DisableScreensaver( vout_thread_t *p_vout )
722 /* disable screensaver by temporarily changing system settings */
723 p_vout->p_sys->i_spi_lowpowertimeout = 0;
724 p_vout->p_sys->i_spi_powerofftimeout = 0;
725 p_vout->p_sys->i_spi_screensavetimeout = 0;
726 if( var_GetBool( p_vout, "disable-screensaver" ) )
728 msg_Dbg(p_vout, "disabling screen saver");
729 SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
730 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
731 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
732 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
734 SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
735 &(p_vout->p_sys->i_spi_powerofftimeout), 0);
736 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
737 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
739 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
740 &(p_vout->p_sys->i_spi_screensavetimeout), 0);
741 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
742 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
747 void RestoreScreensaver( vout_thread_t *p_vout )
749 /* restore screensaver system settings */
750 if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
751 SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
752 p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
754 if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
755 SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
756 p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
758 if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
759 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
760 p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);