summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/amiga/corewindow.c77
-rw-r--r--frontends/amiga/corewindow.h2
-rw-r--r--frontends/amiga/gui.c19
-rw-r--r--frontends/amiga/gui.h7
4 files changed, 87 insertions, 18 deletions
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index a42f08d17..c7252b549 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -50,6 +50,7 @@
#include <classes/window.h>
#include <gadgets/scroller.h>
+#include <gadgets/space.h>
#include <intuition/icclass.h>
#include <reaction/reaction_macros.h>
@@ -57,6 +58,37 @@
#include "amiga/misc.h"
#include "amiga/object.h"
+/* get current mouse position in the draw area, adjusted for scroll */
+static void
+ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *x, int *y)
+{
+ ULONG xs, ys;
+ ULONG xm, ym;
+
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ GetAttr(SPACE_MouseX, ami_cw->objects[GID_CW_DRAW], (ULONG *)&xm);
+ GetAttr(SPACE_MouseY, ami_cw->objects[GID_CW_DRAW], (ULONG *)&ym);
+ *x = xm + xs;
+ *y = ym + ys;
+}
+
+/* handle keypress */
+static void
+ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
+{
+ ami_cw->key(ami_cw, nskey);
+
+ switch(nskey) {
+ case NS_KEY_COPY_SELECTION:
+ /* if we've copied a selection we need to clear it - style guide rules */
+ ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
+ break;
+
+ /* we may need to deal with scroll-related keys here */
+ }
+}
+
static void
ami_cw_close(void *w)
{
@@ -67,17 +99,23 @@ ami_cw_close(void *w)
HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
{
- ULONG gid;
struct ami_corewindow *ami_cw = hook->h_Data;
struct IntuiWheelData *wheel;
+ ULONG gid = GetTagData( GA_ID, 0, msg->IAddress );
+ int x, y;
+ int key_state = 0;
switch(msg->Class)
{
case IDCMP_IDCMPUPDATE:
- gid = GetTagData( GA_ID, 0, msg->IAddress );
+ switch(gid)
+ {
+ case GID_CW_DRAW:
+ ami_cw_mouse_pos(ami_cw, &x, &y);
+ key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ break;
- switch( gid )
- {
case GID_CW_HSCROLL:
case GID_CW_VSCROLL:
/* redraw */
@@ -97,6 +135,7 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
}
}
+
/**
* Main event loop for our core window
*
@@ -116,6 +155,7 @@ ami_cw_event(void *w)
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
switch(result & WMHI_CLASSMASK) {
case WMHI_MOUSEMOVE:
+ /* in theory the mouse moves we care about are processed in our hook function... */
break;
case WMHI_MOUSEBUTTONS:
@@ -126,11 +166,8 @@ ami_cw_event(void *w)
GetAttr(WINDOW_InputEvent, ami_cw->objects[GID_CW_WIN], (ULONG *)&ie);
nskey = ami_key_to_nskey(storage, ie);
- ami_cw->key(ami_cw, nskey);
- if(nskey == NS_KEY_COPY_SELECTION) {
- /* if we've copied a selection we need to clear it - style guide rules */
- ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
- }
+
+ ami_cw_key(ami_cw, nskey);
break;
case WMHI_NEWSIZE:
@@ -142,9 +179,24 @@ ami_cw_event(void *w)
return TRUE;
break;
+ case WMHI_GADGETUP:
+ switch(result & WMHI_GADGETMASK) {
+ case GID_CW_HSCROLL:
+ case GID_CW_VSCROLL:
+ /* redraw */
+ break;
+
+ default:
+ /* pass the event to the window owner */
+ if(ami_cw->event != NULL)
+ ami_cw->event(ami_cw, result);
+ break;
+ }
+
default:
/* pass the event to the window owner */
- ami_cw->event(ami_cw, result);
+ if(ami_cw->event != NULL)
+ ami_cw->event(ami_cw, result);
break;
}
};
@@ -274,6 +326,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
/* setup the core window callback table */
ami_cw->cb_table = &ami_cw_cb_table;
+ /* clear some vars */
+ ami_cw->mouse_state = 0;
+
/* allocate drawing area etc */
ami_init_layers(&ami_cw->gg, 0, 0, false);
ami_cw->gg.shared_pens = ami_AllocMinList();
@@ -289,7 +344,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
TAG_DONE); */
- /* attach the scrollbars for event processing if they are in the window border */
+ /* attach the scrollbars for event processing _if they are in the window border_ */
if(ami_cw->objects[GID_CW_HSCROLL] == NULL) {
GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
(ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 3c27e5126..fae5658d3 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -50,6 +50,8 @@ struct ami_corewindow {
Object *objects[GID_CW_LAST];
struct Hook idcmp_hook;
+ struct timeval lastclick;
+ int mouse_state;
/** stuff for our off-screen render bitmap */
struct gui_globals gg;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index ba0a786e3..46961dd0f 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1376,27 +1376,34 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
return nskey;
}
-static void ami_update_quals(struct gui_window_2 *gwin)
+int ami_gui_get_quals(Object *win_obj)
{
uint32 quals = 0;
+ int key_state = 0;
#ifdef __amigaos4__
- GetAttr(WINDOW_Qualifier,gwin->objects[OID_MAIN],(uint32 *)&quals);
+ GetAttr(WINDOW_Qualifier, win_obj, (uint32 *)&quals);
#else
#warning qualifier needs fixing for OS3
#endif
- gwin->key_state = 0;
if(quals & NSA_QUAL_SHIFT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_1;
+ key_state |= BROWSER_MOUSE_MOD_1;
}
if(quals & IEQUALIFIER_CONTROL) {
- gwin->key_state |= BROWSER_MOUSE_MOD_2;
+ key_state |= BROWSER_MOUSE_MOD_2;
}
if(quals & NSA_QUAL_ALT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_3;
+ key_state |= BROWSER_MOUSE_MOD_3;
}
+
+ return key_state;
+}
+
+static void ami_update_quals(struct gui_window_2 *gwin)
+{
+ gwin->key_state = ami_gui_get_quals(gwin->objects[OID_MAIN]);
}
/* exported interface documented in amiga/gui.h */
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index eb39e9e47..f9e62c5d3 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -282,5 +282,10 @@ nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_tab
* Remove a window from the NetSurf window list
*/
void ami_gui_win_list_remove(void *win);
+
+/**
+ * Get which qualifier keys are being pressed
+ */
+int ami_gui_get_quals(Object *win_obj);
#endif