Skip to content

Commit deef0f2

Browse files
committed
Display Preferences: fix setting display resolution - update refresh rate list active item after resolution has been set.
1 parent 394c29f commit deef0f2

File tree

1 file changed

+23
-19
lines changed
  • Applications/Preferences/Modules/Display

1 file changed

+23
-19
lines changed

Applications/Preferences/Modules/Display/Display.m

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,18 @@ - (NSImage *)buttonImage
143143
//
144144
- (void)fillRateButton
145145
{
146-
NSString *resBtnTitle = [resolutionBtn titleOfSelectedItem];
147-
NSArray *m = [selectedDisplay allResolutions];
146+
NSString *resBtnTitle;
148147
NSString *rateTitle;
149148
NSString *resolutionTitle;
150149
NSDictionary *res;
151150
float rateValue = 0.0;
152151
NSString *rateFormat = @"%.2f Hz";
153152

154-
// [m writeToFile:[NSString stringWithFormat:@"%@.displayResolutions", [selectedDisplay outputName]]
155-
// atomically:NO];
156153
[rateBtn removeAllItems];
157154

158155
// Fill the buttion with items
159-
for (res in m) {
156+
resBtnTitle = [resolutionBtn titleOfSelectedItem];
157+
for (res in [selectedDisplay allResolutions]) {
160158
resolutionTitle = [res objectForKey:OSEDisplayResolutionNameKey];
161159
if ([resolutionTitle isEqualToString:resBtnTitle]) {
162160
rateValue = [[res objectForKey:OSEDisplayResolutionRateKey] floatValue];
@@ -165,24 +163,37 @@ - (void)fillRateButton
165163
[[rateBtn itemWithTitle:rateTitle] setRepresentedObject:res];
166164
}
167165
}
166+
}
167+
168+
- (void)updateRateButton
169+
{
170+
NSString *rateFormat = @"%.2f Hz";
171+
NSString *rateTitle;
168172

169173
if ([[rateBtn itemArray] count] == 1) {
170174
[rateBtn setEnabled:NO];
171175
} else {
172176
// Select actual value of selected resolution
173-
res = [selectedDisplay activeResolution];
174-
rateValue = [[res objectForKey:OSEDisplayResolutionRateKey] floatValue];
175-
rateTitle = [NSString stringWithFormat:rateFormat, rateValue];
177+
NSLog(@"%s - resoltion rate %f", __func__, selectedDisplay.activeRate);
178+
rateTitle = [NSString stringWithFormat:rateFormat, selectedDisplay.activeRate];
179+
NSLog(@"%s - rate title %@", __func__, rateTitle);
176180
[rateBtn selectItemWithTitle:rateTitle];
177181
[rateBtn setEnabled:YES];
178-
}
182+
}
179183
}
180184

181185
- (void)setResolution
182186
{
187+
NSDictionary *resolution = [[rateBtn selectedCell] representedObject];
188+
if (resolution == nil) {
189+
NSLog(@"%s - resolution dictionary is nil! Resolution button is %@", __func__,
190+
[resolutionBtn title]);
191+
return;
192+
}
183193
// Set resolution only to active display.
184194
// Display activating implemented in 'Screen' Preferences' module.
185195
if ([selectedDisplay isActive]) {
196+
NSLog(@"%s - %@", __func__, [[rateBtn selectedCell] representedObject]);
186197
[systemScreen setDisplay:selectedDisplay resolution:[[rateBtn selectedCell] representedObject]];
187198
}
188199
}
@@ -257,12 +268,11 @@ - (IBAction)monitorsListClicked:(id)sender
257268

258269
- (IBAction)resolutionClicked:(id)sender
259270
{
260-
[self fillRateButton];
261-
// NSLog(@"resolutionClicked: Selected resolution: %@", [[rateBtn selectedCell] representedObject]);
262-
263271
[[NSNotificationCenter defaultCenter] removeObserver:self];
264272

273+
[self fillRateButton];
265274
[self setResolution];
275+
[self updateRateButton];
266276

267277
[[NSNotificationCenter defaultCenter] addObserver:self
268278
selector:@selector(screenDidUpdate:)
@@ -273,8 +283,6 @@ - (IBAction)resolutionClicked:(id)sender
273283
- (IBAction)rateClicked:(id)sender
274284
{
275285
[self setResolution];
276-
277-
NSLog(@"rateClicked: Selected resolution: %@", [[rateBtn selectedCell] representedObject]);
278286
}
279287

280288
- (IBAction)sliderMoved:(id)sender
@@ -393,13 +401,9 @@ - (void)controlTextDidEndEditing:(NSNotification *)aNotification
393401
// Notifications
394402
- (void)screenDidUpdate:(NSNotification *)aNotif
395403
{
396-
NSLog(@"Display: XRandR screen resources was updated, refreshing...");
404+
NSLog(@"%s: XRandR screen resources was updated, refreshing...", __func__);
397405
[monitorsList reloadColumn:0];
398406
[self selectFirstEnabledMonitor];
399407
}
400408

401-
//
402-
// Utility methods
403-
//
404-
405409
@end

0 commit comments

Comments
 (0)