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

Fixed issue where 2010 MBPs switch to Discrete Only after apps quit #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion Classes/GSGPU.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ static void _displayReconfigurationCallback(CGDirectDisplayID display, CGDisplay
BOOL isUsingIntegrated = [GSMux isUsingIntegratedGPU];

GTMLoggerInfo(@"Notification: GPU changed. Integrated? %d", isUsingIntegrated);


// For Macbook Pro 2010 users who have set the mode to Integrated Only,
// there will be rogue apps like Chrome that switch the graphics to
// Discrete Only upon closing. This will reverse the switch
if (!isUsingIntegrated && ([GSMux currentGSSwitcherMode]==GSSwitcherModeForceIntegrated)) {
[GSMux setMode:GSSwitcherModeForceIntegrated];
}

GSGPUType activeType = (isUsingIntegrated ? GSGPUTypeIntegrated : GSGPUTypeDiscrete);
[_delegate GPUDidChangeTo:activeType];
});
Expand Down
3 changes: 3 additions & 0 deletions Classes/GSMux.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ typedef enum {
+ (BOOL)isOnIntegratedOnlyMode;
+ (BOOL)isOnDiscreteOnlyMode;

// Returns the value of the current GSSwitcherMode as set in the Menu
+ (GSSwitcherMode) currentGSSwitcherMode;

@end
13 changes: 12 additions & 1 deletion Classes/GSMux.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ static void dumpState(io_connect_t connect)

@implementation GSMux

static GSSwitcherMode currentGSSwitcherMode;

+(GSSwitcherMode)currentGSSwitcherMode
{
return currentGSSwitcherMode;
}

#pragma mark - GSMux API
#pragma mark Initialization/destruction

Expand Down Expand Up @@ -303,10 +310,14 @@ + (BOOL)setMode:(GSSwitcherMode)mode
{
if (_switcherConnect == IO_OBJECT_NULL)
return NO;


// Set current GSSwitcher mode
currentGSSwitcherMode = mode;

switch (mode) {
case GSSwitcherModeForceIntegrated:
case GSSwitcherModeForceDiscrete:

// Disable dynamic switching
setDynamicSwitchingEnabled(_switcherConnect, NO);

Expand Down