@@ -398,77 +398,82 @@ cdef class PyBrowser:
398398 IF UNAME_SYSNAME == " Windows" :
399399 self .ToggleFullscreen_Windows()
400400
401- cpdef py_void ToggleFullscreen_Windows(self ):
402- cdef int windowHandle
403- if self .GetUserData(" __outerWindowHandle" ):
404- windowHandle = self .GetUserData(" __outerWindowHandle" )
405- else :
406- windowHandle = self .GetWindowHandle()
407-
408- # Offscreen browser will have an empty window handle.
409- assert windowHandle, (
410- " Browser.ToggleFullscreen() failed: no window handle found" )
411-
412- cdef HWND hwnd = < HWND>< int > int (windowHandle)
413- cdef RECT rect
414- cdef HMONITOR monitor
415- cdef MONITORINFO monitorInfo
416- monitorInfo.cbSize = sizeof(monitorInfo)
417-
418- # Logic copied from chromium > fullscreen_handler.cc >
419- # FullscreenHandler::SetFullscreenImpl:
420- # http://src.chromium.org/viewvc/chrome/trunk/src/ui/views/win/
421- # fullscreen_handler.cc
422-
423- cdef py_bool for_metro = False
424-
425- if not self .isFullscreen:
426- self .maximized = IsZoomed(hwnd)
427- if self .maximized:
428- SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 )
429- self .gwlStyle = GetWindowLong(hwnd, GWL_STYLE)
430- self .gwlExStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
431- GetWindowRect(hwnd, & rect)
432- self .windowRect = (rect.left, rect.top, rect.right, rect.bottom)
433-
434- cdef int removeStyle, removeExStyle
435- cdef int left, top, right, bottom
436-
437- if not self .isFullscreen:
438- removeStyle = WS_CAPTION | WS_THICKFRAME
439- removeExStyle = (WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
440- | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)
441- SetWindowLong(hwnd, GWL_STYLE,
442- self .gwlStyle & ~ (removeStyle))
443- SetWindowLong(hwnd, GWL_EXSTYLE,
444- self .gwlExStyle & ~ (removeExStyle))
445-
446- if not for_metro:
447- # MONITOR_DEFAULTTONULL, MONITOR_DEFAULTTOPRIMARY,
448- # MONITOR_DEFAULTTONEAREST
449- monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)
450- GetMonitorInfo(monitor, & monitorInfo)
451- left = monitorInfo.rcMonitor.left
452- top = monitorInfo.rcMonitor.top
453- right = monitorInfo.rcMonitor.right
454- bottom = monitorInfo.rcMonitor.bottom
455- SetWindowPos(hwnd, NULL , left, top, right- left, bottom- top,
456- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED)
457- else :
458- SetWindowLong(hwnd, GWL_STYLE, int (self .gwlStyle))
459- SetWindowLong(hwnd, GWL_EXSTYLE, int (self .gwlExStyle))
401+ IF UNAME_SYSNAME == " Windows" :
402+
403+ cpdef py_void ToggleFullscreen_Windows(self ):
404+ cdef int windowHandle
405+ if self .GetUserData(" __outerWindowHandle" ):
406+ windowHandle = self .GetUserData(" __outerWindowHandle" )
407+ else :
408+ windowHandle = self .GetWindowHandle()
409+
410+ # Offscreen browser will have an empty window handle.
411+ assert windowHandle, (
412+ " Browser.ToggleFullscreen() failed: no window handle "
413+ " found" )
414+
415+ cdef HWND hwnd = < HWND>< int > int (windowHandle)
416+ cdef RECT rect
417+ cdef HMONITOR monitor
418+ cdef MONITORINFO monitorInfo
419+ monitorInfo.cbSize = sizeof(monitorInfo)
420+
421+ # Logic copied from chromium > fullscreen_handler.cc >
422+ # FullscreenHandler::SetFullscreenImpl:
423+ # http://src.chromium.org/viewvc/chrome/trunk/src/ui/views/win/
424+ # fullscreen_handler.cc
425+
426+ cdef py_bool for_metro = False
427+
428+ if not self .isFullscreen:
429+ self .maximized = IsZoomed(hwnd)
430+ if self .maximized:
431+ SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 )
432+ self .gwlStyle = GetWindowLong(hwnd, GWL_STYLE)
433+ self .gwlExStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
434+ GetWindowRect(hwnd, & rect)
435+ self .windowRect = (rect.left, rect.top,
436+ rect.right, rect.bottom)
437+
438+ cdef int removeStyle, removeExStyle
439+ cdef int left, top, right, bottom
440+
441+ if not self .isFullscreen:
442+ removeStyle = WS_CAPTION | WS_THICKFRAME
443+ removeExStyle = (WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
444+ | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)
445+ SetWindowLong(hwnd, GWL_STYLE,
446+ self .gwlStyle & ~ (removeStyle))
447+ SetWindowLong(hwnd, GWL_EXSTYLE,
448+ self .gwlExStyle & ~ (removeExStyle))
449+
450+ if not for_metro:
451+ # MONITOR_DEFAULTTONULL, MONITOR_DEFAULTTOPRIMARY,
452+ # MONITOR_DEFAULTTONEAREST
453+ monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)
454+ GetMonitorInfo(monitor, & monitorInfo)
455+ left = monitorInfo.rcMonitor.left
456+ top = monitorInfo.rcMonitor.top
457+ right = monitorInfo.rcMonitor.right
458+ bottom = monitorInfo.rcMonitor.bottom
459+ SetWindowPos(hwnd, NULL ,
460+ left, top, right- left, bottom- top,
461+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED)
462+ else :
463+ SetWindowLong(hwnd, GWL_STYLE, int (self .gwlStyle))
464+ SetWindowLong(hwnd, GWL_EXSTYLE, int (self .gwlExStyle))
460465
461- if not for_metro:
462- (left, top, right, bottom) = self .windowRect
463- SetWindowPos(hwnd, NULL ,
464- int (left), int (top),
465- int (right- left), int (bottom- top),
466- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED)
466+ if not for_metro:
467+ (left, top, right, bottom) = self .windowRect
468+ SetWindowPos(hwnd, NULL ,
469+ int (left), int (top),
470+ int (right- left), int (bottom- top),
471+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED)
467472
468- if self .maximized:
469- SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 )
473+ if self .maximized:
474+ SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 )
470475
471- self .isFullscreen = int (not bool (self .isFullscreen))
476+ self .isFullscreen = int (not bool (self .isFullscreen))
472477
473478 # Off-screen rendering.
474479
0 commit comments