Lock focus / unlock focus optimizations and fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15839 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2003-02-01 05:10:00 +00:00
parent 72512673b2
commit 2177ef847e
22 changed files with 111 additions and 115 deletions

View file

@ -439,10 +439,15 @@ static NSCell* tileCell = nil;
- (void) setImage: (NSImage *)anImage - (void) setImage: (NSImage *)anImage
{ {
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
[dragCell setImage: anImage]; [dragCell setImage: anImage];
[dragCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
[_window flushWindow]; if ([self lockFocusIfCanDraw])
{
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
[dragCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
[self unlockFocus];
[_window flushWindow];
}
} }
@end @end

View file

@ -192,9 +192,7 @@ static NSTextFieldCell *titleCell;
return; return;
} }
[controlView lockFocus];
NSDrawGrayBezel (cellFrame, NSZeroRect); NSDrawGrayBezel (cellFrame, NSZeroRect);
[controlView unlockFocus];
[self drawInteriorWithFrame: cellFrame inView: controlView]; [self drawInteriorWithFrame: cellFrame inView: controlView];
} }
@end @end
@ -752,8 +750,10 @@ static NSTextFieldCell *titleCell;
// Update and display title of column // Update and display title of column
if (_isTitled) if (_isTitled)
{ {
[self lockFocus];
[self drawTitleOfColumn: column [self drawTitleOfColumn: column
inRect: [self titleFrameOfColumn: column]]; inRect: [self titleFrameOfColumn: column]];
[self unlockFocus];
} }
// Display column // Display column
@ -762,6 +762,9 @@ static NSTextFieldCell *titleCell;
if (!(sc = [bc columnScrollView])) if (!(sc = [bc columnScrollView]))
return; return;
/* FIXME: why the following ? Are we displaying now, or marking for
* later display ?? Given the name, I think we are displaying
* now. */
[sc setNeedsDisplay: YES]; [sc setNeedsDisplay: YES];
} }
@ -1800,7 +1803,6 @@ static NSTextFieldCell *titleCell;
if (_allowsBranchSelection == NO && [cell isLeaf] == NO) if (_allowsBranchSelection == NO && [cell isLeaf] == NO)
{ {
[selectedCells removeObject: cell]; [selectedCells removeObject: cell];
continue;
} }
} }
@ -1826,6 +1828,11 @@ static NSTextFieldCell *titleCell;
while ((cell = [enumerator nextObject])) while ((cell = [enumerator nextObject]))
[sender selectCell: cell]; [sender selectCell: cell];
// FIXME: shouldn't be locking focus on another object
// probably all this loop is wrong, because deselectSelectedCell
// above may have changed array a.
[sender lockFocus];
enumerator = [a objectEnumerator]; enumerator = [a objectEnumerator];
while ((cell = [enumerator nextObject])) while ((cell = [enumerator nextObject]))
{ {
@ -1840,6 +1847,9 @@ static NSTextFieldCell *titleCell;
[sender drawCellAtRow: row column: 0]; [sender drawCellAtRow: row column: 0];
} }
} }
[sender unlockFocus];
[self displayIfNeeded];
[_window flushWindow];
} }
if (selectedCellsCount > 0) if (selectedCellsCount > 0)

View file

@ -230,8 +230,6 @@ static NSFont *_leafFont;
if (!cvWin) if (!cvWin)
return; return;
[controlView lockFocus];
if (_cell.is_highlighted || _cell.state) if (_cell.is_highlighted || _cell.state)
{ {
backColor = [self highlightColorInView: controlView]; backColor = [self highlightColorInView: controlView];
@ -308,8 +306,6 @@ static NSFont *_leafFont;
NSDottedFrameRect(cellFrame); NSDottedFrameRect(cellFrame);
_cell.shows_first_responder = showsFirstResponder; _cell.shows_first_responder = showsFirstResponder;
[controlView unlockFocus];
} }
- (BOOL) isOpaque - (BOOL) isOpaque

View file

@ -615,7 +615,6 @@
// draw the border if needed // draw the border if needed
if (_cell.is_bordered) if (_cell.is_bordered)
{ {
[controlView lockFocus];
// FIXME Should check the bezel and gradient style // FIXME Should check the bezel and gradient style
if (_cell.is_highlighted && (_highlightsByMask & NSPushInCellMask)) if (_cell.is_highlighted && (_highlightsByMask & NSPushInCellMask))
{ {
@ -625,7 +624,6 @@
{ {
NSDrawButton(cellFrame, NSZeroRect); NSDrawButton(cellFrame, NSZeroRect);
} }
[controlView unlockFocus];
} }
[self drawInteriorWithFrame: cellFrame inView: controlView]; [self drawInteriorWithFrame: cellFrame inView: controlView];
@ -651,7 +649,6 @@
_control_view = controlView; _control_view = controlView;
cellFrame = [self drawingRectForBounds: cellFrame]; cellFrame = [self drawingRectForBounds: cellFrame];
[controlView lockFocus];
if (_cell.is_highlighted) if (_cell.is_highlighted)
{ {
@ -897,8 +894,6 @@
else else
NSDottedFrameRect(titleRect); NSDottedFrameRect(titleRect);
} }
[controlView unlockFocus];
} }
- (NSSize) cellSize - (NSSize) cellSize

