mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-22 02:12:10 +03:00
[project @ 2003-09-10 21:44:10 by bursa]
Reformat page when browser window is resized. svn path=/import/netsurf/; revision=280
This commit is contained in:
parent
9c2e649290
commit
f33b3e6f52
@ -257,6 +257,7 @@ void content_reformat(struct content *c, unsigned long width, unsigned long heig
|
||||
c->status == CONTENT_STATUS_DONE);
|
||||
c->available_width = width;
|
||||
handler_map[c->type].reformat(c, width, height);
|
||||
content_broadcast(c, CONTENT_MSG_REFORMAT, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,8 @@ typedef enum {
|
||||
CONTENT_MSG_DONE, /**< finished */
|
||||
CONTENT_MSG_ERROR, /**< error occurred */
|
||||
CONTENT_MSG_STATUS, /**< new status string */
|
||||
CONTENT_MSG_REDIRECT /**< replacement URL */
|
||||
CONTENT_MSG_REDIRECT, /**< replacement URL */
|
||||
CONTENT_MSG_REFORMAT /**< content_reformat done */
|
||||
} content_msg;
|
||||
|
||||
/** Linked list of users of a content. */
|
||||
|
@ -356,6 +356,11 @@ void browser_window_callback(content_msg msg, struct content *c,
|
||||
browser_window_open_location(bw, error);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_REFORMAT:
|
||||
if (bw->current_content->status == CONTENT_STATUS_DONE)
|
||||
browser_window_reformat(bw, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@ -389,6 +394,9 @@ void download_window_callback(content_msg msg, struct content *c,
|
||||
/* not possible at this point, handled above */
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_REFORMAT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,6 +468,9 @@ void html_object_callback(content_msg msg, struct content *object,
|
||||
c->active++;
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_REFORMAT:
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
49
riscos/gui.c
49
riscos/gui.c
@ -89,8 +89,7 @@ static void ro_gui_keypress(wimp_key* key);
|
||||
static void ro_msg_datasave(wimp_message* block);
|
||||
static void ro_msg_dataload(wimp_message* block);
|
||||
static void gui_set_gadget_extent(struct box* box, int x, int y, os_box* extent, struct gui_gadget* g);
|
||||
|
||||
|
||||
static void ro_gui_screen_size(int *width, int *height);
|
||||
|
||||
|
||||
|
||||
@ -232,6 +231,8 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
|
||||
}
|
||||
|
||||
g->redraw_safety = SAFE;
|
||||
g->data.browser.reformat_pending = false;
|
||||
g->data.browser.old_width = 0;
|
||||
|
||||
g->next = window_list;
|
||||
window_list = g;
|
||||
@ -470,16 +471,26 @@ void ro_gui_window_open(gui_window* g, wimp_open* open)
|
||||
{
|
||||
if (g->type == GUI_BROWSER_WINDOW)
|
||||
{
|
||||
wimp_window_state state;
|
||||
state.w = g->data.browser.window;
|
||||
wimp_get_window_state(&state);
|
||||
if (state.flags & wimp_WINDOW_TOGGLED) {
|
||||
open->visible.x0 = open->visible.y0 = 0;
|
||||
ro_gui_screen_size(&open->visible.x1, &open->visible.y1);
|
||||
}
|
||||
|
||||
if (g->data.browser.bw->current_content != 0) {
|
||||
if (g->old_width != open->visible.x1 - open->visible.x0) {
|
||||
if (g->data.browser.bw->current_content->width
|
||||
< browser_x_units(open->visible.x1 - open->visible.x0))
|
||||
gui_window_set_extent(g, browser_x_units(open->visible.x1 - open->visible.x0),
|
||||
int width = open->visible.x1 - open->visible.x0;
|
||||
if (g->data.browser.old_width != width) {
|
||||
if (g->data.browser.bw->current_content->width
|
||||
< browser_x_units(width))
|
||||
gui_window_set_extent(g, browser_x_units(width),
|
||||
g->data.browser.bw->current_content->height);
|
||||
else
|
||||
gui_window_set_extent(g, g->data.browser.bw->current_content->width,
|
||||
g->data.browser.bw->current_content->height);
|
||||
g->old_width = open->visible.x1 - open->visible.x0;
|
||||
g->data.browser.old_width = width;
|
||||
g->data.browser.reformat_pending = true;
|
||||
}
|
||||
}
|
||||
wimp_open_window(open);
|
||||
@ -1446,6 +1457,13 @@ void gui_poll(void)
|
||||
wimp_get_pointer_info(&pointer);
|
||||
ro_gui_window_mouse_at(&pointer);
|
||||
}
|
||||
for (g = window_list; g; g = g->next) {
|
||||
if (g->type == GUI_BROWSER_WINDOW && g->data.browser.reformat_pending) {
|
||||
content_reformat(g->data.browser.bw->current_content,
|
||||
browser_x_units(g->data.browser.old_width), 1000);
|
||||
g->data.browser.reformat_pending = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case wimp_REDRAW_WINDOW_REQUEST :
|
||||
@ -1919,3 +1937,20 @@ void gui_remove_gadget(struct gui_gadget* g)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find screen size in OS units.
|
||||
*/
|
||||
|
||||
void ro_gui_screen_size(int *width, int *height)
|
||||
{
|
||||
int xeig_factor, yeig_factor, xwind_limit, ywind_limit;
|
||||
|
||||
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XEIG_FACTOR, &xeig_factor);
|
||||
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YEIG_FACTOR, &yeig_factor);
|
||||
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XWIND_LIMIT, &xwind_limit);
|
||||
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YWIND_LIMIT, &ywind_limit);
|
||||
*width = (xwind_limit + 1) << xeig_factor;
|
||||
*height = (ywind_limit + 1) << yeig_factor;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef _NETSURF_RISCOS_GUI_H_
|
||||
#define _NETSURF_RISCOS_GUI_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "oslib/wimp.h"
|
||||
#include "netsurf/desktop/browser.h"
|
||||
#include "netsurf/desktop/netsurf.h"
|
||||
@ -36,6 +37,8 @@ struct gui_window
|
||||
wimp_w toolbar;
|
||||
int toolbar_width;
|
||||
struct browser_window* bw;
|
||||
bool reformat_pending;
|
||||
int old_width;
|
||||
} browser;
|
||||
struct {
|
||||
wimp_w window;
|
||||
@ -56,7 +59,6 @@ struct gui_window
|
||||
|
||||
gui_safety redraw_safety;
|
||||
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status;
|
||||
int old_width;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user