Fullscreen mode

1,202 views
Skip to first unread message

bdh...@gmail.com

unread,
Nov 5, 2012, 10:58:54 AM11/5/12
to cefp...@googlegroups.com
Hello all,

Is there a way to make a CEFPython app run full-screen (without titlebar or anything) in Windows? I did some poking around and saw some discussion about adding it to CEF, but didn't see anything conclusive about wether or not it is actually there. I did see the enable_fullscreen flag for BrowserSettings, but couldn't determine what, if any, effect it had.
-Benjamin

Czarek Tomczak

unread,
Nov 5, 2012, 11:44:22 AM11/5/12
to cefp...@googlegroups.com
Hello Benjamin,

First you need to create a fullscreen window, see this question on stackoverflow:
The easiest way is to just call SetWindowPos() after creating window, use the pywin32 extension to call win32 api functions.

Next pass that window handle to cefpython.CreateBrowser(), set the fullscreen_enabled to true in BrowserSettings.

Czarek.

bdh...@gmail.com

unread,
Nov 5, 2012, 12:45:51 PM11/5/12
to cefp...@googlegroups.com
Thanks for the response.

I was about to report that I had achieved my desired result using PyGTK, using the example in your package, adding

self.mainWindow.fullscreen()

and that worked pretty well, too.

Thanks for your contributions; I'll be keeping an eye on your CEF3 port as well.

ric...@gmail.com

unread,
Nov 16, 2012, 5:08:22 PM11/16/12
to cefp...@googlegroups.com
Can you explain further how to get Full screen.
My situation is a bit different. I'll be running 3 apps, each on a different screen, and each needs to be full screen. By default, full screen goes to the 'Main' monitor, while I need to move the app prior to making it full screen so it occupies the correct screen.

ric...@gmail.com

unread,
Nov 16, 2012, 6:51:03 PM11/16/12
to cefp...@googlegroups.com
I figured it out, and am posting how for others.
Post these 2 lines where you want. I got them assigned to a hotkey.
win32gui.SetWindowLong(windowID, win32con.GWL_STYLE, win32con.WS_POPUP)
win32gui.ShowWindow(windowID, win32con.SW_MAXIMIZE)

ric...@gmail.com

unread,
Nov 16, 2012, 7:20:44 PM11/16/12
to cefp...@googlegroups.com
If you want to return back to normal after going full-screen, you'll need these 2 lines:
win32gui.SetWindowLong(windowID, win32con.GWL_STYLE, win32con.WS_TILEDWINDOW)
win32gui.ShowWindow(windowID, win32con.SW_SHOWNORMAL)

Note that position and size is not restored, so you'll have to record that info and restore it.
You can use cefwindow.MoveWindow() or a win32 line like this:
win32gui.SetWindowPos(windowID, win32con.HWND_TOPMOST, 0, 0, 800, 600, 0)

Czarek Tomczak

unread,
Nov 16, 2012, 11:53:52 PM11/16/12
to cefp...@googlegroups.com
I've added an example of going fullscreen to cefadvanced.py, this code emulates chromium's behavior, though I'm not sure about the "for_metro" variable, it probably should tell whether this is metro snap mode in Windows 8, it is hardcoded to False as of the moment.

# Bind F11 to go fullscreen.
if keyCode == cefpython.VK_F11 and cefpython.IsKeyModifier(cefpython.KEY_NONE, modifiers):
if platform.system() == "Windows":
for_metro = False
hwnd = browser.GetWindowID()
# Logic copied from chromium > fullscreen_handler.cc > FullscreenHandler::SetFullscreenImpl:
if not browser.GetUserData("is_fullscreen"):
browser.SetUserData("SavedWindowInfo_maximized", ctypes.windll.user32.IsZoomed(hwnd))
if browser.GetUserData("SavedWindowInfo_maximized"):
win32api.SendMessage(hwnd, win32con.WM_SYSCOMMAND, win32con.SC_RESTORE, 0)
browser.SetUserData("SavedWindowInfo_gwl_style", win32api.GetWindowLong(hwnd, win32con.GWL_STYLE))
browser.SetUserData("SavedWindowInfo_gwl_exstyle", win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE))
browser.SetUserData("SavedWindowInfo_window_rect", win32gui.GetWindowRect(hwnd)) 