View file

@ -1135,6 +1135,8 @@ static NSColor *shadowCol;
{ {
NSRect cvBounds = [cv bounds]; NSRect cvBounds = [cv bounds];
NSWindow *cvWin = [cv window]; NSWindow *cvWin = [cv window];
[cv lockFocus];
[self setNextState]; [self setNextState];
[self highlight: YES withFrame: cvBounds inView: cv]; [self highlight: YES withFrame: cvBounds inView: cv];
@ -1147,6 +1149,8 @@ static NSColor *shadowCol;
[self highlight: NO withFrame: cvBounds inView: cv]; [self highlight: NO withFrame: cvBounds inView: cv];
[cvWin flushWindow]; [cvWin flushWindow];
[cv unlockFocus];
if (action) if (action)
{ {
NS_DURING NS_DURING
@ -1596,8 +1600,6 @@ static NSColor *shadowCol;
cellFrame.size.height -= 2; cellFrame.size.height -= 2;
} }
[controlView lockFocus];
switch (_cell.type) switch (_cell.type)
{ {
case NSTextCellType: case NSTextCellType:
@ -1637,7 +1639,6 @@ static NSColor *shadowCol;
// NB: We don't do any highlighting to make it easier for subclasses // NB: We don't do any highlighting to make it easier for subclasses
// to reuse this code while doing their own custom highlighting and // to reuse this code while doing their own custom highlighting and
// prettyfying // prettyfying
[controlView unlockFocus];
} }
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
@ -1649,16 +1650,12 @@ static NSColor *shadowCol;
// draw the border if needed // draw the border if needed
if (_cell.is_bordered) if (_cell.is_bordered)
{ {
[controlView lockFocus];
[shadowCol set]; [shadowCol set];
NSFrameRect(cellFrame); NSFrameRect(cellFrame);
[controlView unlockFocus];
} }
else if (_cell.is_bezeled) else if (_cell.is_bezeled)
{ {
[controlView lockFocus];
NSDrawWhiteBezel(cellFrame, NSZeroRect); NSDrawWhiteBezel(cellFrame, NSZeroRect);
[controlView unlockFocus];
} }
[self drawInteriorWithFrame: cellFrame inView: controlView]; [self drawInteriorWithFrame: cellFrame inView: controlView];

View file

@ -1006,18 +1006,23 @@ buttonCellFrameFromRect(NSRect cellRect)
// We can not use performClick: on the button cell here as // We can not use performClick: on the button cell here as
// the button uses only part of the bounds of the control view. // the button uses only part of the bounds of the control view.
NSWindow *cvWin = [controlView window]; NSWindow *cvWin = [controlView window];
[controlView lockFocus];
[_buttonCell highlight: YES [_buttonCell highlight: YES
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonCellFrameFromRect(cellFrame)
inView: controlView]; inView: controlView];
[controlView unlockFocus];
[cvWin flushWindow]; [cvWin flushWindow];
[self _didClick: self]; [self _didClick: self];
[controlView lockFocus];
[_buttonCell highlight: NO [_buttonCell highlight: NO
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonCellFrameFromRect(cellFrame)
inView: controlView]; inView: controlView];
[controlView unlockFocus];
[cvWin flushWindow]; [cvWin flushWindow];
} }
- (void) _didClick: (id)sender - (void) _didClick: (id)sender
@ -1031,7 +1036,8 @@ buttonCellFrameFromRect(NSRect cellRect)
object: popView object: popView
userInfo: nil]; userInfo: nil];
// HACK Abort the editing, otherwise the selected value is overwritten by the editor // HACK Abort the editing, otherwise the selected value is
// overwritten by the editor
//if ([_control_view isKindOfClass: NSControl]) //if ([_control_view isKindOfClass: NSControl])
[(NSControl *)_control_view abortEditing]; [(NSControl *)_control_view abortEditing];

View file

