Ignore:
Timestamp:
12/08/07 06:07:14 (16 years ago)
Author:
Nicholas Riley
Message:

Apparently in Xcode, 'Commit Entire Project' doesn't. See the log message from [369].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/AntiRSI/AntiRSI.m

    r348 r370  
    2424#include <ApplicationServices/ApplicationServices.h>
    2525
     26// 10.5-only
     27enum {
     28    NSWindowCollectionBehaviorDefault = 0,
     29    NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0,
     30    NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
     31};
     32typedef unsigned NSWindowCollectionBehavior;
     33@interface NSWindow (NSWindowCollectionBehavior)
     34- (void)setCollectionBehavior:(NSWindowCollectionBehavior)behavior;
     35@end
     36
    2637extern CFTimeInterval CGSSecondsSinceLastInputEvent(unsigned long eventType);
    2738
     
    194205    [main_window setHasShadow:NO];
    195206    [main_window setMovableByWindowBackground:YES];
     207    if ([main_window respondsToSelector:@selector(setCollectionBehavior:)])
     208        [main_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];
     209
    196210    [main_window center];
    197211    [main_window setContentView:view];
     
    235249    [dc setInitialValues:initial];
    236250   
    237     // bind to defauls controller
     251    // bind to defaults controller
    238252    [self bind:@"micro_pause_period" toObject:dc withKeyPath:@"values.micro_pause_period" options:nil];
    239253    [self bind:@"micro_pause_duration" toObject:dc withKeyPath:@"values.micro_pause_duration" options:nil];
     
    550564}
    551565
     566static ProcessSerialNumber frontmostApp;
     567
    552568// done with micro pause or work break
    553569- (void)endBreak
    554570{
    555571    [main_window orderOut:NULL];
     572    if (lock_focus && (frontmostApp.highLongOfPSN != 0 || frontmostApp.lowLongOfPSN != 0)) {
     573        SetFrontProcess(&frontmostApp);
     574        frontmostApp.highLongOfPSN = kNoProcess;
     575    }
    556576    state = s_normal;
    557577    // reset time interval to user's choice
    558578    [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];
    559592}
    560593
     
    570603    [postpone setHidden:YES];
    571604    state = s_taking_micro_pause;
    572     [self tick: nil];
    573     [main_window center];
    574     [main_window orderFrontRegardless];
     605    [self focus];
    575606}
    576607
     
    591622    [postpone setHidden:NO];
    592623    state = s_taking_work_break;
    593     [self tick: nil];
    594     [main_window center];
    595     [main_window orderFrontRegardless];
     624    [self focus];
    596625}
    597626
     
    656685        int r = NSRunInformationalAlertPanel(
    657686             @"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],
    659688             @"Goto Website", @"Cancel", nil);
    660689        if (r == NSOKButton) {
Note: See TracChangeset for help on using the changeset viewer.