summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-27 17:49:25 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-03-27 17:49:25 +0000
commitc097ddf59e0e7da60f3980fa0b5b9472a52ba071 (patch)
treebbb39ef22868ad8916b946a2ecdc46ac25dba33f /riscos
parentdbeeea572c4e03d7d6c99b7d8a4d34b91f85166b (diff)
downloadnetsurf-c097ddf59e0e7da60f3980fa0b5b9472a52ba071.tar.gz
netsurf-c097ddf59e0e7da60f3980fa0b5b9472a52ba071.tar.bz2
Permit aliasing of pointers to wimp_window_state and wimp_open.
svn path=/trunk/netsurf/; revision=6944
Diffstat (limited to 'riscos')
-rw-r--r--riscos/wimputils.h38
-rw-r--r--riscos/window.c18
2 files changed, 48 insertions, 8 deletions
diff --git a/riscos/wimputils.h b/riscos/wimputils.h
new file mode 100644
index 000000000..5a6349b9f
--- /dev/null
+++ b/riscos/wimputils.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * A collection of grubby utilities for working with OSLib's wimp API.
+ */
+
+#ifndef riscos_wimputils_h_
+#define riscos_wimputils_h_
+
+#include <oslib/wimp.h>
+
+/* Magical union for working around strict aliasing
+ * Do not use this directly. Use the macros, instead. */
+typedef union window_open_state {
+ wimp_window_state state;
+ wimp_open open;
+} window_open_state;
+
+/* Convert a pointer to a wimp_window_state into a pointer to a wimp_open */
+#define PTR_WIMP_OPEN(pstate) ((wimp_open *) (window_open_state *) (pstate))
+
+#endif
diff --git a/riscos/window.c b/riscos/window.c
index d28789868..a4a0e3e2e 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -66,6 +66,7 @@
#include "riscos/url_complete.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
+#include "riscos/wimputils.h"
#include "utils/log.h"
#include "utils/talloc.h"
#include "utils/url.h"
@@ -388,14 +389,15 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
state.next = wimp_TOP;
if (bw->parent) {
top = browser_window_owner(bw);
- error = xwimp_open_window_nested((wimp_open *)&state, top->window->window,
+ error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state),
+ top->window->window,
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_XORIGIN_SHIFT |
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_YORIGIN_SHIFT);
}
- ro_gui_window_open((wimp_open*)&state);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
/* Claim the caret for top-level windows */
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
@@ -676,7 +678,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
state.yscroll = -sy * 2 * g->bw->scale;
if (g->toolbar)
state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
- ro_gui_window_open((wimp_open *)&state);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
}
@@ -760,7 +762,7 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int
state.xscroll = cx0;
state.yscroll = -cy0 + toolbar_height;
- ro_gui_window_open((wimp_open *)&state);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
}
@@ -854,7 +856,7 @@ void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int
state.visible.x1 = px0 + x1;
state.visible.y1 = py1 - y0 * 2 * scale;
g->update_extent = true;
- ro_gui_window_open((wimp_open *)&state);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
}
@@ -914,7 +916,7 @@ void gui_window_update_extent(struct gui_window *g)
flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
update = g->bw->reformat_pending;
g->update_extent = true;
- ro_gui_window_open((wimp_open *)&state);
+ ro_gui_window_open(PTR_WIMP_OPEN(&state));
state.w = g->window;
error = xwimp_get_window_state(&state);
@@ -1896,7 +1898,7 @@ void ro_gui_window_open(wimp_open *open)
}
/* first resize stops any flickering by making the URL window on top */
- ro_gui_url_complete_resize(g, (wimp_open *)&state);
+ ro_gui_url_complete_resize(g, PTR_WIMP_OPEN(&state));
error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
if (error) {
@@ -2617,7 +2619,7 @@ bool ro_gui_window_keypress(wimp_key *key)
break;
}
- error = xwimp_open_window((wimp_open *) &state);
+ error = xwimp_open_window(PTR_WIMP_OPEN(&state));
if (error) {
LOG(("xwimp_open_window: 0x%x: %s",
error->errnum, error->errmess));