summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-28 14:08:42 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-28 14:08:42 +0000
commit3ba2596f5c5c82af5c342359e29e9f65160f4f56 (patch)
treeeec2ccca2d3bf9d4201587c37ce19b2bde2415e7
parentf56b20994ea693d36b2bcc8c99942f50e1fd6814 (diff)
downloadnetsurf-3ba2596f5c5c82af5c342359e29e9f65160f4f56.tar.gz
netsurf-3ba2596f5c5c82af5c342359e29e9f65160f4f56.tar.bz2
Implemented frames and handling reformats the right way using browser_reformat_pending.
svn path=/trunk/netsurf/; revision=11518
-rw-r--r--cocoa/BrowserView.h4
-rw-r--r--cocoa/BrowserView.m16
-rw-r--r--cocoa/gui.m37
3 files changed, 39 insertions, 18 deletions
diff --git a/cocoa/BrowserView.h b/cocoa/BrowserView.h
index 6d6466af0..aa62e7ada 100644
--- a/cocoa/BrowserView.h
+++ b/cocoa/BrowserView.h
@@ -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
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index d5e8d0aff..fd7c938db 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -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
diff --git a/cocoa/gui.m b/cocoa/gui.m
index fdaa379ef..517489f33 100644
--- a/cocoa/gui.m
+++ b/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,13 +94,22 @@ 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,