Changeset 370 for trunk/Cocoa/AntiRSI/AntiRSI.m
- Timestamp:
- 12/08/07 06:07:14 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.m
r348 r370 24 24 #include <ApplicationServices/ApplicationServices.h> 25 25 26 // 10.5-only 27 enum { 28 NSWindowCollectionBehaviorDefault = 0, 29 NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0, 30 NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1 31 }; 32 typedef unsigned NSWindowCollectionBehavior; 33 @interface NSWindow (NSWindowCollectionBehavior) 34 - (void)setCollectionBehavior:(NSWindowCollectionBehavior)behavior; 35 @end 36 26 37 extern CFTimeInterval CGSSecondsSinceLastInputEvent(unsigned long eventType); 27 38 … … 194 205 [main_window setHasShadow:NO]; 195 206 [main_window setMovableByWindowBackground:YES]; 207 if ([main_window respondsToSelector:@selector(setCollectionBehavior:)]) 208 [main_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces]; 209 196 210 [main_window center]; 197 211 [main_window setContentView:view]; … … 235 249 [dc setInitialValues:initial]; 236 250 237 // bind to defaul s controller251 // bind to defaults controller 238 252 [self bind:@"micro_pause_period" toObject:dc withKeyPath:@"values.micro_pause_period" options:nil]; 239 253 [self bind:@"micro_pause_duration" toObject:dc withKeyPath:@"values.micro_pause_duration" options:nil]; … … 550 564 } 551 565 566 static ProcessSerialNumber frontmostApp; 567 552 568 // done with micro pause or work break 553 569 - (void)endBreak 554 570 { 555 571 [main_window orderOut:NULL]; 572 if (lock_focus && (frontmostApp.highLongOfPSN != 0 || frontmostApp.lowLongOfPSN != 0)) { 573 SetFrontProcess(&frontmostApp); 574 frontmostApp.highLongOfPSN = kNoProcess; 575 } 556 576 state = s_normal; 557 577 // reset time interval to user's choice 558 578 [self installTimer:sample_interval]; 579 } 580 581 // bring app to front, saving previous app 582 - (void)focus 583 { 584 NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication]; 585 if (lock_focus) { 586 frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue]; 587 frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue]; 588 } 589 [self tick: nil]; 590 [main_window center]; 591 [main_window orderFrontRegardless]; 559 592 } 560 593 … … 570 603 [postpone setHidden:YES]; 571 604 state = s_taking_micro_pause; 572 [self tick: nil]; 573 [main_window center]; 574 [main_window orderFrontRegardless]; 605 [self focus]; 575 606 } 576 607 … … 591 622 [postpone setHidden:NO]; 592 623 state = s_taking_work_break; 593 [self tick: nil]; 594 [main_window center]; 595 [main_window orderFrontRegardless]; 624 [self focus]; 596 625 } 597 626 … … 656 685 int r = NSRunInformationalAlertPanel( 657 686 @"New Version", 658 [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to the website now?", latest_version],687 [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to its Web site now?", latest_version], 659 688 @"Goto Website", @"Cancel", nil); 660 689 if (r == NSOKButton) {
Note:
See TracChangeset
for help on using the changeset viewer.