Ticket #2709: dskm.diff

File dskm.diff, 14.1 KB (added by shadow@…, 20 years ago)

diff of patch 95 to patch 97 of the DesktopManager arch repository

  • ChangeLog

    old new  
    22# arch-tag: automatic-ChangeLog--richwareham@users.sourceforge.net--DesktopManager/DesktopManager--dev--0.5
    33#
    44
     52004-07-15 13:19:05 GMT Rich Wareham <richwareham@users.sourceforge.net>        patch-97
     6
     7    Summary:
     8      Added possibility of having Tab as hotkey
     9    Revision:
     10      DesktopManager--dev--0.5--patch-97
     11
     12    Added the possibility of Tab as a hot key. Unfortunately we can't capture Ctrl-Tab in the keyDown messages so we can't set it via preferences. Manual editting of prefs file should work however.
     13
     14    modified files:
     15     ChangeLog DesktopManager.xcode/rjw57.pbxuser HotKeys/HotKey.m
     16     Utility/MouseWatcher.m
     17
     18
     192004-07-15 12:32:35 GMT Rich Wareham <richwareham@users.sourceforge.net>        patch-96
     20
     21    Summary:
     22      Move windows between desktops via pager
     23    Revision:
     24      DesktopManager--dev--0.5--patch-96
     25
     26    Can now drag windows between desktops using the desktop pager.
     27   
     28    Based on main patch by Naveen Michaud-Agrawal <infinite8s@yahoo.com>
     29   
     30    Modified by Ka-Hing Cheung <kahing@gmail.com> to only cause desktop switch on mouse up.
     31    Modified by me to tidy up warnings / make cmore consistent with DM coding style.
     32
     33    modified files:
     34     ChangeLog Core/ForeignWindow.m Core/WorkspaceController.m
     35     DesktopManager.xcode/rjw57.pbxuser Include/ForeignWindow.h
     36     Include/WindowControllerEvents.h Include/WorkspaceController.h
     37     Plugins/DesktopPager/DesktopPagerCell.h
     38     Plugins/DesktopPager/DesktopPagerCell.m
     39     Plugins/DesktopPager/DesktopPagerView.m
     40     Plugins/DockExtension/ControllerEventHandlers.c
     41     Plugins/DockExtension/ControllerEventHandlers.h
     42     Plugins/DockExtension/WindowController.c
     43     Plugins/DockExtension/WindowController.h
     44     Plugins/DockExtension/main.c
     45
     46
    5472004-07-12 16:09:15 GMT Rich Wareham <richwareham@users.sourceforge.net>        patch-95
    648
    749    Summary:
  • Core/ForeignWindow.m

    
            
    old new  
    335335    sendEvent(&theEvent);
    336336}
    337337
     338- (void) hide {
     339    AppleEvent theEvent;
     340   
     341    makeEvent(kWindowControllerHideWindow, &theEvent);
     342    addIntParm(wid, 'wid ', &theEvent);
     343   
     344    sendEvent(&theEvent);
     345}
     346
     347- (void) show {
     348    AppleEvent theEvent;
     349   
     350    makeEvent(kWindowControllerShowWindow, &theEvent);
     351    addIntParm(wid, 'wid ', &theEvent);
     352   
     353    sendEvent(&theEvent);
     354}
     355
    338356- (void) fade {
    339357    AppleEvent theEvent;
    340358   
  • Core/WorkspaceController.m

    
            
    old new  
    474474}
    475475
    476476- (ForeignWindow*) windowContainingPoint: (NSPoint) mouseLoc {
     477        return [self windowContainingPoint: mouseLoc inWorkspace: [self currentWorkspace]];
     478}
    477479
    478        
    479         // NSLog(@"Mouse at (%f,%f)", mouseLoc.x, mouseLoc.y);
    480        
     480- (ForeignWindow*) windowContainingPoint: (NSPoint) mouseLoc inWorkspace: (Workspace*) ws {
    481481        // Start walking trough the window list from top to bottom
    482482        // and return if we find a window.
    483         int i=0; NSArray *windowList = [[self currentWorkspace] windowList];
     483        int i=0; NSArray *windowList = [ws windowList];
    484484        for(i=0; i<[windowList count]; i++) {
    485485                ForeignWindow *window = (ForeignWindow*) [windowList objectAtIndex: i];
    486486                NSRect screenRect = [window screenRect];
    487                 //NSLog(@"(%f,%f) +(%f,%f) - %@", screenRect.origin.x, screenRect.origin.y,
    488             //          screenRect.size.width, screenRect.size.height, [window title]);
    489487               
    490488                if(NSMouseInRect(mouseLoc, screenRect, NO)) {
    491489                        return window;
  • HotKeys/HotKey.m

    
            
    old new  
    254254                        return C2S(0x2196);
    255255                        break;
    256256                case kSpaceCharCode:
    257                         return @"<Spc>";
     257                        return @"Space";
    258258                        break;
    259259                case kReturnCharCode:
    260260                        return C2S(0x23CE);
     
    262262                case kEscapeCharCode:
    263263                        return C2S(0x238B);
    264264                        break; 
     265                case kTabCharCode:
     266                        return @"Tab";
     267                        break;
    265268        }
    266269       
    267270        // NSLog(@"CharCode: %i", charCode);
  • Include/ForeignWindow.h

    
            
    old new  
    4242- (int) workspaceNumber;
    4343- (CGSWindow) windowNumber;
    4444- (ForeignWindow*) movementParent;
     45- (void) show;
     46- (void) hide;
    4547- (void) fade;
    4648- (void) unFade;
    4749- (void) move: (NSPoint) to;
     
    5961- (int) tags;
    6062- (uint32_t) eventMask;
    6163- (void) setEventMask: (uint32_t) mask;
     64- (void) moveToWorkspaceRepresentedBy: (id) represent;
    6265
    6366@end
  • Include/WindowControllerEvents.h

    
            
    old new  
    2323};
    2424
    2525enum {
     26        kWindowControllerHideWindow             = 'hidw',
     27        kWindowControllerShowWindow             = 'show',
    2628    kWindowControllerFadeWindow         = 'fdwn',
    2729    kWindowControllerUnFadeWindow       = 'ufdw',
    2830    kWindowControllerMoveWindow         = 'mvwn',
  • Include/WorkspaceController.h

    
            
    old new  
    5151- (int) currentWorkspaceIndex;
    5252- (NSArray*) workspaceNames;
    5353- (ForeignWindow*) windowContainingPoint: (NSPoint) screenPoint;
     54- (ForeignWindow*) windowContainingPoint: (NSPoint) screenPoint inWorkspace: (Workspace*) ws;
    5455- (ForeignWindow*) windowUnderPointer;
    5556- (void) collectWindows;
    5657
  • Plugins/DesktopPager/DesktopPagerCell.h

    
            
    old new  
    2525        BOOL dragging;
    2626        ForeignWindow *draggingWindow;
    2727        NSPoint delta;
     28
     29        /* These are for dragging windows between workspaces */
     30        Workspace* dragInWorkspace, *dragToWorkspace;
    2831}
    2932
    3033- (void) setTargetHeight: (int) height;
    3134- (int) targetHeight;
    32 
     35- (DesktopPagerCell *) pointToCell:(NSView *)controlView point:(NSPoint)point;
    3336
    3437@end
  • Plugins/DesktopPager/DesktopPagerCell.m

    
            
    old new  
    2626        id mySelf = [super init];
    2727        if(mySelf) {
    2828                targetHeight = 50;
     29//        [self sendActionOn: (NSLeftMouseUpMask | NSLeftMouseDraggedMask)];
    2930        }
    3031        return mySelf;
    3132}
     
    198199        Workspace *ws = [self representedObject];
    199200       
    200201        if(!ws) { return NO; }
     202   
     203    DesktopPagerCell *tmp = [self pointToCell: controlView point: startPoint];
     204               
     205        startPoint = [tmp cellPointToScreenPoint: startPoint cellFrame: lastCellFrame];
     206        draggingWindow = [wsController windowContainingPoint: startPoint inWorkspace: ws];
    201207       
    202         if(ws && ![ws isSelected]) { [ws selectWithDefaultTransition]; }
    203        
    204         startPoint = [self cellPointToScreenPoint: startPoint cellFrame: lastCellFrame];
    205         draggingWindow = [wsController windowContainingPoint: startPoint];
    206        
    207         if(!draggingWindow) { return nil; }
     208        if(!draggingWindow) {
     209        if(![ws isSelected]) { [ws selectWithDefaultTransition]; }
     210        return nil;
     211    }
    208212       
    209213        delta.x = [draggingWindow screenRect].origin.x - startPoint.x;
    210214        delta.y = [draggingWindow screenRect].origin.y - startPoint.y;
    211215        [draggingWindow retain];
    212         dragging = YES;
     216   
     217        dragInWorkspace = dragToWorkspace = [tmp representedObject];
    213218       
    214219        return YES;
    215220}
    216221
    217222- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView*)controlView {
    218         if(!dragging) { return NO; }
     223        if(!draggingWindow) { return NO; }
     224    dragging = YES;     
    219225       
    220         if(!NSPointInRect(currentPoint, lastCellFrame)) {
     226        if (!NSPointInRect(currentPoint, [controlView bounds])) {
    221227                // Don't move windows out of the screen but
    222228                // keep tracking...
    223229                return YES;
    224230        }
     231
     232    int row, column;
     233        NSMatrix *mControlView = (NSMatrix*) controlView;
     234        BOOL inControlView = [mControlView getRow: &row column:&column forPoint: currentPoint];
     235    if(!inControlView) {
     236                return NO;
     237        }
    225238       
    226         currentPoint = [self cellPointToScreenPoint: currentPoint cellFrame: lastCellFrame];
    227        
     239    id cell = [mControlView cellAtRow: row column: column];
     240    dragToWorkspace = [cell representedObject];
     241
     242        if ([dragToWorkspace workspaceNumber] != [dragInWorkspace workspaceNumber]) {
     243                // We've moved to a new workspace
     244                [draggingWindow hide];
     245                [draggingWindow moveToWorkspaceRepresentedBy: cell];
     246                [dragInWorkspace updateWindowList];
     247                [dragToWorkspace updateWindowList];
     248        }
     249               
     250        // Move window to new coordinates
     251        currentPoint = [cell cellPointToScreenPoint: currentPoint cellFrame: [mControlView cellFrameAtRow:row column:column]];         
     252
    228253        NSPoint newPoint;
    229254        newPoint.x = currentPoint.x + delta.x;
    230255        newPoint.y = currentPoint.y + delta.y;
    231        
    232256        [draggingWindow move: newPoint];
     257       
     258        if ([dragToWorkspace workspaceNumber] != [dragInWorkspace workspaceNumber]) {
     259                [draggingWindow show];
     260                [draggingWindow focusOwner];
     261                //[dragToWorkspace selectWithDefaultTransition];
     262                dragInWorkspace = dragToWorkspace;
     263        }
     264
    233265        [[self controlView] setNeedsDisplay: YES];
    234266       
    235267        return YES;
    236268}
    237269
    238270- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag {
     271    if(!dragging) {
     272        // if we are not dragging, and this is mouse up, switch workspace
     273        Workspace *ws = [[self pointToCell: controlView point: lastPoint] representedObject];
     274       
     275        if(ws && ![ws isSelected]) { [ws selectWithDefaultTransition]; }
     276    }
    239277        dragging = NO;
    240278       
    241279        [draggingWindow release];
     280    draggingWindow = nil;
     281}
     282
     283- (DesktopPagerCell *) pointToCell:(NSView *)controlView point:(NSPoint)point {
     284    int row, column;
     285    BOOL inControlView = [(NSMatrix*) controlView getRow: &row column:&column forPoint: point];
     286    if(!inControlView) {
     287                return nil;
     288        }
     289       
     290    id cell = [(NSMatrix*) controlView cellAtRow: row column: column];
     291   
     292    return cell;
    242293}
    243294
    244295+ (BOOL)prefersTrackingUntilMouseUp { return YES; }
  • Plugins/DesktopPager/DesktopPagerView.m

    
            
    old new  
    8282            name: NOTIFICATION_WINDOWLAYOUTUPDATED
    8383            object: nil
    8484        ];
    85                                                
     85
    8686                [self readPreferences];
    8787    }
    8888
  • Plugins/DockExtension/ControllerEventHandlers.c

    
            
    old new  
    9797
    9898/* These are the various AppleEvent handlers, they are used to
    9999 * translate the events into calls to functions in WindowManipulation.c */
    100  
     100
     101/* Hide a window */
     102OSErr hideWindowHandler( const AppleEvent *theEvent,
     103    AppleEvent *reply, SInt32 handlerRefcon) {
     104    int wid;
     105   
     106    wid = getIntParam(theEvent, 'wid ');
     107    hideWindow(wid);
     108   
     109    return 0;
     110}
     111
     112/* Show a window */
     113OSErr showWindowHandler( const AppleEvent *theEvent,
     114    AppleEvent *reply, SInt32 handlerRefcon) {
     115    int wid;
     116   
     117    wid = getIntParam(theEvent, 'wid ');
     118    showWindow(wid);
     119   
     120    return 0;
     121}
     122
    101123/* Fade a window */
    102124OSErr fadeWindowHandler( const AppleEvent *theEvent,
    103125    AppleEvent *reply, SInt32 handlerRefcon) {
  • Plugins/DockExtension/ControllerEventHandlers.h

    
            
    old new  
    1818
    1919#include <Carbon/Carbon.h>
    2020
     21OSErr hideWindowHandler( const AppleEvent *theEvent,
     22    AppleEvent *reply, SInt32 handlerRefcon);
     23OSErr showWindowHandler( const AppleEvent *theEvent,
     24    AppleEvent *reply, SInt32 handlerRefcon);
    2125OSErr fadeWindowHandler( const AppleEvent *theEvent,
    2226    AppleEvent *reply, SInt32 handlerRefcon);
    2327OSErr unFadeWindowHandler( const AppleEvent *theEvent,
  • Plugins/DockExtension/WindowController.c

    
            
    old new  
    2222#include <unistd.h>
    2323#include <syslog.h>
    2424
     25void hideWindow(int wid) {
     26        CGSConnection cid;
     27       
     28        cid = _CGSDefaultConnection();
     29        CGSSetWindowAlpha(cid, wid, 0.0);
     30}
     31
     32void showWindow(int wid) {
     33        CGSConnection cid;
     34       
     35        cid = _CGSDefaultConnection();
     36        CGSSetWindowAlpha(cid, wid, 1.0);
     37}
     38
    2539void fadeWindow(int wid) {
    2640        float alpha = 0;
    2741    CGSConnection cid;
     
    5771    CGSConnection cid;
    5872    CGPoint point;
    5973        CGSValue group = NULL;
    60         int groupNo = 0;
    6174       
    6275    cid = _CGSDefaultConnection();
    6376    point.x = x; point.y = y;
     
    6881       
    6982        if(group) {
    7083                // CGSMoveWindowWithGroup(cid, wid, &point, groupNo);
     84                //CGSMoveWindowWithGroup(cid, wid, &point, groupNo);
    7185        } else {
    7286                CGSMoveWindow(cid, wid, &point);
    7387        }
  • Plugins/DockExtension/WindowController.h

    
            
    old new  
    1818 
    1919#include <Carbon/Carbon.h>
    2020
     21void hideWindow(int wid);
     22void showWindow(int wid);
    2123void fadeWindow(int wid);
    2224void unFadeWindow(int wid);
    2325void moveWindow(int wid, float x, float y);
  • Plugins/DockExtension/main.c

    
            
    old new  
    5353    /* Install event handlers */
    5454    err = AEInstallEventHandler(
    5555        kWindowControllerClass,
     56        kWindowControllerHideWindow,
     57        NewAEEventHandlerUPP((&hideWindowHandler) + offset),
     58        0, FALSE
     59    );
     60    if(err) { syslog(LOG_ERR, "Error registering hide handler: %i", err); }
     61
     62    err = AEInstallEventHandler(
     63        kWindowControllerClass,
     64        kWindowControllerShowWindow,
     65        NewAEEventHandlerUPP((&showWindowHandler) + offset),
     66        0, FALSE
     67    );
     68    if(err) { syslog(LOG_ERR, "Error registering show handler: %i", err); }
     69
     70    err = AEInstallEventHandler(
     71        kWindowControllerClass,
    5672        kWindowControllerFadeWindow,
    5773        NewAEEventHandlerUPP((&fadeWindowHandler) + offset),
    5874        0, FALSE
  • Utility/MouseWatcher.m

    
            
    old new  
    5151}
    5252
    5353- (MouseWatcherEdge) _edgeContainingPoint: (CGPoint) loc {
    54         if((loc.x >= screenRect.origin.x) && (loc.x <= screenRect.origin.x + 3)) {
    55                 return LeftEdge;
    56         }
    57         if((loc.x <= screenRect.origin.x + screenRect.size.width) &&
    58            (loc.x >= screenRect.origin.x + screenRect.size.width - 3)) {
    59                 return RightEdge;
    60         }
    61         if((loc.y <= screenRect.origin.y + screenRect.size.height) &&
    62            (loc.y >= screenRect.origin.y + screenRect.size.height - 3)) {
    63                 return BottomEdge;
    64         }
     54    if((loc.y >= screenRect.origin.y + 10) &&
     55       (loc.y <= screenRect.origin.y + screenRect.size.height - 10)) {
     56        if((loc.x >= screenRect.origin.x) && (loc.x <= screenRect.origin.x + 3)) {
     57            return LeftEdge;
     58        }
     59        if((loc.x <= screenRect.origin.x + screenRect.size.width) &&
     60           (loc.x >= screenRect.origin.x + screenRect.size.width - 3)) {
     61            return RightEdge;
     62        }
     63    }
     64    if((loc.x >= screenRect.origin.x + 10) &&
     65       (loc.x <= screenRect.origin.x + screenRect.size.width - 10)) {
     66        if((loc.y <= screenRect.origin.y + screenRect.size.height) &&
     67           (loc.y >= screenRect.origin.y + screenRect.size.height - 3)) {
     68            return BottomEdge;
     69        }
     70    }
    6571       
    6672        return None;
    6773}