@ -512,6 +512,7 @@ static Class actionCellClass;
} }
[_window _captureMouse: self]; [_window _captureMouse: self];
[self lockFocus];
e = theEvent; e = theEvent;
while (!done) // loop until mouse goes up while (!done) // loop until mouse goes up
@ -557,6 +558,8 @@ static Class actionCellClass;
[_window flushWindow]; [_window flushWindow];
} }
[self unlockFocus];
[_cell sendActionOn: oldActionMask]; [_cell sendActionOn: oldActionMask];
if (mouseUp) if (mouseUp)

View file

@ -317,16 +317,12 @@ static NSColor *shadowCol;
if (_cell.is_bordered) if (_cell.is_bordered)
{ {
[controlView lockFocus];
[shadowCol set]; [shadowCol set];
NSFrameRect(borderedFrame); NSFrameRect(borderedFrame);
[controlView unlockFocus];
} }
else if (_cell.is_bezeled) else if (_cell.is_bezeled)
{ {
[controlView lockFocus];
NSDrawWhiteBezel(borderedFrame, NSZeroRect); NSDrawWhiteBezel(borderedFrame, NSZeroRect);
[controlView unlockFocus];
} }
// //

View file

@ -121,24 +121,16 @@
// nada // nada
break; break;
case NSImageFramePhoto: case NSImageFramePhoto:
[controlView lockFocus];
NSDrawFramePhoto(cellFrame, NSZeroRect); NSDrawFramePhoto(cellFrame, NSZeroRect);
[controlView unlockFocus];
break; break;
case NSImageFrameGrayBezel: case NSImageFrameGrayBezel:
[controlView lockFocus];
NSDrawGrayBezel(cellFrame, NSZeroRect); NSDrawGrayBezel(cellFrame, NSZeroRect);
[controlView unlockFocus];
break; break;
case NSImageFrameGroove: case NSImageFrameGroove:
[controlView lockFocus];
NSDrawGroove(cellFrame, NSZeroRect); NSDrawGroove(cellFrame, NSZeroRect);
[controlView unlockFocus];
break; break;
case NSImageFrameButton: case NSImageFrameButton:
[controlView lockFocus];
NSDrawButton(cellFrame, NSZeroRect); NSDrawButton(cellFrame, NSZeroRect);
[controlView unlockFocus];
break; break;
} }
@ -294,13 +286,10 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
position.y += imageSize.height; position.y += imageSize.height;
// draw! // draw!
[controlView lockFocus];
[_cell_image compositeToPoint: position operation: NSCompositeSourceOver]; [_cell_image compositeToPoint: position operation: NSCompositeSourceOver];
if (_cell.shows_first_responder) if (_cell.shows_first_responder)
NSDottedFrameRect(cellFrame); NSDottedFrameRect(cellFrame);
[controlView unlockFocus];
} }
- (NSSize) cellSize - (NSSize) cellSize

View file

