Tk Source Code

Check-in [91a8d730]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refinement of redraw during window resizing in Cocoa; refinement of button display
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 91a8d7308bc0838174fda5fa95bcdd9b29f9fc55
User & Date: kevin_walzer 2014-12-28 05:24:34
Context
2014-12-31
21:26
Reduce redraw issues during window zoom events on Cocoa check-in: 6ef1af44 user: kevin_walzer tags: trunk
2014-12-28
05:24
Refinement of redraw during window resizing in Cocoa; refinement of button display check-in: 91a8d730 user: kevin_walzer tags: trunk
2014-12-24
09:17
merge-mark check-in: 66f4565d user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXButton.c.

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
		int parent_height = Tk_Height(Tk_Parent(tkwin));
		int widget_height = Tk_Height(tkwin);
		int y = Tk_Y(tkwin);
		if ( y > parent_height - 20 || y + widget_height < 0 ) {
		    return;
		}

	    /* Do not draw if the widget is completely outside of its parent, or within 50 pixels of the right border; this prevents buttons from being drawn on peer widgets as scrolling occurs. */
		int parent_width = Tk_Width(Tk_Parent(tkwin));
		int widget_width = Tk_Width(tkwin);
		int x = Tk_X(tkwin);
		if (x > parent_width - 50 || x < 0) {
		    return;
		}
	    }

	[super drawRect:dirtyRect];
    }
 }

@end









|



|



>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
		int parent_height = Tk_Height(Tk_Parent(tkwin));
		int widget_height = Tk_Height(tkwin);
		int y = Tk_Y(tkwin);
		if ( y > parent_height - 20 || y + widget_height < 0 ) {
		    return;
		}

	    /* Do not draw if the widget is completely outside of its parent, or within 20 pixels of the right border; this prevents buttons from being drawn on peer widgets as scrolling occurs. */
		int parent_width = Tk_Width(Tk_Parent(tkwin));
		int widget_width = Tk_Width(tkwin);
		int x = Tk_X(tkwin);
		if (x > parent_width - 20 || x < 0) {
		    return;
		}
	    }
	    
	[super drawRect:dirtyRect];
    }
 }

@end


Changes to macosx/tkMacOSXWindowEvent.c.

813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839







840
841
842
843
844
845
846
847

848
849

850
851
852
853
854
855


856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873

874
875
876
877
878
879
880

 	    
    CGFloat height = [self bounds].size.height;
    HIMutableShapeRef drawShape = HIShapeCreateMutable();

    while (rectsBeingDrawnCount--) {
	CGRect r = NSRectToCGRect(*rectsBeingDrawn++);

	r.origin.y = height - (r.origin.y + r.size.height);
	HIShapeUnionWithRect(drawShape, &r);
    }
    if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
	[self generateExposeEvents:drawShape];
    } else {
	[self performSelectorOnMainThread:@selector(generateExposeEvents:)
		withObject:(id)drawShape waitUntilDone:NO
		modes:[NSArray arrayWithObjects:NSRunLoopCommonModes,
			NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode,
			nil]];
    }
   
    CFRelease(drawShape);
  
}


/*Provide more fine-grained control over resizing of content to reduce flicker after removal of private API's.*/








- (BOOL) preservesContentDuringLiveResize
{
    return YES;
}

- (void)viewWillStartLiveResize
{

  [super viewWillStartLiveResize];
  [self setNeedsDisplay:NO];

}


- (void)viewDidEndLiveResize
{



    [self setNeedsDisplay:YES];
    [super setNeedsDisplay:YES];
    [super viewDidEndLiveResize];
     
}


/*Core function of this class, generates expose events for redrawing.*/
- (void) generateExposeEvents: (HIMutableShapeRef) shape
{

    TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
    unsigned long serial;
    CGRect updateBounds;

    if (!winPtr) {
		return;
    }


    HIShapeGetBounds(shape, &updateBounds);
    serial = LastKnownRequestProcessed(Tk_Display(winPtr));
    if (GenerateUpdates(shape, &updateBounds, winPtr) &&
	![[NSRunLoop currentRunLoop] currentMode] &&
	Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
    	/*







<



















>
>
>
>
>
>
>








>


>






>
>





<












>







813
814
815
816
817
818
819

820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870

871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890

 	    
    CGFloat height = [self bounds].size.height;
    HIMutableShapeRef drawShape = HIShapeCreateMutable();

    while (rectsBeingDrawnCount--) {
	CGRect r = NSRectToCGRect(*rectsBeingDrawn++);

	r.origin.y = height - (r.origin.y + r.size.height);
	HIShapeUnionWithRect(drawShape, &r);
    }
    if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
	[self generateExposeEvents:drawShape];
    } else {
	[self performSelectorOnMainThread:@selector(generateExposeEvents:)
		withObject:(id)drawShape waitUntilDone:NO
		modes:[NSArray arrayWithObjects:NSRunLoopCommonModes,
			NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode,
			nil]];
    }
   
    CFRelease(drawShape);
  
}


/*Provide more fine-grained control over resizing of content to reduce flicker after removal of private API's.*/

-(void) viewWillDraw
{

        [super viewWillDraw];
}


- (BOOL) preservesContentDuringLiveResize
{
    return YES;
}

- (void)viewWillStartLiveResize
{
  NSDisableScreenUpdates();
  [super viewWillStartLiveResize];
  [self setNeedsDisplay:NO];
  [self setHidden:YES];
}


- (void)viewDidEndLiveResize
{

    NSEnableScreenUpdates();
    [self setHidden:NO];
    [self setNeedsDisplay:YES];
    [super setNeedsDisplay:YES];
    [super viewDidEndLiveResize];
     
}


/*Core function of this class, generates expose events for redrawing.*/
- (void) generateExposeEvents: (HIMutableShapeRef) shape
{

    TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
    unsigned long serial;
    CGRect updateBounds;

    if (!winPtr) {
		return;
    }


    HIShapeGetBounds(shape, &updateBounds);
    serial = LastKnownRequestProcessed(Tk_Display(winPtr));
    if (GenerateUpdates(shape, &updateBounds, winPtr) &&
	![[NSRunLoop currentRunLoop] currentMode] &&
	Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
    	/*
892
893
894
895
896
897
898

899
900
901
902
903
904
905
    	ClientData oldArg;
    	Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc,
						     UINT2PTR(serial), &oldArg);

    	while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}

    	Tk_RestrictEvents(oldProc, oldArg, &oldArg);

    	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}

    }

}

/*This is no-op on 10.7 and up because Apple has removed this widget, but leaving here for backwards compatibility.*/







>







902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
    	ClientData oldArg;
    	Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc,
						     UINT2PTR(serial), &oldArg);

    	while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}

    	Tk_RestrictEvents(oldProc, oldArg, &oldArg);

    	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}

    }

}

/*This is no-op on 10.7 and up because Apple has removed this widget, but leaving here for backwards compatibility.*/