Implemented frames and handling reformats the right way using browser_reformat_pending.
svn path=/trunk/netsurf/; revision=11518
This commit is contained in:
parent
f56b20994e
commit
3ba2596f5c
|
@ -33,19 +33,17 @@
|
|||
BOOL isDragging;
|
||||
NSPoint dragStart;
|
||||
|
||||
BOOL isResizing;
|
||||
|
||||
HistoryView *history;
|
||||
BOOL historyVisible;
|
||||
}
|
||||
|
||||
@property (readwrite, assign, nonatomic) struct browser_window *browser;
|
||||
@property (readwrite, retain, nonatomic) NSTimer *caretTimer;
|
||||
@property (readwrite, assign, nonatomic, getter=isResizing) BOOL resizing;
|
||||
@property (readwrite, assign, nonatomic, getter=isHistoryVisible) BOOL historyVisible;
|
||||
|
||||
- (void) removeCaret;
|
||||
- (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
|
||||
|
||||
- (void) reformat;
|
||||
|
||||
@end
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
@synthesize browser;
|
||||
@synthesize caretTimer;
|
||||
@synthesize resizing = isResizing;
|
||||
|
||||
static const CGFloat CaretWidth = 1.0;
|
||||
static const NSTimeInterval CaretBlinkTime = 0.8;
|
||||
|
@ -377,11 +376,8 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
|
|||
|
||||
- (void) adjustFrame;
|
||||
{
|
||||
if (!isResizing) {
|
||||
NSSize frameSize = [[self superview] frame].size;
|
||||
browser_window_reformat( browser, cocoa_pt_to_px( frameSize.width ), cocoa_pt_to_px( frameSize.height ) );
|
||||
}
|
||||
|
||||
browser->reformat_pending = true;
|
||||
browser_reformat_pending = true;
|
||||
[super adjustFrame];
|
||||
}
|
||||
|
||||
|
@ -422,4 +418,12 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
|
|||
return NSHeight( [[self superview] frame] ) - [[self enclosingScrollView] pageScroll];
|
||||
}
|
||||
|
||||
- (void) reformat;
|
||||
{
|
||||
if (!browser->reformat_pending) return;
|
||||
|
||||
NSRect size = [[self superview] frame];
|
||||
browser_window_reformat( browser, cocoa_pt_to_px( NSWidth( size ) ), cocoa_pt_to_px( NSHeight( size ) ) );
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
37
cocoa/gui.m
37
cocoa/gui.m
|
@ -46,6 +46,8 @@ NSString * const kHotlistFileOption = @"Hotlist";
|
|||
NSString * const kHomepageURLOption = @"HomepageURL";
|
||||
NSString * const kOptionsFileOption = @"ClassicOptionsFile";
|
||||
|
||||
static NSMutableSet *cocoa_all_browser_views = nil;
|
||||
|
||||
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
|
||||
|
||||
void gui_multitask(void)
|
||||
|
@ -60,9 +62,15 @@ void gui_poll(bool active)
|
|||
NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: active ? nil : [NSDate distantFuture]
|
||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
||||
|
||||
if (nil != event) [NSApp sendEvent: event];
|
||||
if (nil != event) {
|
||||
[NSApp sendEvent: event];
|
||||
[NSApp updateWindows];
|
||||
}
|
||||
|
||||
[NSApp updateWindows];
|
||||
if (browser_reformat_pending) {
|
||||
[cocoa_all_browser_views makeObjectsPerformSelector: @selector( reformat )];
|
||||
browser_reformat_pending = false;
|
||||
}
|
||||
}
|
||||
|
||||
void gui_quit(void)
|
||||
|
@ -86,14 +94,23 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
BrowserViewController *result = [[BrowserViewController alloc] initWithBrowser: bw];
|
||||
|
||||
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
|
||||
if (bw->parent == NULL) {
|
||||
if (!new_tab || nil == window) {
|
||||
window = [[[BrowserWindowController alloc] init] autorelease];
|
||||
[[window window] makeKeyAndOrderFront: nil];
|
||||
}
|
||||
[window addTab: result];
|
||||
} else {
|
||||
BrowserViewController *parent = (BrowserViewController *)bw->parent->window;
|
||||
NSCParameterAssert( parent != nil );
|
||||
[[parent browserView] addSubview: [result view]];
|
||||
}
|
||||
|
||||
if (cocoa_all_browser_views == nil) {
|
||||
cocoa_all_browser_views = [[NSMutableSet alloc] init];
|
||||
}
|
||||
[cocoa_all_browser_views addObject: [result browserView]];
|
||||
|
||||
return (struct gui_window *)result;
|
||||
}
|
||||
|
||||
|
@ -104,7 +121,11 @@ struct browser_window *gui_window_get_browser_window(struct gui_window *g)
|
|||
|
||||
void gui_window_destroy(struct gui_window *g)
|
||||
{
|
||||
[(BrowserViewController *)g release];
|
||||
BrowserViewController *vc = (BrowserViewController *)g;
|
||||
|
||||
if ([vc browser]->parent != NULL) [[vc view] removeFromSuperview];
|
||||
[cocoa_all_browser_views removeObject: [vc browserView]];
|
||||
[vc release];
|
||||
}
|
||||
|
||||
void gui_window_set_title(struct gui_window *g, const char *title)
|
||||
|
@ -156,7 +177,8 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
|
|||
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
|
||||
int x1, int y1)
|
||||
{
|
||||
UNIMPL();
|
||||
const NSRect rect = cocoa_rect( x0, y0, x1, y1 );
|
||||
[[(BrowserViewController *)g view] setFrame: rect];
|
||||
}
|
||||
|
||||
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
||||
|
@ -182,9 +204,7 @@ void gui_window_update_extent(struct gui_window *g)
|
|||
int width = content_get_width( browser->current_content );
|
||||
int height = content_get_height( browser->current_content );
|
||||
|
||||
[[window browserView] setResizing: YES];
|
||||
[[window browserView] setMinimumSize: cocoa_scaled_size( browser->scale, width, height )];
|
||||
[[window browserView] setResizing: NO];
|
||||
}
|
||||
|
||||
void gui_window_set_status(struct gui_window *g, const char *text)
|
||||
|
@ -298,8 +318,7 @@ bool gui_window_box_scroll_start(struct gui_window *g,
|
|||
|
||||
bool gui_window_frame_resize_start(struct gui_window *g)
|
||||
{
|
||||
UNIMPL();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void gui_window_save_link(struct gui_window *g, const char *url,
|
||||
|
|
Loading…
Reference in New Issue