@ -940,9 +940,11 @@ static SEL getSel;
[aCell setState: NSOffState]; [aCell setState: NSOffState];
if (isHighlighted) if (isHighlighted)
[self highlightCell: NO atRow: i column: j]; {
else [aCell setHighlighted: NO];
[self drawCellAtRow: i column: j]; }
[self setNeedsDisplayInRect: [self cellFrameAtRow: i
column: j]];
} }
} }
} }
@ -1066,7 +1068,8 @@ static SEL getSel;
&& (lastRow != row || lastColumn != column) && (lastRow != row || lastColumn != column)
&& [self window] != nil) && [self window] != nil)
{ {
[self drawCellAtRow: lastRow column: lastColumn]; [self setNeedsDisplayInRect: [self cellFrameAtRow: lastRow
column: lastColumn]];
} }
} }
@ -1234,7 +1237,8 @@ static SEL getSel;
lastDottedRow = _dottedRow; lastDottedRow = _dottedRow;
lastDottedColumn = _dottedColumn; lastDottedColumn = _dottedColumn;
[self drawCellAtRow: lastDottedRow column: lastDottedColumn]; [self setNeedsDisplayInRect: [self cellFrameAtRow: lastDottedRow
column: lastDottedColumn]];
} }
_selectedRow = _dottedRow = end.y; _selectedRow = _dottedRow = end.y;
@ -1258,7 +1262,8 @@ static SEL getSel;
} }
if (drawLast) if (drawLast)
[self drawCellAtRow: _dottedRow column: _dottedColumn]; [self setNeedsDisplayInRect: [self cellFrameAtRow: _dottedRow
column: _dottedColumn]];
} }
- (id) cellAtRow: (int)row - (id) cellAtRow: (int)row
@ -1860,17 +1865,13 @@ static SEL getSel;
if (_drawsCellBackground) if (_drawsCellBackground)
{ {
[self lockFocus];
[_cellBackgroundColor set]; [_cellBackgroundColor set];
NSRectFill(cellFrame); NSRectFill(cellFrame);
[self unlockFocus];
} }
else else
{ {
[self lockFocus];
[_backgroundColor set]; [_backgroundColor set];
NSRectFill(cellFrame); NSRectFill(cellFrame);
[self unlockFocus];
} }
if (_dottedRow == row && _dottedColumn == column if (_dottedRow == row && _dottedColumn == column
@ -1897,13 +1898,12 @@ static SEL getSel;
if (aCell) if (aCell)
{ {
NSRect cellFrame = [self cellFrameAtRow: row column: column]; NSRect cellFrame = [self cellFrameAtRow: row column: column];
[self lockFocus];
if (_drawsCellBackground) if (_drawsCellBackground)
{ {
[self lockFocus];
[_cellBackgroundColor set]; [_cellBackgroundColor set];
NSRectFill(cellFrame); NSRectFill(cellFrame);
[self unlockFocus];
} }
if (_dottedRow != -1 && _dottedColumn != -1 if (_dottedRow != -1 && _dottedColumn != -1
@ -1922,6 +1922,8 @@ static SEL getSel;
if (_dottedRow != -1 && _dottedColumn != -1) if (_dottedRow != -1 && _dottedColumn != -1)
[_cells[_dottedRow][_dottedColumn] setShowsFirstResponder: NO]; [_cells[_dottedRow][_dottedColumn] setShowsFirstResponder: NO];
[self unlockFocus];
} }
} }
@ -2059,6 +2061,8 @@ static SEL getSel;
if ([mouseCell isEnabled]) if ([mouseCell isEnabled])
{ {
[self lockFocus];
if ([mouseCell acceptsFirstResponder]) if ([mouseCell acceptsFirstResponder])
{ {
NSCell *aCell = [self cellAtRow: _dottedRow NSCell *aCell = [self cellAtRow: _dottedRow
@ -2096,11 +2100,17 @@ static SEL getSel;
[self highlightCell: YES [self highlightCell: YES
atRow: highlightedRow atRow: highlightedRow
column: highlightedColumn]; column: highlightedColumn];
[_window flushWindow];
} }
if (_mode == NSRadioModeMatrix) if (_mode == NSRadioModeMatrix)
[mouseCell setState: NSOffState]; {
[mouseCell setState: NSOffState];
[self drawCell: _selectedCell];
}
[self unlockFocus];
[_window flushWindow];
mouseUpInCell = [mouseCell trackMouse: theEvent mouseUpInCell = [mouseCell trackMouse: theEvent
inRect: mouseCellFrame inRect: mouseCellFrame
@ -2119,10 +2129,11 @@ static SEL getSel;
highlightedCell = nil; highlightedCell = nil;
[self lockFocus];
[self highlightCell: NO [self highlightCell: NO
atRow: highlightedRow atRow: highlightedRow
column: highlightedColumn]; column: highlightedColumn];
[_window flushWindow]; [self unlockFocus];
} }
if (!mouseUpInCell) if (!mouseUpInCell)
@ -2151,7 +2162,9 @@ static SEL getSel;
if ([_selectedCell state]) if ([_selectedCell state])
{ {
[_selectedCell setState: NSOffState]; [_selectedCell setState: NSOffState];
[self lockFocus];
[self drawCell: _selectedCell]; [self drawCell: _selectedCell];
[self unlockFocus];
} }
_selectedCells[_selectedRow][_selectedColumn] = NO; _selectedCells[_selectedRow][_selectedColumn] = NO;
@ -2253,7 +2266,9 @@ static SEL getSel;
if ((_mode == NSRadioModeMatrix) && _selectedCell != nil) if ((_mode == NSRadioModeMatrix) && _selectedCell != nil)
{ {
[_selectedCell setState: NSOffState]; [_selectedCell setState: NSOffState];
[self lockFocus];
[self drawCellAtRow: _selectedRow column: _selectedColumn]; [self drawCellAtRow: _selectedRow column: _selectedColumn];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
_selectedCells[_selectedRow][_selectedColumn] = NO; _selectedCells[_selectedRow][_selectedColumn] = NO;
_selectedCell = nil; _selectedCell = nil;
@ -2369,8 +2384,6 @@ static SEL getSel;
highlight: YES]; highlight: YES];
} }
[_window flushWindow];
previousCell = aCell; previousCell = aCell;
previousRect = rect; previousRect = rect;
} }
@ -2409,7 +2422,6 @@ static SEL getSel;
} }
[self setNeedsDisplayInRect: rect]; [self setNeedsDisplayInRect: rect];
[_window flushWindow];
[NSEvent stopPeriodicEvents]; [NSEvent stopPeriodicEvents];
@ -2451,10 +2463,13 @@ static SEL getSel;
int oldSelectedColumn = _selectedColumn; int oldSelectedColumn = _selectedColumn;
_selectedCell = aCell; _selectedCell = aCell;
[self lockFocus];
[self highlightCell: YES atRow: i column: j]; [self highlightCell: YES atRow: i column: j];
[_window flushWindow];
[aCell setNextState]; [aCell setNextState];
[self sendAction]; [self sendAction];
[self highlightCell: NO atRow: i column: j]; [self highlightCell: NO atRow: i column: j];
[self unlockFocus];
_selectedCell = oldSelectedCell; _selectedCell = oldSelectedCell;
_selectedRow = oldSelectedRow; _selectedRow = oldSelectedRow;
_selectedColumn = oldSelectedColumn; _selectedColumn = oldSelectedColumn;
@ -2986,25 +3001,14 @@ static SEL getSel;
{ {
if (_selectedCell) if (_selectedCell)
{ {
if (_mode == NSRadioModeMatrix) [self deselectAllCells];
{
NSCell *aCell = _selectedCell;
[aCell setState: NSOffState];
_selectedCells[_selectedRow][_selectedColumn] = NO;
_selectedRow = _selectedColumn = -1;
_selectedCell = nil;
[self drawCell: aCell];
}
else
[self deselectAllCells];
} }
[self selectCellAtRow: _dottedRow column: _dottedColumn]; [self selectCellAtRow: _dottedRow column: _dottedColumn];
} }
else else
[self drawCellAtRow: _dottedRow column: _dottedColumn]; [self setNeedsDisplayInRect: [self cellFrameAtRow: _dottedRow
column: _dottedColumn]];
} }
else else
{ {
@ -3080,6 +3084,8 @@ static SEL getSel;
{ {
if (_mode == NSRadioModeMatrix) if (_mode == NSRadioModeMatrix)
{ {
/* FIXME */
/*
NSCell *aCell = _cells[lastDottedRow][lastDottedColumn]; NSCell *aCell = _cells[lastDottedRow][lastDottedColumn];
BOOL isHighlighted = [aCell isHighlighted]; BOOL isHighlighted = [aCell isHighlighted];
@ -3097,6 +3103,7 @@ static SEL getSel;
else else
[self drawCell: aCell]; [self drawCell: aCell];
} }
*/
} }
else else
[self deselectAllCells]; [self deselectAllCells];
@ -3105,17 +3112,17 @@ static SEL getSel;
} }
else else
{ {
[self drawCell: _cells[lastDottedRow][lastDottedColumn]]; [self setNeedsDisplayInRect: [self cellFrameAtRow: lastDottedRow
[self drawCell: _cells[_dottedRow][_dottedColumn]]; column: lastDottedColumn]];
[self setNeedsDisplayInRect: [self cellFrameAtRow: _dottedRow
column: _dottedColumn]];
} }
} }
[_window flushWindow];
if (selectCell) if (selectCell)
{ {
[self displayIfNeeded];
[self performClick: self]; [self performClick: self];
[_window flushWindow];
} }
} }
@ -3206,8 +3213,10 @@ static SEL getSel;
} }
} }
[self lockFocus];
[self drawCell: _cells[lastDottedRow][_dottedColumn]]; [self drawCell: _cells[lastDottedRow][_dottedColumn]];
[self drawCell: _cells[_dottedRow][_dottedColumn]]; [self drawCell: _cells[_dottedRow][_dottedColumn]];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
[self performClick: self]; [self performClick: self];
@ -3252,6 +3261,7 @@ static SEL getSel;
anchor: INDEX_FROM_COORDS(_selectedRow, _selectedColumn) anchor: INDEX_FROM_COORDS(_selectedRow, _selectedColumn)
highlight: YES]; highlight: YES];
[self displayIfNeeded];
[self performClick: self]; [self performClick: self];
} }
@ -3290,7 +3300,8 @@ static SEL getSel;
cell = _cells[_dottedRow][_dottedColumn]; cell = _cells[_dottedRow][_dottedColumn];
[cell setNextState]; [cell setNextState];
[self drawCell: cell]; [self setNeedsDisplayInRect: [self cellFrameAtRow: _dottedRow
column: _dottedColumn]];
break; break;
case NSListModeMatrix: case NSListModeMatrix:
@ -3302,7 +3313,7 @@ static SEL getSel;
break; break;
} }
[_window flushWindow]; [self displayIfNeeded];
[self performClick: self]; [self performClick: self];
} }
return; return;
@ -3637,11 +3648,9 @@ static SEL getSel;
_selectedCells[i][j] = YES; _selectedCells[i][j] = YES;
[aCell setCellAttribute: NSCellHighlighted to: highlight]; [aCell setCellAttribute: NSCellHighlighted to: highlight];
[self drawCell: aCell]; [self setNeedsDisplayInRect: [self cellFrameAtRow: i column: j]];
} }
} }
[_window flushWindow];
} }
// Return YES on success; NO if no selectable cell found. // Return YES on success; NO if no selectable cell found.
@ -3732,10 +3741,8 @@ static SEL getSel;
// (this method is only called by drawRect:) // (this method is only called by drawRect:)
if (_drawsCellBackground) if (_drawsCellBackground)
{ {
[self lockFocus];
[_cellBackgroundColor set]; [_cellBackgroundColor set];
NSRectFill(cellFrame); NSRectFill(cellFrame);
[self unlockFocus];
} }
if (_dottedRow == row && _dottedColumn == column if (_dottedRow == row && _dottedColumn == column

View file

@ -369,8 +369,6 @@ static NSImage *arrowImageH = nil;
if (!_cell.is_bordered) if (!_cell.is_bordered)
return; return;
[controlView lockFocus];
if (_cell.is_highlighted && (_highlightsByMask & NSPushInCellMask)) if (_cell.is_highlighted && (_highlightsByMask & NSPushInCellMask))
{ {
NSDrawGrayBezel(cellFrame, NSZeroRect); NSDrawGrayBezel(cellFrame, NSZeroRect);
@ -379,8 +377,6 @@ static NSImage *arrowImageH = nil;
{ {
NSDrawButton(cellFrame, NSZeroRect); NSDrawButton(cellFrame, NSZeroRect);
} }
[controlView unlockFocus];
} }
- (void) drawImageWithFrame: (NSRect)cellFrame - (void) drawImageWithFrame: (NSRect)cellFrame
@ -538,7 +534,6 @@ static NSImage *arrowImageH = nil;
return; return;
cellFrame = [self drawingRectForBounds: cellFrame]; cellFrame = [self drawingRectForBounds: cellFrame];
[controlView lockFocus];
if (_cell.is_highlighted) if (_cell.is_highlighted)
{ {
@ -618,7 +613,6 @@ static NSImage *arrowImageH = nil;
if (_keyEquivalentWidth > 0) if (_keyEquivalentWidth > 0)
[self drawKeyEquivalentWithFrame: cellFrame inView: controlView]; [self drawKeyEquivalentWithFrame: cellFrame inView: controlView];
[controlView unlockFocus];
_backgroundColor = nil; _backgroundColor = nil;
} }

View file

@ -1675,6 +1675,8 @@ static NSImage *unexpandable = nil;
// move the drawing rect over like in the drawRow routine... // move the drawing rect over like in the drawRow routine...
drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex]; drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex];
[self lockFocus];
if(tb == [self outlineTableColumn]) if(tb == [self outlineTableColumn])
{ {
level = [self levelForItem: item]; level = [self levelForItem: item];
@ -1718,7 +1720,9 @@ static NSImage *unexpandable = nil;
delegate: self delegate: self
event: theEvent]; event: theEvent];
} }
return;
[self unlockFocus];
return;
} }
@end /* implementation of NSOutlineView */ @end /* implementation of NSOutlineView */

View file

@ -534,15 +534,11 @@ static NSImage *_pbc_image[2];
if (_buttoncell_is_transparent) if (_buttoncell_is_transparent)
return; return;
[view lockFocus];
cellFrame = [self drawingRectForBounds: cellFrame]; cellFrame = [self drawingRectForBounds: cellFrame];
if (_cell.shows_first_responder if (_cell.shows_first_responder
&& [[view window] firstResponder] == view) && [[view window] firstResponder] == view)
NSDottedFrameRect(cellFrame); NSDottedFrameRect(cellFrame);
[view unlockFocus];
} }
/* FIXME: this method needs to be rewritten to be something like /* FIXME: this method needs to be rewritten to be something like

View file

@ -677,6 +677,8 @@ static NSColor *scrollBarColor = nil;
id theCell = nil; id theCell = nil;
NSRect rect; NSRect rect;
[self lockFocus];
NSDebugLog (@"trackScrollButtons"); NSDebugLog (@"trackScrollButtons");
do do
{ {
@ -740,6 +742,8 @@ static NSColor *scrollBarColor = nil;
} }
while ([theEvent type] != NSLeftMouseUp); while ([theEvent type] != NSLeftMouseUp);
[self unlockFocus];
NSDebugLog (@"return from trackScrollButtons"); NSDebugLog (@"return from trackScrollButtons");
} }

View file

@ -369,6 +369,8 @@ static Class cellClass;
[NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05]; [NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05];
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode]; [[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
[self lockFocus];
while (eventType != NSLeftMouseUp) while (eventType != NSLeftMouseUp)
{ {
theEvent = [app nextEventMatchingMask: eventMask theEvent = [app nextEventMatchingMask: eventMask
@ -407,6 +409,7 @@ static Class cellClass;
} }
} }
} }
[self unlockFocus];
// If the control is not continuous send the action at the end of the drag // If the control is not continuous send the action at the end of the drag
if (!isContinuous) if (!isContinuous)
{ {
@ -439,7 +442,9 @@ static Class cellClass;
{ {
[self sendAction: [_cell action] to: [_cell target]]; [self sendAction: [_cell action] to: [_cell target]];
} }
[self lockFocus];
[_cell drawWithFrame: _bounds inView: self]; [_cell drawWithFrame: _bounds inView: self];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
} }

View file

@ -173,7 +173,6 @@
cellFrame = [self drawingRectForBounds: cellFrame]; cellFrame = [self drawingRectForBounds: cellFrame];
[controlView lockFocus];
if (vertical != _isVertical) if (vertical != _isVertical)
{ {
if (vertical == YES) if (vertical == YES)
@ -205,7 +204,6 @@
} }
[self drawKnob]; [self drawKnob];
[controlView unlockFocus];
} }
- (BOOL) isOpaque - (BOOL) isOpaque

View file

@ -203,6 +203,7 @@ id _nsstepperCellClass = nil;
return; return;
} }
[self lockFocus];
{ {
BOOL overButton = YES; BOOL overButton = YES;
int ignore = 3; int ignore = 3;
@ -298,6 +299,7 @@ id _nsstepperCellClass = nil;
[_window flushWindow]; [_window flushWindow];
[_window _releaseMouse: self]; [_window _releaseMouse: self];
} }
[self unlockFocus];
} }
- (void)_increment - (void)_increment

View file

@ -253,7 +253,6 @@ inline void HighlightDownButton(NSRect aRect)
NSRect downRect; NSRect downRect;
NSRect twoButtons; NSRect twoButtons;
NSGraphicsContext *ctxt; NSGraphicsContext *ctxt;
[controlView lockFocus];
ctxt = GSCurrentContext(); ctxt = GSCurrentContext();
{ {
@ -283,8 +282,6 @@ inline void HighlightDownButton(NSRect aRect)
up_sides, grays, 2); up_sides, grays, 2);
} }
} }
[controlView unlockFocus];
} }
- (void) highlight: (BOOL) highlight - (void) highlight: (BOOL) highlight
@ -295,7 +292,6 @@ inline void HighlightDownButton(NSRect aRect)
NSRect upRect; NSRect upRect;
NSRect downRect; NSRect downRect;
NSGraphicsContext *ctxt; NSGraphicsContext *ctxt;
[controlView lockFocus];
ctxt = GSCurrentContext(); ctxt = GSCurrentContext();
{ {
upRect = [self upButtonRectWithFrame: frame]; upRect = [self upButtonRectWithFrame: frame];
@ -317,7 +313,6 @@ inline void HighlightDownButton(NSRect aRect)
DrawDownButton(downRect); DrawDownButton(downRect);
} }
} }
[controlView unlockFocus];
} }
- (NSRect) upButtonRectWithFrame: (NSRect) frame - (NSRect) upButtonRectWithFrame: (NSRect) frame

View file

@ -69,7 +69,6 @@ static NSColor *clearCol = nil;
NSRect rect; NSRect rect;
NSGraphicsContext *ctxt; NSGraphicsContext *ctxt;
[controlView lockFocus];
ctxt = GSCurrentContext(); ctxt = GSCurrentContext();
if (GSWViewIsFlipped(ctxt) == YES) if (GSWViewIsFlipped(ctxt) == YES)
@ -86,7 +85,6 @@ static NSColor *clearCol = nil;
DPSsetgray(ctxt, NSLightGray); DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect), DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect)); NSWidth(rect), NSHeight(rect));
[controlView unlockFocus];
} }
else else
{ {
@ -99,7 +97,6 @@ static NSColor *clearCol = nil;
NSRect rect; NSRect rect;
NSGraphicsContext *ctxt; NSGraphicsContext *ctxt;
[controlView lockFocus];
ctxt = GSCurrentContext(); ctxt = GSCurrentContext();
if (GSWViewIsFlipped(ctxt) == YES) if (GSWViewIsFlipped(ctxt) == YES)
@ -116,7 +113,6 @@ static NSColor *clearCol = nil;
DPSsetgray(ctxt, NSDarkGray); DPSsetgray(ctxt, NSDarkGray);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect), DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect)); NSWidth(rect), NSHeight(rect));
[controlView unlockFocus];
} }
[self drawInteriorWithFrame: cellFrame inView: controlView]; [self drawInteriorWithFrame: cellFrame inView: controlView];
} }
@ -158,7 +154,6 @@ static NSColor *clearCol = nil;
} }
// Prepare to draw // Prepare to draw
cellFrame = [self drawingRectForBounds: cellFrame]; cellFrame = [self drawingRectForBounds: cellFrame];
[controlView lockFocus];
// Deal with the background // Deal with the background
if ([self isOpaque]) if ([self isOpaque])
{ {
@ -192,7 +187,6 @@ static NSColor *clearCol = nil;
[_cell_image compositeToPoint: position operation: NSCompositeCopy]; [_cell_image compositeToPoint: position operation: NSCompositeCopy];
} }
// End the drawing // End the drawing
[controlView unlockFocus];
break; break;
case NSNullCellType: case NSNullCellType:

View file

@ -239,13 +239,11 @@
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSGraphicsContext *ctxt = GSCurrentContext();
[self lockFocus];
DPSsetgray(ctxt, NSBlack); DPSsetgray(ctxt, NSBlack);
DPSrectfill(ctxt,_bounds.origin.x, _bounds.origin.y, DPSrectfill(ctxt,_bounds.origin.x, _bounds.origin.y,
_bounds.size.width, 1.); _bounds.size.width, 1.);
DPSrectfill(ctxt, NSMaxX(_bounds)-1., NSMinY(_bounds), DPSrectfill(ctxt, NSMaxX(_bounds)-1., NSMinY(_bounds),
1., _bounds.size.height); 1., _bounds.size.height);
[self unlockFocus];
} }
} }
@ -519,10 +517,12 @@
rect.size.height--; rect.size.height--;
[[currentColumn headerCell] setHighlighted: YES]; [[currentColumn headerCell] setHighlighted: YES];
[self lockFocus];
[[currentColumn headerCell] [[currentColumn headerCell]
highlight: YES highlight: YES
withFrame: rect withFrame: rect
inView: self]; inView: self];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
} }
@ -755,10 +755,12 @@
[[currentColumn headerCell] [[currentColumn headerCell]
setHighlighted: NO]; setHighlighted: NO];
[self lockFocus];
[[currentColumn headerCell] [[currentColumn headerCell]
highlight: NO highlight: NO
withFrame: rect withFrame: rect
inView: self]; inView: self];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
} }
if (i > columnIndex) if (i > columnIndex)
@ -810,10 +812,12 @@
[[currentColumn headerCell] [[currentColumn headerCell]
setHighlighted: NO]; setHighlighted: NO];
[self lockFocus];
[[currentColumn headerCell] [[currentColumn headerCell]
highlight: NO highlight: NO
withFrame: rect withFrame: rect
inView: self]; inView: self];
[self unlockFocus];
[_window flushWindow]; [_window flushWindow];
} }

View file

@ -161,10 +161,8 @@ static NSColor *txtCol;
{ {
if (_textfieldcell_draws_background) if (_textfieldcell_draws_background)
{ {
[controlView lockFocus];
[_background_color set]; [_background_color set];
NSRectFill ([self drawingRectForBounds: cellFrame]); NSRectFill ([self drawingRectForBounds: cellFrame]);
[controlView unlockFocus];
} }
[super drawInteriorWithFrame: cellFrame inView: controlView]; [super drawInteriorWithFrame: cellFrame inView: controlView];
} }

View file

@ -324,9 +324,8 @@ static NSCell *tileCell = nil;
{ {
[imageCell setImage: anImage]; [imageCell setImage: anImage];
} }
if (_window != nil) if ([self lockFocusIfCanDraw])
{ {
[self lockFocus];
[self drawRect: [self bounds]]; [self drawRect: [self bounds]];
[self unlockFocus]; [self unlockFocus];
[_window flushWindow]; [_window flushWindow];
@ -351,9 +350,8 @@ static NSCell *tileCell = nil;
{ {
[titleCell setStringValue: aString]; [titleCell setStringValue: aString];
} }
if (_window != nil) if ([self lockFocusIfCanDraw])
{ {
[self lockFocus];
[self drawRect: [self bounds]]; [self drawRect: [self bounds]];
[self unlockFocus]; [self unlockFocus];
[_window flushWindow]; [_window flushWindow];