Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fullscreen fix #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions push.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,24 @@ end

function push:switchFullscreen(winw, winh)
self._fullscreen = not self._fullscreen
local windowWidth, windowHeight = love.window.getDesktopDimensions()
local _, _, flags = love.window.getMode()
local desktopWidth, desktopHeight = love.window.getDesktopDimensions(flags.display)

if self._fullscreen then --save windowed dimensions for later
self._WINWIDTH, self._WINHEIGHT = self._RWIDTH, self._RHEIGHT
elseif not self._WINWIDTH or not self._WINHEIGHT then
self._WINWIDTH, self._WINHEIGHT = windowWidth * .5, windowHeight * .5
self._WINWIDTH, self._WINHEIGHT = desktopWidth * .5, desktopHeight * .5
end

self._RWIDTH = self._fullscreen and windowWidth or winw or self._WINWIDTH
self._RHEIGHT = self._fullscreen and windowHeight or winh or self._WINHEIGHT
self._RWIDTH = self._fullscreen and desktopWidth or winw or self._WINWIDTH
self._RHEIGHT = self._fullscreen and desktopHeight or winh or self._WINHEIGHT

self:initValues()

love.window.setFullscreen(self._fullscreen, "desktop")
if not self._fullscreen and (winw or winh) then

local windowWidth, windowHeight = love.window.getMode()
if not self._fullscreen and (windowWidth~=self._RWIDTH or windowHeight~=self._RHEIGHT) then
windowUpdateMode(self._RWIDTH, self._RHEIGHT) --set window dimensions
end
end
Expand Down