if not browser.GetUserData("is_fullscreen"):
gwl_style = browser.GetUserData("SavedWindowInfo_gwl_style")
gwl_exstyle = browser.GetUserData("SavedWindowInfo_gwl_exstyle")
remove_style = win32con.WS_CAPTION | win32con.WS_THICKFRAME
remove_exstyle = win32con.WS_EX_DLGMODALFRAME | win32con.WS_EX_WINDOWEDGE
remove_exstyle += win32con.WS_EX_CLIENTEDGE | win32con.WS_EX_STATICEDGE
win32api.SetWindowLong(hwnd, win32con.GWL_STYLE, gwl_style & ~(remove_style))
win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, gwl_exstyle & ~(remove_exstyle))
if not for_metro:
# MONITOR_DEFAULTTONULL, MONITOR_DEFAULTTOPRIMARY, MONITOR_DEFAULTTONEAREST
monitor = win32api.MonitorFromWindow(hwnd, win32con.MONITOR_DEFAULTTONEAREST)
monitorInfo = win32api.GetMonitorInfo(monitor) # keys: Device, Work, Monitor
(left, top, right, bottom) = monitorInfo["Monitor"]
win32gui.SetWindowPos(hwnd, None, left, top, right-left, bottom-top,
win32con.SWP_NOZORDER | win32con.SWP_NOACTIVATE | win32con.SWP_FRAMECHANGED)
else:
gwl_style = browser.GetUserData("SavedWindowInfo_gwl_style")
gwl_exstyle = browser.GetUserData("SavedWindowInfo_gwl_exstyle")
win32api.SetWindowLong(hwnd, win32con.GWL_STYLE, gwl_style)
win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, gwl_exstyle)
if not for_metro:
(left, top, right, bottom) = browser.GetUserData("SavedWindowInfo_window_rect")
win32gui.SetWindowPos(hwnd, None, left, top, right-left, bottom-top,
win32con.SWP_NOZORDER | win32con.SWP_NOACTIVATE | win32con.SWP_FRAMECHANGED)
if browser.GetUserData("SavedWindowInfo_maximized"):
win32api.SendMessage(hwnd, win32con.WM_SYSCOMMAND, win32con.SC_MAXIMIZE, 0)

browser.SetUserData("is_fullscreen", not bool(browser.GetUserData("is_fullscreen")))
return True

Czarek.

Czarek Tomczak

unread,
Nov 18, 2012, 2:56:43 PM11/18/12
to cefp...@googlegroups.com
Switching to fullscreen will be built-in in next 0.42 release, there will be new methods in Browser object: IsFullscreen(), ToggleFullscreen().

or...@icx-il.com

unread,
May 28, 2018, 6:53:21 AM5/28/18
to CEF Python
Hi,
Is there a similar way we can achieve full-screen in Linux too?

Czarek Tomczak

unread,
May 28, 2018, 7:06:31 AM5/28/18
to CEF Python
It depends on the GUI framework you use. If using wxPython call window.ShowFullScreen() on a top-level window. If using PyGTK call window.fullscreen().

or...@icx-il.com

unread,
May 28, 2018, 8:04:56 AM5/28/18
to CEF Python
What about without any framework, like in the cefpython tutorial? (https://github.com/cztomczak/cefpython/blob/master/examples/tutorial.py)
We only want to show web content, no other GUI components involved.

Czarek Tomczak

unread,
May 28, 2018, 9:11:42 AM5/28/18
to CEF Python
Please ask your questions in a separate topic.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages