Skip to content
Snippets Groups Projects
Commit 72404b8b authored by George Nachman's avatar George Nachman
Browse files

slow down jobs timer when not key window. optimize jobs timer if no changes....

slow down jobs timer when not key window. optimize jobs timer if no changes. fix cursor after reloading a table view in toolbelt.
parent a9063505
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -106,17 +106,49 @@ static const int kMaxJobs = 20;
[tableView_ sizeToFit];
[tableView_ setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
timer_ = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateTimer:)
userInfo:nil
repeats:YES];
repeats:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setSlowTimer)
name:NSWindowDidResignMainNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setFastTimer)
name:NSWindowDidBecomeKeyNotification
object:nil];
[self updateTimer:nil];
}
return self;
}
 
// When not key, check much less often to avoid burning the battery.
- (void)setSlowTimer
{
[timer_ invalidate];
timer_ = [NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(updateTimer:)
userInfo:nil
repeats:YES];
}
- (void)setFastTimer
{
[self updateTimer:nil];
[timer_ invalidate];
timer_ = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateTimer:)
userInfo:nil
repeats:YES];
}
- (void)dealloc
{
[signal_ release];
Loading
Loading
@@ -140,6 +172,10 @@ static const int kMaxJobs = 20;
ToolWrapper *wrapper = (ToolWrapper *)[[self superview] superview];
pid_t rootPid = [[[wrapper.term currentSession] SHELL] pid];
NSSet *pids = [[ProcessCache sharedInstance] childrenOfPid:rootPid levelsToSkip:0];
if ([pids isEqualToSet:[NSSet setWithArray:pids_]]) {
// Nothing to do, skip the expensive step of getting names.
return;
}
[pids_ release];
pids_ = [[[pids allObjects] sortedArrayUsingSelector:@selector(compare:)] retain];
[names_ removeAllObjects];
Loading
Loading
@@ -153,6 +189,15 @@ static const int kMaxJobs = 20;
}
}
[tableView_ reloadData];
// Updating the table data causes the cursor to change into an arrow!
[self performSelector:@selector(fixCursor) withObject:nil afterDelay:0];
}
- (void)fixCursor
{
ToolWrapper *wrapper = (ToolWrapper *)[[self superview] superview];
[[[wrapper.term currentSession] TEXTVIEW] updateCursor:[[NSApplication sharedApplication] currentEvent]];
}
 
- (BOOL)isFlipped
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@
#import "ToolPasteHistory.h"
#import "NSDateFormatterExtras.h"
#import "iTermController.h"
#import "ToolWrapper.h"
 
@implementation ToolPasteHistory
 
Loading
Loading
@@ -114,6 +115,14 @@
- (void)pasteboardHistoryDidChange:(id)sender
{
[tableView_ reloadData];
// Updating the table data causes the cursor to change into an arrow!
[self performSelector:@selector(fixCursor) withObject:nil afterDelay:0];
}
- (void)fixCursor
{
ToolWrapper *wrapper = (ToolWrapper *)[[self superview] superview];
[[[wrapper.term currentSession] TEXTVIEW] updateCursor:[[NSApplication sharedApplication] currentEvent]];
}
 
- (void)doubleClickOnTableView:(id)sender
Loading
Loading
@@ -134,6 +143,8 @@
[pasteHistory_ eraseHistory];
[pasteHistory_ clear];
[tableView_ reloadData];
// Updating the table data causes the cursor to change into an arrow!
[self performSelector:@selector(fixCursor) withObject:nil afterDelay:0];
}
 
@end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment