summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cocoa/BrowserView.m22
-rw-r--r--content/content.c18
-rw-r--r--desktop/browser.c26
-rw-r--r--desktop/browser.h28
-rw-r--r--framebuffer/gui.c10
-rw-r--r--gtk/window.c42
-rw-r--r--windows/gui.c73
7 files changed, 140 insertions, 79 deletions
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index 2951364ea..4e728c867 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -123,8 +123,6 @@ static inline NSRect cocoa_get_caret_rect( BrowserView *view )
- (void)drawRect:(NSRect)dirtyRect;
{
- if (NULL == browser->current_content) return;
-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
current_redraw_browser = browser;
@@ -137,19 +135,13 @@ static inline NSRect cocoa_get_caret_rect( BrowserView *view )
[self getRectsBeingDrawn: &rects count: &count];
for (NSInteger i = 0; i < count; i++) {
- plot.clip( NSMinX( rects[i] ), NSMinY( rects[i]), NSMaxX( rects[i] ), NSMaxY( rects[i] ) );
-
- content_redraw(browser->current_content,
- 0,
- 0,
- cocoa_pt_to_px( NSWidth( frame ) ),
- cocoa_pt_to_px( NSHeight( frame ) ),
- cocoa_pt_to_px( NSMinX( rects[i] ) ),
- cocoa_pt_to_px( NSMinY( rects[i] ) ),
- cocoa_pt_to_px( NSMaxX( rects[i] ) ),
- cocoa_pt_to_px( NSMaxY( rects[i] ) ),
- browser->scale,
- 0xFFFFFF);
+ browser_window_redraw(browser, 0, 0,
+ cocoa_pt_to_px( NSWidth( frame ) ),
+ cocoa_pt_to_px( NSHeight( frame ) ),
+ cocoa_pt_to_px( NSMinX( rects[i] ) ),
+ cocoa_pt_to_px( NSMinY( rects[i] ) ),
+ cocoa_pt_to_px( NSMaxX( rects[i] ) ),
+ cocoa_pt_to_px( NSMaxY( rects[i] ) ));
}
current_redraw_browser = NULL;
diff --git a/content/content.c b/content/content.c
index 040679d7e..e314e2314 100644
--- a/content/content.c
+++ b/content/content.c
@@ -901,15 +901,19 @@ bool content_redraw(hlcache_handle *h, int x, int y,
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
-// LOG(("%p %s", c, c->url));
- if (c->locked)
+
+ if (c->locked) {
/* not safe to attempt redraw */
return true;
- if (handler_map[c->type].redraw)
- return handler_map[c->type].redraw(c, x, y, width, height,
- clip_x0, clip_y0, clip_x1, clip_y1, scale,
- background_colour);
- return true;
+ }
+
+ if (handler_map[c->type].redraw == NULL) {
+ return true;
+ }
+
+ return handler_map[c->type].redraw(c, x, y, width, height,
+ clip_x0, clip_y0, clip_x1, clip_y1, scale,
+ background_colour);
}
diff --git a/desktop/browser.c b/desktop/browser.c
index d80886556..1ffc12e29 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -51,6 +51,8 @@
#include "desktop/options.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
+#include "desktop/plotters.h"
+
#include "render/form.h"
#include "render/html.h"
#include "render/textplain.h"
@@ -86,6 +88,30 @@ static void browser_window_find_target_internal(struct browser_window *bw,
const char *target, int depth, struct browser_window *page,
int *rdepth, struct browser_window **bw_target);
+/* exported interface, documented in browser.h */
+bool browser_window_redraw(struct browser_window *bw,
+ int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0,
+ int clip_x1, int clip_y1)
+{
+ if (bw == NULL) {
+ LOG(("NULL browser window"));
+ return false;
+ }
+
+ plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
+
+ if (bw->current_content == NULL) {
+ return plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white);
+
+ }
+
+ return content_redraw(bw->current_content, x, y, width, height,
+ clip_x0, clip_y0, clip_x1, clip_y1,
+ bw->scale, 0xFFFFFF);
+}
+
/**
* Create and open a new browser window with the given page.
*
diff --git a/desktop/browser.h b/desktop/browser.h
index c0a738a6e..2c16c9732 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -251,6 +251,34 @@ bool browser_window_forward_available(struct browser_window *bw);
bool browser_window_reload_available(struct browser_window *bw);
bool browser_window_stop_available(struct browser_window *bw);
+/**
+ * Redraw an area of a window
+ *
+ * Calls the redraw function for the content,
+ *
+ * \param bw The window to redraw
+ * \param x coordinate for top-left of redraw
+ * \param y coordinate for top-left of redraw
+ * \param width available width (not used for HTML redraw)
+ * \param height available height (not used for HTML redraw)
+ * \param clip_x0 clip rectangle left
+ * \param clip_y0 clip rectangle top
+ * \param clip_x1 clip rectangle right
+ * \param clip_y1 clip rectangle bottom
+ * \return true if successful, false otherwise
+ *
+ * x, y and clip_* are coordinates from the top left of the canvas area.
+ *
+ * The top left corner of the clip rectangle is (clip_x0, clip_y0) and
+ * the bottom right corner of the clip rectangle is (clip_x1, clip_y1).
+ * Units for x, y and clip_* are pixels.
+ */
+bool browser_window_redraw(struct browser_window *bw,
+ int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0,
+ int clip_x1, int clip_y1);
+
/* In platform specific hotlist.c. */
void hotlist_visited(struct hlcache_handle *c);
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index fa2ca2b66..f389d85d7 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -305,9 +305,6 @@ fb_redraw(fbtk_widget_t *widget,
int width;
int height;
- if (bw->current_content == NULL)
- return;
-
LOG(("%d,%d to %d,%d",
bwidget->redraw_box.x0,
bwidget->redraw_box.y0,
@@ -329,12 +326,13 @@ fb_redraw(fbtk_widget_t *widget,
/* redraw bounding box is relative to window */
current_redraw_browser = bw;
- content_redraw(bw->current_content,
+
+ browser_window_redraw(bw,
x - bwidget->scrollx, y - bwidget->scrolly,
width, height,
bwidget->redraw_box.x0, bwidget->redraw_box.y0,
- bwidget->redraw_box.x1, bwidget->redraw_box.y1,
- bw->scale, 0xFFFFFF);
+ bwidget->redraw_box.x1, bwidget->redraw_box.y1);
+
current_redraw_browser = NULL;
nsfb_update(fbtk_get_nsfb(widget), &bwidget->redraw_box);
diff --git a/gtk/window.c b/gtk/window.c
index 9934215c3..06bc97df0 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -156,25 +156,29 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
struct gui_window *g = data;
- hlcache_handle *c;
- float scale = g->bw->scale;
+ struct gui_window *z;
+ int width = 0;
+ int height = 0;
assert(g);
assert(g->bw);
- struct gui_window *z;
for (z = window_list; z && z != g; z = z->next)
continue;
assert(z);
assert(GTK_WIDGET(g->layout) == widget);
- c = g->bw->current_content;
- if (c == NULL)
- return FALSE;
+ /* set the width and height to use */
+ if (g->bw->current_content != NULL) {
+ width = content_get_width(g->bw->current_content);
+ height = content_get_height(g->bw->current_content);
- /* HTML rendering handles scale itself */
- if (content_get_type(c) == CONTENT_HTML)
- scale = 1;
+ if (content_get_type(g->bw->current_content) != CONTENT_HTML) {
+ /* HTML rendering handles scale itself */
+ width *= g->bw->scale;
+ height *= g->bw->scale;
+ }
+ }
current_widget = (GtkWidget *)g->layout;
current_drawable = g->layout->bin_window;
@@ -187,19 +191,11 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget,
nsgtk_plot_set_scale(g->bw->scale);
current_redraw_browser = g->bw;
- plot.clip(event->area.x,
- event->area.y,
- event->area.x + event->area.width,
- event->area.y + event->area.height);
-
- content_redraw(c, 0, 0,
- content_get_width(c) * scale,
- content_get_height(c) * scale,
- event->area.x,
- event->area.y,
+ browser_window_redraw(g->bw, 0, 0, width, height,
+ event->area.x, event->area.y,
event->area.x + event->area.width,
- event->area.y + event->area.height,
- g->bw->scale, 0xFFFFFF);
+ event->area.y + event->area.height);
+
current_redraw_browser = NULL;
if (g->careth != 0)
@@ -334,8 +330,8 @@ static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
if (g->mouse.state & (BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_CLICK_2)) {
- browser_window_mouse_click(g->bw, g->mouse.state,
- event->x / g->bw->scale,
+ browser_window_mouse_click(g->bw, g->mouse.state,
+ event->x / g->bw->scale,
event->y / g->bw->scale);
} else {
browser_window_mouse_drag_end(g->bw, 0, event->x / g->bw->scale,
diff --git a/windows/gui.c b/windows/gui.c
index 03f3d67ec..d5b31a82f 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -880,30 +880,20 @@ static LRESULT
nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
{
PAINTSTRUCT ps;
- HDC hdc, tmp_hdc;
- hdc = BeginPaint(hwnd, &ps);
+ plot_hdc = BeginPaint(hwnd, &ps);
- if ((gw != NULL) &&
- (gw->bw != NULL) &&
- (gw->bw->current_content != NULL)) {
- /* set global HDC for the plotters */
- tmp_hdc = hdc;
- plot_hdc = hdc;
-
- content_redraw(gw->bw->current_content,
- -gw->scrollx / gw->bw->scale,
- -gw->scrolly / gw->bw->scale,
- gw->width,
- gw->height,
- ps.rcPaint.left,
- ps.rcPaint.top,
- ps.rcPaint.right,
- ps.rcPaint.bottom,
- gw->bw->scale,
- 0xFFFFFF);
+ if (gw != NULL) {
+ browser_window_redraw(gw->bw,
+ -gw->scrollx / gw->bw->scale,
+ -gw->scrolly / gw->bw->scale,
+ gw->width,
+ gw->height,
+ ps.rcPaint.left,
+ ps.rcPaint.top,
+ ps.rcPaint.right,
+ ps.rcPaint.bottom);
- plot_hdc = tmp_hdc;
}
EndPaint(hwnd, &ps);
@@ -1683,6 +1673,22 @@ static HWND nsws_window_statusbar_create(struct gui_window *w)
return hwnd;
}
+static css_fixed get_window_dpi(HWND hwnd)
+{
+ HDC hdc = GetDC(hwnd);
+ int dpi = GetDeviceCaps(hdc, LOGPIXELSY);
+ css_fixed fix_dpi = INTTOFIX(96);
+
+ if (dpi > 10) {
+ fix_dpi = INTTOFIX(dpi);
+ }
+
+ ReleaseDC(hwnd, hdc);
+
+ LOG(("FIX DPI %x", fix_dpi));
+
+ return fix_dpi;
+}
/**
* creation of a new full browser window
@@ -1692,7 +1698,7 @@ static HWND nsws_window_create(struct gui_window *gw)
HWND hwnd;
INITCOMMONCONTROLSEX icc;
- LOG(("nsws_window_create %p", gw));
+ LOG(("GUI window %p", gw));
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
@@ -1718,16 +1724,20 @@ static HWND nsws_window_create(struct gui_window *gw)
hinstance,
NULL);
- HDC hdc = GetDC(hwnd);
- int dpi = GetDeviceCaps(hdc,LOGPIXELSY);
- if (dpi > 10)
- nscss_screen_dpi = INTTOFIX(dpi);
- ReleaseDC(hwnd, hdc);
+ if (hwnd == NULL) {
+ LOG(("Window create failed"));
+ return NULL;
+ }
+
+ nscss_screen_dpi = get_window_dpi(hwnd);
if ((option_window_width >= 100) &&
(option_window_height >= 100) &&
(option_window_x >= 0) &&
(option_window_y >= 0)) {
+ LOG(("Setting Window position %d,%d %d,%d",
+ option_window_x, option_window_y,
+ option_window_width, option_window_height));
SetWindowPos(hwnd, HWND_TOPMOST,
option_window_x, option_window_y,
option_window_width, option_window_height,
@@ -1751,10 +1761,13 @@ gui_create_browser_window(struct browser_window *bw,
{
struct gui_window *gw;
+ LOG(("Creating gui window for browser window %p", bw));
+
gw = calloc(1, sizeof(struct gui_window));
- if (gw == NULL)
+ if (gw == NULL) {
return NULL;
+ }
/* connect gui window to browser window */
gw->bw = bw;
@@ -1769,6 +1782,7 @@ gui_create_browser_window(struct browser_window *bw,
gw->mouse = malloc(sizeof(struct browser_mouse));
if (gw->mouse == NULL) {
free(gw);
+ LOG(("Unable to allocate mouse state"));
return NULL;
}
gw->mouse->gui = gw;
@@ -1795,6 +1809,8 @@ gui_create_browser_window(struct browser_window *bw,
NULL,
hinstance,
NULL);
+ LOG(("BROWSER_WINDOW_NORMAL: main:%p toolbar:%p statusbar %p drawingarea %p", gw->main, gw->toolbar, gw->statusbar, gw->drawingarea));
+
/* set the gui window associated with this toolbar */
SetProp(gw->drawingarea, TEXT("GuiWnd"), (HANDLE)gw);
@@ -1803,6 +1819,7 @@ gui_create_browser_window(struct browser_window *bw,
input_window = gw;
open_windows++;
ShowWindow(gw->main, SW_SHOWNORMAL);
+ ShowWindow(gw->drawingarea, SW_SHOWNORMAL);
break;