[Wsmanager-devel] [ForeignWindow moveToWorkspaceRepresentedBy:...]
Status: Alpha
Brought to you by:
richwareham
From: Naveen Michaud-A. <inf...@ya...> - 2004-04-14 19:01:51
|
Hello, I am trying to implement the ability to drag windows between desktops using the pager. I have it working correctly (by calling the above function in DesktopPagerCell continueTracking:...) but the window list of the new workspace is not updated until mouse tracking ends, so visually the window only moves within the pager cell corresponding to the workspace it originated in. Since that probably doesn't make sense without witnessing it, here is my modified DesktopPagerCell continueTracking: static BOOL movedtoNewWorkspace = NO; static int newWorkspaceNumber = -1; - (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView*)controlView { if(!dragging) { return NO; } if(!NSPointInRect(currentPoint, lastCellFrame)) { if (!NSPointInRect(currentPoint, [controlView bounds])) { // Don't move windows out of the screen but // keep tracking... return YES; } int row, column; BOOL inControlView = [controlView getRow: &row column:&column forPoint: currentPoint]; // I should really test inControlView id cell = [controlView cellAtRow: row column: column]; if (newWorkspaceNumber != [[cell representedObject] workspaceNumber]) { [draggingWindow moveToWorkspaceRepresentedBy: cell]; movedtoNewWorkspace = YES; newWorkspaceNumber = [draggingWindow workspaceNumber]; } /* This just prints all the windows in the new workspace for debugging NSArray *windowList = [[cell representedObject] windowList]; int i; if(windowList && [windowList count]) { for(i=[windowList count]-1; i>=0; i--) { ForeignWindow *window = (ForeignWindow*) [windowList objectAtIndex: i]; NSLog(@"\t%@", [window title]); } }*/ // Convert window to new coordinates currentPoint = [self cellPointToScreenPoint: currentPoint cellFrame: [controlView cellFrameAtRow:row column:column]]; } else { /* Current workspace */ if (movedtoNewWorkspace) { /* The window was moved back into the current workspace */ movedtoNewWorkspace = NO; [draggingWindow moveToWorkspaceRepresentedBy: self]; newWorkspaceNumber = -1; } currentPoint = [self cellPointToScreenPoint: currentPoint cellFrame: lastCellFrame]; } NSPoint newPoint; newPoint.x = currentPoint.x + delta.x; newPoint.y = currentPoint.y + delta.y; [draggingWindow move: newPoint]; [[self controlView] setNeedsDisplay: YES]; return YES; } - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { dragging = NO; movedtoNewWorkspace = NO; newWorkspaceNumber = -1; [draggingWindow release]; } When you run the code and drag a window from one workspace to the next, visually the pager representation of the window only moves around in the originating cell, but when you release the mouse the window is in the right workspace. I could hack the drawRect function but I would rather not. If you uncomment the code above that lists the windows in the new workspace you'll see that even though the window claims that it is in the new workspace, the workspace doesn't see it. any ideas? Naveen Michaud-Agrawal __________________________________ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html |