comparison mac/dw.m @ 1497:99a53823079f

On Mac lets just use the shown flag and not worry about the actual window position. The shown flag should get set in dw_window_set_pos() not _set_size().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 25 Dec 2011 06:58:53 +0000
parents cf960e266444
children f8b4d6075cac
comparison
equal deleted inserted replaced
1496:8b84b752a363 1497:99a53823079f
7590 if(rect.size.width <= 1 || rect.size.height <= 1) 7590 if(rect.size.width <= 1 || rect.size.height <= 1)
7591 { 7591 {
7592 /* Determine the contents size */ 7592 /* Determine the contents size */
7593 dw_window_set_size(handle, 0, 0); 7593 dw_window_set_size(handle, 0, 0);
7594 } 7594 }
7595 /* If the position was not set... generate a default
7596 * default one in a similar pattern to SHELLPOSITION.
7597 */
7595 if(![window shown]) 7598 if(![window shown])
7596 { 7599 {
7600 static int defaultx = 0, defaulty = 0;
7601 int cx = dw_screen_width(), cy = dw_screen_height();
7602 int maxx = cx / 4, maxy = cy / 4;
7603 NSPoint point;
7604
7597 rect = [window frame]; 7605 rect = [window frame];
7598 7606
7599 /* If the position was not set... generate a default 7607 defaultx += 20;
7600 * default one in a similar pattern to SHELLPOSITION. 7608 defaulty += 20;
7601 */ 7609 if(defaultx > maxx)
7602 if(rect.origin.x <= 1 && rect.origin.y <= 1) 7610 defaultx = 20;
7603 { 7611 if(defaulty > maxy)
7604 static int defaultx = 0, defaulty; 7612 defaulty = 20;
7605 int cx = dw_screen_width(), cy = dw_screen_height(); 7613
7606 int maxx = cx / 4, maxy = cy / 4; 7614 point.x = defaultx;
7607 NSPoint point; 7615 /* Take into account menu bar and inverted Y */
7608 7616 point.y = cy - defaulty - (int)rect.size.height - 22;
7609 defaultx += 20; 7617
7610 defaulty += 20; 7618 [window setFrameOrigin:point];
7611 if(defaultx > maxx)
7612 defaultx = 20;
7613 if(defaulty > maxy)
7614 defaulty = 20;
7615
7616 point.x = defaultx;
7617 /* Take into account menu bar and inverted Y */
7618 point.y = cy - defaulty - (int)rect.size.height - 20;
7619
7620 [window setFrameOrigin:point];
7621 }
7622 [window setShown:YES]; 7619 [window setShown:YES];
7623 } 7620 }
7624 [[window contentView] showWindow]; 7621 [[window contentView] showWindow];
7625 [window makeKeyAndOrderFront:nil]; 7622 [window makeKeyAndOrderFront:nil];
7626 } 7623 }
8499 if(height < 1) content.size.height = thisbox->minheight; 8496 if(height < 1) content.size.height = thisbox->minheight;
8500 } 8497 }
8501 8498
8502 /* Finally set the size */ 8499 /* Finally set the size */
8503 [window setContentSize:content.size]; 8500 [window setContentSize:content.size];
8504 /* Size set manually... don't auto-position */
8505 [window setShown:YES];
8506 } 8501 }
8507 DW_MUTEX_UNLOCK; 8502 DW_MUTEX_UNLOCK;
8508 } 8503 }
8509 8504
8510 /* 8505 /*
8594 { 8589 {
8595 int _locked_by_me = FALSE; 8590 int _locked_by_me = FALSE;
8596 DW_MUTEX_LOCK; 8591 DW_MUTEX_LOCK;
8597 NSObject *object = handle; 8592 NSObject *object = handle;
8598 8593
8599 if([ object isKindOfClass:[ NSWindow class ] ]) 8594 if([ object isMemberOfClass:[ DWWindow class ] ])
8600 { 8595 {
8601 NSWindow *window = handle; 8596 DWWindow *window = handle;
8602 NSPoint point; 8597 NSPoint point;
8603 NSSize size = [window frame].size; 8598 NSSize size = [window frame].size;
8604 8599
8605 _handle_gravity(handle, &x, &y, (unsigned long)size.width, (unsigned long)size.height); 8600 _handle_gravity(handle, &x, &y, (unsigned long)size.width, (unsigned long)size.height);
8606 8601
8607 point.x = x; 8602 point.x = x;
8608 point.y = y; 8603 point.y = y;
8609 8604
8610 [window setFrameOrigin:point]; 8605 [window setFrameOrigin:point];
8606 /* Position set manually... don't auto-position */
8607 [window setShown:YES];
8611 } 8608 }
8612 DW_MUTEX_UNLOCK; 8609 DW_MUTEX_UNLOCK;
8613 } 8610 }
8614 8611
8615 /* 8612 /*