summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2004-06-27 14:41:14 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2004-06-27 14:41:14 +0000
commit50e0ebf3fa1fa09603371d81b971f5f95331ecd2 (patch)
treedbacc563d47e7b6ac7440fba12f2d61861ac2f64 /riscos
parentafceb17b80b04a8f98676d430d0b87c6ac66c4eb (diff)
downloadnetsurf-50e0ebf3fa1fa09603371d81b971f5f95331ecd2.tar.gz
netsurf-50e0ebf3fa1fa09603371d81b971f5f95331ecd2.tar.bz2
[project @ 2004-06-27 14:41:14 by rjw]
Improved window positioning svn path=/import/netsurf/; revision=1018
Diffstat (limited to 'riscos')
-rw-r--r--riscos/dialog.c12
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/options.h3
-rw-r--r--riscos/window.c96
4 files changed, 86 insertions, 26 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c
index ff531a305..a33d5fd1a 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -261,9 +261,7 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
get_browser_choices();
get_proxy_choices();
get_theme_choices();
- xosfile_create_dir("<Choices$Write>.WWW", 0);
- xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
- options_write("<Choices$Write>.WWW.NetSurf.Choices");
+ ro_gui_save_options();
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(dialog_config_br);
ro_gui_dialog_close(dialog_config_prox);
@@ -294,6 +292,14 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
}
}
+/**
+ * Save the current options
+ */
+void ro_gui_save_options(void) {
+ xosfile_create_dir("<Choices$Write>.WWW", 0);
+ xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
+ options_write("<Choices$Write>.WWW.NetSurf.Choices");
+}
/**
* Handle clicks in the Browser Choices dialog.
diff --git a/riscos/gui.h b/riscos/gui.h
index 0eb366e5b..d8e07e79f 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -125,6 +125,7 @@ wimp_w ro_gui_dialog_create(const char *template_name);
wimp_window * ro_gui_dialog_load_template(const char *template_name);
void ro_gui_dialog_open(wimp_w w);
void ro_gui_dialog_click(wimp_pointer *pointer);
+void ro_gui_save_options(void);
bool ro_gui_dialog_keypress(wimp_key *key);
void ro_gui_dialog_close(wimp_w close);
void ro_gui_redraw_config_th_pane(wimp_draw *redraw);
diff --git a/riscos/options.h b/riscos/options.h
index bb00506ff..fc9401563 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -39,6 +39,7 @@ extern int option_window_width;
extern int option_window_height;
extern int option_window_screen_width;
extern int option_window_screen_height;
+extern bool option_window_stagger;
extern int option_minimum_gif_delay;
extern bool option_background_images;
extern bool option_background_blending;
@@ -67,6 +68,7 @@ int option_window_width = 0; \
int option_window_height = 0; \
int option_window_screen_width = 0; \
int option_window_screen_height = 0; \
+bool option_window_stagger = true; \
int option_minimum_gif_delay = 10; \
bool option_background_images = true; \
bool option_background_blending = false;
@@ -95,6 +97,7 @@ bool option_background_blending = false;
{ "window_height", OPTION_INTEGER, &option_window_height }, \
{ "window_screen_width", OPTION_INTEGER, &option_window_screen_width }, \
{ "window_screen_height", OPTION_INTEGER, &option_window_screen_height }, \
+{ "window_stagger", OPTION_BOOL, &option_window_stagger }, \
{ "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay }, \
{ "background_images", OPTION_BOOL, &option_background_images }, \
{ "background_blending", OPTION_BOOL, &option_background_blending }
diff --git a/riscos/window.c b/riscos/window.c
index 698382284..c309226cd 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -52,6 +52,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
wimp_window window;
wimp_window_state state;
os_error *error;
+ bool open_centred = true;
gui_window *g = malloc(sizeof *g);
if (!g) {
@@ -70,18 +71,53 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
g->throbber = 0;
g->throbtime = 0;
- ro_gui_screen_size(&screen_width, &screen_height);
-
- win_width = screen_width * 3 / 4;
- if (1600 < win_width)
- win_width = 1600;
- win_height = win_width * 3 / 4;
-
- window.visible.x0 = (screen_width - win_width) / 2;
- window.visible.y0 = ((screen_height - win_height) / 2) + 96 -
- (48 * (window_count % 5));
- window.visible.x1 = window.visible.x0 + win_width;
- window.visible.y1 = window.visible.y0 + win_height;
+ /* Set the window position
+ */
+ if (clone && clone->window) {
+ state.w = clone->window->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+ window.visible.x0 = state.visible.x0;
+ window.visible.x1 = state.visible.x1;
+ window.visible.y0 = state.visible.y0 - 48;
+ window.visible.y1 = state.visible.y1 - 48;
+ open_centred = false;
+ } else {
+ ro_gui_screen_size(&screen_width, &screen_height);
+
+ /* Check if we have a preferred position
+ */
+ if ((option_window_screen_width != 0) && (option_window_screen_height != 0)) {
+ win_width = (option_window_width * screen_width) / option_window_screen_width;
+ win_height = (option_window_height * screen_height) / option_window_screen_height;
+ window.visible.x0 = (option_window_x * screen_width) / option_window_screen_width;
+ window.visible.y0 = (option_window_y * screen_height) / option_window_screen_height;
+ if (option_window_stagger) {
+ window.visible.y0 += 96 - (48 * (window_count % 5));
+ }
+ open_centred = false;
+ if (100 < win_width) win_width = 100;
+ if (100 < win_height) win_height = 100;
+ } else {
+ win_width = screen_width * 3 / 4;
+ if (1600 < win_width)
+ win_width = 1600;
+ win_height = win_width * 3 / 4;
+
+ window.visible.x0 = (screen_width - win_width) / 2;
+ window.visible.y0 = ((screen_height - win_height) / 2) + 96 -
+ (48 * (window_count % 5));
+ }
+ window.visible.x1 = window.visible.x0 + win_width;
+ window.visible.y1 = window.visible.y0 + win_height;
+ }
+
+ /* Set the general window characteristics
+ */
window.xscroll = 0;
window.yscroll = 0;
window.next = wimp_TOP;
@@ -106,8 +142,8 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
window.highlight_bg = wimp_COLOUR_CREAM;
window.extra_flags = 0;
window.extent.x0 = 0;
- window.extent.y0 = win_height;
- window.extent.x1 = win_width;
+ window.extent.y0 = window.visible.y1 - window.visible.y0;
+ window.extent.x1 = window.visible.x1 - window.visible.x0;
window.extent.y1 = 0;
window.title_flags = wimp_ICON_TEXT |
wimp_ICON_INDIRECTED |
@@ -152,8 +188,16 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
warn_user("WimpError", error->errmess);
return g;
}
- scroll_width = ro_get_vscroll_width(g->window);
- state.visible.x0 -= scroll_width;
+
+ /* Only fix the centralisation if we've opened the window centred
+ */
+ if (open_centred) {
+ scroll_width = ro_get_vscroll_width(g->window);
+ state.visible.x0 -= scroll_width;
+ }
+
+ /* Open the window at the top of the stack
+ */
state.next = wimp_TOP;
ro_gui_window_open(g, (wimp_open*)&state);
@@ -460,6 +504,8 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) {
int toolbar_height = 0;
struct content *content;
wimp_window_state state;
+ bool toggle_hack = false;
+ int screen_height, screen_width;
if (g->type != GUI_BROWSER_WINDOW) {
wimp_open_window(open);
@@ -468,15 +514,21 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) {
content = g->data.browser.bw->current_content;
- /* check for toggle to full size */
+ /* check for toggle to full size - NOW FEATURING "TEMPORARY HACK" */
state.w = g->window;
wimp_get_window_state(&state);
if ((state.flags & wimp_WINDOW_TOGGLED) &&
(state.flags & wimp_WINDOW_BOUNDED_ONCE) &&
!(state.flags & wimp_WINDOW_FULL_SIZE)) {
- open->visible.y0 = 0;
- open->visible.y1 = 0x1000;
- height = 0x1000;
+ /* Check if we need to perform our hack
+ */
+ ro_gui_screen_size(&screen_width, &screen_height);
+ if ((content->height * 2 * g->scale) < screen_height) {
+ open->visible.y0 = 0;
+ open->visible.y1 = 0x1000;
+ height = 0x1000;
+ toggle_hack = true;
+ }
}
/* account for toolbar height, if present */
@@ -511,9 +563,7 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) {
wimp_open_window(open);
/* update extent to actual size if toggled */
- if ((state.flags & wimp_WINDOW_TOGGLED) &&
- (state.flags & wimp_WINDOW_BOUNDED_ONCE) &&
- !(state.flags & wimp_WINDOW_FULL_SIZE)) {
+ if (toggle_hack) {
width = open->visible.x1 - open->visible.x0;
height = open->visible.y1 - open->visible.y0 - toolbar_height;
if (content && (unsigned int)height <