Skip to content

Commit

Permalink
Fix window focus events (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Oct 24, 2015
1 parent 6c4eb03 commit 4581f34
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions src/cdogs/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,35 @@ void EventPoll(EventHandlers *handlers, Uint32 ticks)
case SDL_MOUSEWHEEL:
MouseOnWheel(&handlers->mouse, e.wheel.x, e.wheel.y);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
MusicSetPlaying(&gSoundDevice, true);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (!gCampaign.IsClient && !ConfigGetBool(&gConfig, "StartServer"))
{
MusicSetPlaying(&gSoundDevice, false);
}
break;
case SDL_WINDOWEVENT_SIZE_CHANGED:
handlers->HasResolutionChanged = true;
if (gGraphicsDevice.cachedConfig.IsEditor)
case SDL_WINDOWEVENT:
switch (e.window.event)
{
const int scale = ConfigGetInt(&gConfig, "Graphics.ScaleFactor");
GraphicsConfigSet(
&gGraphicsDevice.cachedConfig,
Vec2iNew(e.window.data1 / scale, e.window.data2 / scale),
false,
scale,
gGraphicsDevice.cachedConfig.ScaleMode);
GraphicsInitialize(&gGraphicsDevice, false);
case SDL_WINDOWEVENT_FOCUS_GAINED:
MusicSetPlaying(&gSoundDevice, true);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (!gCampaign.IsClient && !ConfigGetBool(&gConfig, "StartServer"))
{
MusicSetPlaying(&gSoundDevice, false);
}
break;
case SDL_WINDOWEVENT_SIZE_CHANGED:
handlers->HasResolutionChanged = true;
if (gGraphicsDevice.cachedConfig.IsEditor)
{
const int scale = ConfigGetInt(&gConfig, "Graphics.ScaleFactor");
GraphicsConfigSet(
&gGraphicsDevice.cachedConfig,
Vec2iNew(e.window.data1 / scale, e.window.data2 / scale),
false,
scale,
gGraphicsDevice.cachedConfig.ScaleMode);
GraphicsInitialize(&gGraphicsDevice, false);
}
break;
default:
// do nothing
break;
}
break;
case SDL_QUIT:
Expand Down

0 comments on commit 4581f34

Please sign in to comment.