netsurf: branch master updated. 897acff532415ed81f9066b8b811ae744918da84
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/897acff532415ed81f906...
...commit http://git.netsurf-browser.org/netsurf.git/commit/897acff532415ed81f9066b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/897acff532415ed81f9066b8b...
The branch, master has been updated
via 897acff532415ed81f9066b8b811ae744918da84 (commit)
from 878fe3e68cbda4f3d51cce7bc3b0ffcc27135367 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/897acff532415ed81f9...
commit 897acff532415ed81f9066b8b811ae744918da84
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
make events work on elements
diff --git a/javascript/js.h b/javascript/js.h
index 643ce5a..44de4fe 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -26,6 +26,10 @@
typedef struct jscontext jscontext;
typedef struct jsobject jsobject;
+struct dom_document;
+struct dom_node;
+struct dom_string;
+
/** Initialise javascript interpreter */
void js_initialise(void);
@@ -51,10 +55,16 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
-struct dom_document;
-struct dom_node;
/* fire an event at a dom node */
bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
+bool
+js_dom_event_add_listener(jscontext *ctx,
+ struct dom_document *document,
+ struct dom_node *node,
+ struct dom_string *event_type_dom,
+ void *js_funcval);
+
+
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index e5b4ddf..eebb33f 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -32,7 +32,7 @@ void js_initialise(void)
/* Create a JS runtime. */
#if JS_VERSION >= 180
- JS_SetCStringsAreUTF8(); /* we prefer our runtime to be utf-8 */
+ JS_SetCStringsAreUTF8(); /* we prefer our runtime to be utf-8 */
#endif
rt = JS_NewRuntime(8L * 1024L * 1024L);
@@ -97,7 +97,7 @@ void js_destroycontext(jscontext *ctx)
*
* This performs the following actions
* 1. constructs a new global object by initialising a window class
- * 2. Instantiate the global a window object
+ * 2. Instantiate the global a window object
*/
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
{
@@ -116,7 +116,7 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
}
window = jsapi_new_Window(cx, window_proto, NULL, win_priv, doc_priv);
-
+
return (jsobject *)window;
}
@@ -139,9 +139,9 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
return false;
}
- if (JS_EvaluateScript(cx,
- JS_GetGlobalObject(cx),
- txt, txtlen,
+ if (JS_EvaluateScript(cx,
+ JS_GetGlobalObject(cx),
+ txt, txtlen,
"<head>", 0, &rval) == JS_TRUE) {
return true;
@@ -174,8 +174,8 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
JSLOG("Dispatching event %s at window", type);
/* create and initialise and event object */
- exc = dom_string_create((unsigned char*)type,
- strlen(type),
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
&type_dom);
if (exc != DOM_NO_ERR) {
return false;
@@ -200,18 +200,18 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
/* dispatch event at the window object */
argv[0] = OBJECT_TO_JSVAL(jsevent);
- ret = JS_CallFunctionName(cx,
- JS_GetGlobalObject(cx),
- "dispatchEvent",
- 1,
- argv,
+ ret = JS_CallFunctionName(cx,
+ JS_GetGlobalObject(cx),
+ "dispatchEvent",
+ 1,
+ argv,
&rval);
} else {
JSLOG("Dispatching event %s at %p", type, node);
/* create and initialise and event object */
- exc = dom_string_create((unsigned char*)type,
- strlen(type),
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
&type_dom);
if (exc != DOM_NO_ERR) {
return false;
@@ -237,3 +237,93 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
}
return false;
}
+
+struct js_dom_event_private {
+ JSContext *cx; /* javascript context */
+ jsval funcval; /* javascript function to call */
+ struct dom_node *node; /* dom node event listening on */
+ dom_string *type; /* event type */
+ dom_event_listener *listener; /* the listener containing this */
+};
+
+static void
+js_dom_event_listener(struct dom_event *event, void *pw)
+{
+ struct js_dom_event_private *private = pw;
+ jsval event_argv[1];
+ jsval event_rval;
+ JSObject *jsevent;
+
+ JSLOG("WOOT dom event with %p", private);
+
+ if (!JSVAL_IS_VOID(private->funcval)) {
+ jsevent = jsapi_new_Event(private->cx, NULL, NULL, event);
+ if (jsevent != NULL) {
+
+ /* dispatch event at the window object */
+ event_argv[0] = OBJECT_TO_JSVAL(jsevent);
+
+ JS_CallFunctionValue(private->cx,
+ NULL,
+ private->funcval,
+ 1,
+ event_argv,
+ &event_rval);
+ }
+ }
+}
+
+/* add a listener to a dom node
+ *
+ * 1. Create a dom_event_listener From a handle_event function pointer
+ * and a private word In a document context
+ *
+ * 2. Register for your events on a target (dom nodes are targets)
+ * dom_event_target_add_event_listener(node, evt_name, listener,
+ * capture_or_not)
+ *
+ */
+
+bool
+js_dom_event_add_listener(jscontext *ctx,
+ struct dom_document *document,
+ struct dom_node *node,
+ struct dom_string *event_type_dom,
+ void *js_funcval)
+{
+ JSContext *cx = (JSContext *)ctx;
+ dom_exception exc;
+ struct js_dom_event_private *private;
+
+ private = malloc(sizeof(struct js_dom_event_private));
+ if (private == NULL) {
+ return false;
+ }
+
+ exc = dom_event_listener_create(document,
+ js_dom_event_listener,
+ private,
+ &private->listener);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ private->cx = cx;
+ private->funcval = *(jsval *)js_funcval;
+ private->node = node;
+ private->type = event_type_dom;
+
+ JSLOG("adding %p to listener", private);
+
+ JS_AddValueRoot(cx, &private->funcval);
+ exc = dom_event_target_add_event_listener(private->node,
+ private->type,
+ private->listener,
+ true);
+ if (exc != DOM_NO_ERR) {
+ JSLOG("failed to add listener");
+ JS_RemoveValueRoot(cx, &private->funcval);
+ }
+
+ return true;
+}
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 15fe83e..e1bd2c8 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -23,7 +23,9 @@ preamble %{
#include "utils/config.h"
#include "utils/log.h"
+#include "utils/corestrings.h"
+#include "javascript/js.h"
#include "javascript/jsapi.h"
#include "javascript/jsapi/binding.h"
@@ -218,24 +220,248 @@ getter childElementCount %{
%}
getter EventHandler %{
- JSLOG("propname[%d]=\"%s\"",
+ JSLOG("propname[%d].name=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
%}
+
setter EventHandler %{
- JSLOG("propname[%d]=\"%s\"",
- tinyid,
+ dom_string *event_type_dom;
+
+ JSLOG("propname[%d].name=\"%s\"",
+ tinyid,
jsclass_properties[tinyid].name);
-/*
-1. Create a dom_event_listener From a handle_event function pointer
- and a private word In a document context
+ switch (tinyid) {
+ case JSAPI_PROP_TINYID_onabort:
+ event_type_dom = corestring_dom_abort;
+ break;
-2. Register for your events on a target (dom nodes are targets)
- dom_event_target_add_event_listener(node, evt_name, listener,
- capture_or_not)
+ case JSAPI_PROP_TINYID_onblur:
+ event_type_dom = corestring_dom_blur;
+ break;
- */
+ case JSAPI_PROP_TINYID_oncancel:
+ event_type_dom = corestring_dom_cancel;
+ break;
+
+ case JSAPI_PROP_TINYID_oncanplay:
+ event_type_dom = corestring_dom_canplay;
+ break;
+
+ case JSAPI_PROP_TINYID_oncanplaythrough:
+ event_type_dom = corestring_dom_canplaythrough;
+ break;
+
+ case JSAPI_PROP_TINYID_onchange:
+ event_type_dom = corestring_dom_change;
+ break;
+
+ case JSAPI_PROP_TINYID_onclick:
+ event_type_dom = corestring_dom_click;
+ break;
+
+ case JSAPI_PROP_TINYID_onclose:
+ event_type_dom = corestring_dom_close;
+ break;
+
+ case JSAPI_PROP_TINYID_oncontextmenu:
+ event_type_dom = corestring_dom_contextmenu;
+ break;
+
+ case JSAPI_PROP_TINYID_oncuechange:
+ event_type_dom = corestring_dom_cuechange;
+ break;
+
+ case JSAPI_PROP_TINYID_ondblclick:
+ event_type_dom = corestring_dom_dblclick;
+ break;
+
+ case JSAPI_PROP_TINYID_ondrag:
+ event_type_dom = corestring_dom_drag;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragend:
+ event_type_dom = corestring_dom_dragend;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragenter:
+ event_type_dom = corestring_dom_dragenter;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragleave:
+ event_type_dom = corestring_dom_dragleave;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragover:
+ event_type_dom = corestring_dom_dragover;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragstart:
+ event_type_dom = corestring_dom_dragstart;
+ break;
+
+ case JSAPI_PROP_TINYID_ondrop:
+ event_type_dom = corestring_dom_drop;
+ break;
+
+ case JSAPI_PROP_TINYID_ondurationchange:
+ event_type_dom = corestring_dom_durationchange;
+ break;
+
+ case JSAPI_PROP_TINYID_onemptied:
+ event_type_dom = corestring_dom_emptied;
+ break;
+
+ case JSAPI_PROP_TINYID_onended:
+ event_type_dom = corestring_dom_ended;
+ break;
+
+ case JSAPI_PROP_TINYID_onerror:
+ event_type_dom = corestring_dom_error;
+ break;
+
+ case JSAPI_PROP_TINYID_onfocus:
+ event_type_dom = corestring_dom_focus;
+ break;
+
+ case JSAPI_PROP_TINYID_oninput:
+ event_type_dom = corestring_dom_input;
+ break;
+
+ case JSAPI_PROP_TINYID_oninvalid:
+ event_type_dom = corestring_dom_invalid;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeydown:
+ event_type_dom = corestring_dom_keydown;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeypress:
+ event_type_dom = corestring_dom_keypress;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeyup:
+ event_type_dom = corestring_dom_keyup;
+ break;
+
+ case JSAPI_PROP_TINYID_onload:
+ event_type_dom = corestring_dom_load;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadeddata:
+ event_type_dom = corestring_dom_loadeddata;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadedmetadata:
+ event_type_dom = corestring_dom_loadedmetadata;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadstart:
+ event_type_dom = corestring_dom_loadstart;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousedown:
+ event_type_dom = corestring_dom_mousedown;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousemove:
+ event_type_dom = corestring_dom_mousemove;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseout:
+ event_type_dom = corestring_dom_mouseout;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseover:
+ event_type_dom = corestring_dom_mouseover;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseup:
+ event_type_dom = corestring_dom_mouseup;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousewheel:
+ event_type_dom = corestring_dom_mousewheel;
+ break;
+
+ case JSAPI_PROP_TINYID_onpause:
+ event_type_dom = corestring_dom_pause;
+ break;
+
+ case JSAPI_PROP_TINYID_onplay:
+ event_type_dom = corestring_dom_play;
+ break;
+
+ case JSAPI_PROP_TINYID_onplaying:
+ event_type_dom = corestring_dom_playing;
+ break;
+
+ case JSAPI_PROP_TINYID_onprogress:
+ event_type_dom = corestring_dom_progress;
+ break;
+
+ case JSAPI_PROP_TINYID_onratechange:
+ event_type_dom = corestring_dom_ratechange;
+ break;
+
+ case JSAPI_PROP_TINYID_onreset:
+ event_type_dom = corestring_dom_reset;
+ break;
+
+ case JSAPI_PROP_TINYID_onscroll:
+ event_type_dom = corestring_dom_scroll;
+ break;
+
+ case JSAPI_PROP_TINYID_onseeked:
+ event_type_dom = corestring_dom_seeked;
+ break;
+
+ case JSAPI_PROP_TINYID_onseeking:
+ event_type_dom = corestring_dom_seeking;
+ break;
+
+ case JSAPI_PROP_TINYID_onselect:
+ event_type_dom = corestring_dom_select;
+ break;
+
+ case JSAPI_PROP_TINYID_onshow:
+ event_type_dom = corestring_dom_show;
+ break;
+
+ case JSAPI_PROP_TINYID_onstalled:
+ event_type_dom = corestring_dom_stalled;
+ break;
+
+ case JSAPI_PROP_TINYID_onsubmit:
+ event_type_dom = corestring_dom_submit;
+ break;
+
+ case JSAPI_PROP_TINYID_onsuspend:
+ event_type_dom = corestring_dom_suspend;
+ break;
+
+ case JSAPI_PROP_TINYID_ontimeupdate:
+ event_type_dom = corestring_dom_timeupdate;
+ break;
+
+ case JSAPI_PROP_TINYID_onvolumechange:
+ event_type_dom = corestring_dom_volumechange;
+ break;
+
+ case JSAPI_PROP_TINYID_onwaiting:
+ event_type_dom = corestring_dom_waiting;
+ break;
+
+ default:
+ JSLOG("called with unknown tinyid");
+ return JS_TRUE;
+ }
+ js_dom_event_add_listener((struct jscontext *)cx,
+ private->htmlc->document,
+ (dom_node *)private->node,
+ event_type_dom,
+ vp);
%}
diff --git a/test/js/event-onclick.html b/test/js/event-onclick.html
new file mode 100644
index 0000000..b2060e5
--- /dev/null
+++ b/test/js/event-onclick.html
@@ -0,0 +1,30 @@
+<html>
+<head>
+<title>alert onclick example</title>
+
+<script type="text/javascript">
+
+function causealert()
+{
+var txt = document.getElementById("p1").textContent;
+alert(txt);
+}
+
+</script>
+</head>
+
+<body>
+<div style="border: 1px solid red">
+<p id="p1">First line of paragraph.<br /></p>
+</div><br />
+
+<button id="button1" >add another textNode.</button>
+
+<script>
+var button = document.getElementById("button1");
+
+button.onclick = causealert;
+</script>
+
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index 7a17c95..bb2918c 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -5,12 +5,15 @@
</head>
<body>
<h1>JavaScript Tests</h1>
+
+
<h2>Window</h2>
<ul>
<li><a href="window.lately.html">location</a></li>
<li><a href="window-enumerate.html">enumerate</a></li>
</ul>
+
<h2>Document write</h2>
<ul>
<li><a href="inline-doc-write-simple.html">Simple document write</a></li>
@@ -22,7 +25,9 @@
<li><a href="inline-innerhtml.html">Inline script innerHtml test</a></li>
</ul>
+
<h2>DOM tests</h2>
+
<h3>Reference method tests</h3>
<ul>
<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
@@ -31,24 +36,34 @@
<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
-
</ul>
+
<h3>Enumeration tests</h3>
<ul>
<li><a href="dom-node-enumerate.html">Node element interface</a></li>
<li><a href="dom-body-enumerate.html">Body element interface</a></li>
<li><a href="dom-document-enumerate.html">Document interface</a></li>
</ul>
+
<h3>Document element specific</h3>
<ul>
<li><a href="dom-doc-cookie.html">Cookie dispaly (only from server)</a></li>
<li><a href="dom-doc-location.html">location</a></li>
</ul>
+
+
+<h2>Dom events</h2>
+<ul>
+<li><a href="event-onload.html">window.onload</a></li>
+<li><a href="event-onclick.html">button.onclick</a></li>
+</ul>
+
+
<h2>Assorted</h2>
<ul>
<li><a href="assorted-log-doc-write.html">console.log and document.write</a></li>
-
<li><a href="wikipedia-lcm.html">Example from wikipedia</a></li>
</ul>
+
</body>
</html>
-----------------------------------------------------------------------
Summary of changes:
javascript/js.h | 14 +-
javascript/jsapi.c | 120 +++++++++--
javascript/jsapi/htmlelement.bnd | 246 ++++++++++++++++++++-
test/js/{event-onload.html => event-onclick.html} | 11 +-
test/js/index.html | 19 ++-
5 files changed, 375 insertions(+), 35 deletions(-)
copy test/js/{event-onload.html => event-onclick.html} (56%)
diff --git a/javascript/js.h b/javascript/js.h
index 643ce5a..44de4fe 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -26,6 +26,10 @@
typedef struct jscontext jscontext;
typedef struct jsobject jsobject;
+struct dom_document;
+struct dom_node;
+struct dom_string;
+
/** Initialise javascript interpreter */
void js_initialise(void);
@@ -51,10 +55,16 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
-struct dom_document;
-struct dom_node;
/* fire an event at a dom node */
bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
+bool
+js_dom_event_add_listener(jscontext *ctx,
+ struct dom_document *document,
+ struct dom_node *node,
+ struct dom_string *event_type_dom,
+ void *js_funcval);
+
+
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index e5b4ddf..eebb33f 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -32,7 +32,7 @@ void js_initialise(void)
/* Create a JS runtime. */
#if JS_VERSION >= 180
- JS_SetCStringsAreUTF8(); /* we prefer our runtime to be utf-8 */
+ JS_SetCStringsAreUTF8(); /* we prefer our runtime to be utf-8 */
#endif
rt = JS_NewRuntime(8L * 1024L * 1024L);
@@ -97,7 +97,7 @@ void js_destroycontext(jscontext *ctx)
*
* This performs the following actions
* 1. constructs a new global object by initialising a window class
- * 2. Instantiate the global a window object
+ * 2. Instantiate the global a window object
*/
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
{
@@ -116,7 +116,7 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
}
window = jsapi_new_Window(cx, window_proto, NULL, win_priv, doc_priv);
-
+
return (jsobject *)window;
}
@@ -139,9 +139,9 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
return false;
}
- if (JS_EvaluateScript(cx,
- JS_GetGlobalObject(cx),
- txt, txtlen,
+ if (JS_EvaluateScript(cx,
+ JS_GetGlobalObject(cx),
+ txt, txtlen,
"<head>", 0, &rval) == JS_TRUE) {
return true;
@@ -174,8 +174,8 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
JSLOG("Dispatching event %s at window", type);
/* create and initialise and event object */
- exc = dom_string_create((unsigned char*)type,
- strlen(type),
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
&type_dom);
if (exc != DOM_NO_ERR) {
return false;
@@ -200,18 +200,18 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
/* dispatch event at the window object */
argv[0] = OBJECT_TO_JSVAL(jsevent);
- ret = JS_CallFunctionName(cx,
- JS_GetGlobalObject(cx),
- "dispatchEvent",
- 1,
- argv,
+ ret = JS_CallFunctionName(cx,
+ JS_GetGlobalObject(cx),
+ "dispatchEvent",
+ 1,
+ argv,
&rval);
} else {
JSLOG("Dispatching event %s at %p", type, node);
/* create and initialise and event object */
- exc = dom_string_create((unsigned char*)type,
- strlen(type),
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
&type_dom);
if (exc != DOM_NO_ERR) {
return false;
@@ -237,3 +237,93 @@ bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node
}
return false;
}
+
+struct js_dom_event_private {
+ JSContext *cx; /* javascript context */
+ jsval funcval; /* javascript function to call */
+ struct dom_node *node; /* dom node event listening on */
+ dom_string *type; /* event type */
+ dom_event_listener *listener; /* the listener containing this */
+};
+
+static void
+js_dom_event_listener(struct dom_event *event, void *pw)
+{
+ struct js_dom_event_private *private = pw;
+ jsval event_argv[1];
+ jsval event_rval;
+ JSObject *jsevent;
+
+ JSLOG("WOOT dom event with %p", private);
+
+ if (!JSVAL_IS_VOID(private->funcval)) {
+ jsevent = jsapi_new_Event(private->cx, NULL, NULL, event);
+ if (jsevent != NULL) {
+
+ /* dispatch event at the window object */
+ event_argv[0] = OBJECT_TO_JSVAL(jsevent);
+
+ JS_CallFunctionValue(private->cx,
+ NULL,
+ private->funcval,
+ 1,
+ event_argv,
+ &event_rval);
+ }
+ }
+}
+
+/* add a listener to a dom node
+ *
+ * 1. Create a dom_event_listener From a handle_event function pointer
+ * and a private word In a document context
+ *
+ * 2. Register for your events on a target (dom nodes are targets)
+ * dom_event_target_add_event_listener(node, evt_name, listener,
+ * capture_or_not)
+ *
+ */
+
+bool
+js_dom_event_add_listener(jscontext *ctx,
+ struct dom_document *document,
+ struct dom_node *node,
+ struct dom_string *event_type_dom,
+ void *js_funcval)
+{
+ JSContext *cx = (JSContext *)ctx;
+ dom_exception exc;
+ struct js_dom_event_private *private;
+
+ private = malloc(sizeof(struct js_dom_event_private));
+ if (private == NULL) {
+ return false;
+ }
+
+ exc = dom_event_listener_create(document,
+ js_dom_event_listener,
+ private,
+ &private->listener);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ private->cx = cx;
+ private->funcval = *(jsval *)js_funcval;
+ private->node = node;
+ private->type = event_type_dom;
+
+ JSLOG("adding %p to listener", private);
+
+ JS_AddValueRoot(cx, &private->funcval);
+ exc = dom_event_target_add_event_listener(private->node,
+ private->type,
+ private->listener,
+ true);
+ if (exc != DOM_NO_ERR) {
+ JSLOG("failed to add listener");
+ JS_RemoveValueRoot(cx, &private->funcval);
+ }
+
+ return true;
+}
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 15fe83e..e1bd2c8 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -23,7 +23,9 @@ preamble %{
#include "utils/config.h"
#include "utils/log.h"
+#include "utils/corestrings.h"
+#include "javascript/js.h"
#include "javascript/jsapi.h"
#include "javascript/jsapi/binding.h"
@@ -218,24 +220,248 @@ getter childElementCount %{
%}
getter EventHandler %{
- JSLOG("propname[%d]=\"%s\"",
+ JSLOG("propname[%d].name=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
%}
+
setter EventHandler %{
- JSLOG("propname[%d]=\"%s\"",
- tinyid,
+ dom_string *event_type_dom;
+
+ JSLOG("propname[%d].name=\"%s\"",
+ tinyid,
jsclass_properties[tinyid].name);
-/*
-1. Create a dom_event_listener From a handle_event function pointer
- and a private word In a document context
+ switch (tinyid) {
+ case JSAPI_PROP_TINYID_onabort:
+ event_type_dom = corestring_dom_abort;
+ break;
-2. Register for your events on a target (dom nodes are targets)
- dom_event_target_add_event_listener(node, evt_name, listener,
- capture_or_not)
+ case JSAPI_PROP_TINYID_onblur:
+ event_type_dom = corestring_dom_blur;
+ break;
- */
+ case JSAPI_PROP_TINYID_oncancel:
+ event_type_dom = corestring_dom_cancel;
+ break;
+
+ case JSAPI_PROP_TINYID_oncanplay:
+ event_type_dom = corestring_dom_canplay;
+ break;
+
+ case JSAPI_PROP_TINYID_oncanplaythrough:
+ event_type_dom = corestring_dom_canplaythrough;
+ break;
+
+ case JSAPI_PROP_TINYID_onchange:
+ event_type_dom = corestring_dom_change;
+ break;
+
+ case JSAPI_PROP_TINYID_onclick:
+ event_type_dom = corestring_dom_click;
+ break;
+
+ case JSAPI_PROP_TINYID_onclose:
+ event_type_dom = corestring_dom_close;
+ break;
+
+ case JSAPI_PROP_TINYID_oncontextmenu:
+ event_type_dom = corestring_dom_contextmenu;
+ break;
+
+ case JSAPI_PROP_TINYID_oncuechange:
+ event_type_dom = corestring_dom_cuechange;
+ break;
+
+ case JSAPI_PROP_TINYID_ondblclick:
+ event_type_dom = corestring_dom_dblclick;
+ break;
+
+ case JSAPI_PROP_TINYID_ondrag:
+ event_type_dom = corestring_dom_drag;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragend:
+ event_type_dom = corestring_dom_dragend;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragenter:
+ event_type_dom = corestring_dom_dragenter;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragleave:
+ event_type_dom = corestring_dom_dragleave;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragover:
+ event_type_dom = corestring_dom_dragover;
+ break;
+
+ case JSAPI_PROP_TINYID_ondragstart:
+ event_type_dom = corestring_dom_dragstart;
+ break;
+
+ case JSAPI_PROP_TINYID_ondrop:
+ event_type_dom = corestring_dom_drop;
+ break;
+
+ case JSAPI_PROP_TINYID_ondurationchange:
+ event_type_dom = corestring_dom_durationchange;
+ break;
+
+ case JSAPI_PROP_TINYID_onemptied:
+ event_type_dom = corestring_dom_emptied;
+ break;
+
+ case JSAPI_PROP_TINYID_onended:
+ event_type_dom = corestring_dom_ended;
+ break;
+
+ case JSAPI_PROP_TINYID_onerror:
+ event_type_dom = corestring_dom_error;
+ break;
+
+ case JSAPI_PROP_TINYID_onfocus:
+ event_type_dom = corestring_dom_focus;
+ break;
+
+ case JSAPI_PROP_TINYID_oninput:
+ event_type_dom = corestring_dom_input;
+ break;
+
+ case JSAPI_PROP_TINYID_oninvalid:
+ event_type_dom = corestring_dom_invalid;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeydown:
+ event_type_dom = corestring_dom_keydown;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeypress:
+ event_type_dom = corestring_dom_keypress;
+ break;
+
+ case JSAPI_PROP_TINYID_onkeyup:
+ event_type_dom = corestring_dom_keyup;
+ break;
+
+ case JSAPI_PROP_TINYID_onload:
+ event_type_dom = corestring_dom_load;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadeddata:
+ event_type_dom = corestring_dom_loadeddata;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadedmetadata:
+ event_type_dom = corestring_dom_loadedmetadata;
+ break;
+
+ case JSAPI_PROP_TINYID_onloadstart:
+ event_type_dom = corestring_dom_loadstart;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousedown:
+ event_type_dom = corestring_dom_mousedown;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousemove:
+ event_type_dom = corestring_dom_mousemove;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseout:
+ event_type_dom = corestring_dom_mouseout;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseover:
+ event_type_dom = corestring_dom_mouseover;
+ break;
+
+ case JSAPI_PROP_TINYID_onmouseup:
+ event_type_dom = corestring_dom_mouseup;
+ break;
+
+ case JSAPI_PROP_TINYID_onmousewheel:
+ event_type_dom = corestring_dom_mousewheel;
+ break;
+
+ case JSAPI_PROP_TINYID_onpause:
+ event_type_dom = corestring_dom_pause;
+ break;
+
+ case JSAPI_PROP_TINYID_onplay:
+ event_type_dom = corestring_dom_play;
+ break;
+
+ case JSAPI_PROP_TINYID_onplaying:
+ event_type_dom = corestring_dom_playing;
+ break;
+
+ case JSAPI_PROP_TINYID_onprogress:
+ event_type_dom = corestring_dom_progress;
+ break;
+
+ case JSAPI_PROP_TINYID_onratechange:
+ event_type_dom = corestring_dom_ratechange;
+ break;
+
+ case JSAPI_PROP_TINYID_onreset:
+ event_type_dom = corestring_dom_reset;
+ break;
+
+ case JSAPI_PROP_TINYID_onscroll:
+ event_type_dom = corestring_dom_scroll;
+ break;
+
+ case JSAPI_PROP_TINYID_onseeked:
+ event_type_dom = corestring_dom_seeked;
+ break;
+
+ case JSAPI_PROP_TINYID_onseeking:
+ event_type_dom = corestring_dom_seeking;
+ break;
+
+ case JSAPI_PROP_TINYID_onselect:
+ event_type_dom = corestring_dom_select;
+ break;
+
+ case JSAPI_PROP_TINYID_onshow:
+ event_type_dom = corestring_dom_show;
+ break;
+
+ case JSAPI_PROP_TINYID_onstalled:
+ event_type_dom = corestring_dom_stalled;
+ break;
+
+ case JSAPI_PROP_TINYID_onsubmit:
+ event_type_dom = corestring_dom_submit;
+ break;
+
+ case JSAPI_PROP_TINYID_onsuspend:
+ event_type_dom = corestring_dom_suspend;
+ break;
+
+ case JSAPI_PROP_TINYID_ontimeupdate:
+ event_type_dom = corestring_dom_timeupdate;
+ break;
+
+ case JSAPI_PROP_TINYID_onvolumechange:
+ event_type_dom = corestring_dom_volumechange;
+ break;
+
+ case JSAPI_PROP_TINYID_onwaiting:
+ event_type_dom = corestring_dom_waiting;
+ break;
+
+ default:
+ JSLOG("called with unknown tinyid");
+ return JS_TRUE;
+ }
+ js_dom_event_add_listener((struct jscontext *)cx,
+ private->htmlc->document,
+ (dom_node *)private->node,
+ event_type_dom,
+ vp);
%}
diff --git a/test/js/event-onload.html b/test/js/event-onclick.html
similarity index 56%
copy from test/js/event-onload.html
copy to test/js/event-onclick.html
index cd9e705..b2060e5 100644
--- a/test/js/event-onload.html
+++ b/test/js/event-onclick.html
@@ -1,12 +1,13 @@
<html>
<head>
-<title>createTextNode onload example</title>
+<title>alert onclick example</title>
<script type="text/javascript">
-function addTextNode()
+function causealert()
{
-para.appendChild(document.createTextNode(" Some text added dynamically. "));
+var txt = document.getElementById("p1").textContent;
+alert(txt);
}
</script>
@@ -21,10 +22,8 @@ para.appendChild(document.createTextNode(" Some text added dynamically. "));
<script>
var button = document.getElementById("button1");
-var para = document.getElementById("p1");
-window.onload = addTextNode;
-button.onclick = addTextNode;
+button.onclick = causealert;
</script>
</body>
diff --git a/test/js/index.html b/test/js/index.html
index 7a17c95..bb2918c 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -5,12 +5,15 @@
</head>
<body>
<h1>JavaScript Tests</h1>
+
+
<h2>Window</h2>
<ul>
<li><a href="window.lately.html">location</a></li>
<li><a href="window-enumerate.html">enumerate</a></li>
</ul>
+
<h2>Document write</h2>
<ul>
<li><a href="inline-doc-write-simple.html">Simple document write</a></li>
@@ -22,7 +25,9 @@
<li><a href="inline-innerhtml.html">Inline script innerHtml test</a></li>
</ul>
+
<h2>DOM tests</h2>
+
<h3>Reference method tests</h3>
<ul>
<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
@@ -31,24 +36,34 @@
<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
-
</ul>
+
<h3>Enumeration tests</h3>
<ul>
<li><a href="dom-node-enumerate.html">Node element interface</a></li>
<li><a href="dom-body-enumerate.html">Body element interface</a></li>
<li><a href="dom-document-enumerate.html">Document interface</a></li>
</ul>
+
<h3>Document element specific</h3>
<ul>
<li><a href="dom-doc-cookie.html">Cookie dispaly (only from server)</a></li>
<li><a href="dom-doc-location.html">location</a></li>
</ul>
+
+
+<h2>Dom events</h2>
+<ul>
+<li><a href="event-onload.html">window.onload</a></li>
+<li><a href="event-onclick.html">button.onclick</a></li>
+</ul>
+
+
<h2>Assorted</h2>
<ul>
<li><a href="assorted-log-doc-write.html">console.log and document.write</a></li>
-
<li><a href="wikipedia-lcm.html">Example from wikipedia</a></li>
</ul>
+
</body>
</html>
--
NetSurf Browser
10 years, 1 month
netsurf: branch mono/removing-windom-dependency updated. f4ea103657f79f3ddf111789d8be98fcab5a54e0
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f4ea103657f79f3ddf111...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f4ea103657f79f3ddf11178...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f4ea103657f79f3ddf111789d...
The branch, mono/removing-windom-dependency has been updated
via f4ea103657f79f3ddf111789d8be98fcab5a54e0 (commit)
via 25db04a890e7493998abede078c6e0cc7a7fd734 (commit)
from 2c5b24d717613211ea4d9c805c19c12436397ec0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/f4ea103657f79f3ddf1...
commit f4ea103657f79f3ddf111789d8be98fcab5a54e0
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Reenabled VDI clipping...
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 9937c0b..e0d52a4 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -325,7 +325,7 @@ inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
inline static void plot_vdi_clip(bool set)
{
// TODO : check this
- return;
+
if( set == true ) {
struct rect c;
short vdiflags[58];
@@ -340,6 +340,7 @@ inline static void plot_vdi_clip(bool set)
newclip[1] = view.y + MAX(c.y0, 0);
newclip[2] = MIN(view.x+view.w, newclip[0] + (c.x1 - c.x0) )-1;
newclip[3] = MIN(view.y+view.h, newclip[1] + (c.y1 - c.y0) )-1;
+ //dbg_pxy("plot_vdi_clip", newclip);
vs_clip(atari_plot_vdi_handle, 1, (short*)&newclip );
} else {
vs_clip(atari_plot_vdi_handle, 1, (short *)&prev_vdi_clip );
@@ -1825,10 +1826,13 @@ bool plot_line(int x0, int y0, int x1, int y1,
pxy[2] = view.x + MAX(0,x1);
pxy[3] = view.y + MAX(0,y1);
+ if((y0 > view.h-1) && (y1 > view.h-1))
+ return(true);
//printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h);
//printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1);
+
plot_vdi_clip(true);
if( sw == 0)
sw = 1;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/25db04a890e7493998a...
commit 25db04a890e7493998abede078c6e0cc7a7fd734
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Dragged scrolling/mouse click events works fine now.
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 54d043e..1f96232 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -471,8 +471,12 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_h/slid->y_unit_px;
newpos = slid->y_pos = MIN(slid->y_units-vis_units,
MAX(0, slid->y_pos+units));
+ if(newpos < 0){
+ newpos = slid->y_pos = 0;
+ }
if(oldpos == newpos)
return;
+
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
// send complete redraw
redraw = &g_ro;
@@ -502,6 +506,11 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_w/slid->x_unit_px;
newpos = slid->x_pos = MIN(slid->x_units-vis_units,
MAX(0, slid->x_pos+units));
+
+ if(newpos < 0){
+ newpos = slid->x_pos = 0;
+ }
+
if(oldpos == newpos)
return;
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
@@ -635,11 +644,30 @@ struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
return(&win->scroll_info);
}
+void guiwin_request_redraw(GUIWIN *win, GRECT *area)
+{
+
+}
+
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
short msg[8];
GRECT work;
+ EVMULT_IN event_in = {
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+ };
+ EVMULT_OUT event_out;
+
if(area == NULL) {
guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
area = &work;
@@ -654,7 +682,10 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
msg[6] = area->g_w;
msg[7] = area->g_h;
- appl_write(gl_apid, 16, &msg);
+ event_out.emo_events = MU_MESAG;
+ win->handler_func(win, &event_out, msg);
+
+ //appl_write(gl_apid, 16, &msg);
}
diff --git a/atari/gui.c b/atari/gui.c
index d930b0c..80e98c2 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -363,22 +363,36 @@ void gui_window_redraw_window(struct gui_window *gw)
if (gw == NULL)
return;
b = gw->browser;
- browser_get_rect(gw, BR_CONTENT, &rect);
- browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &rect);
+ window_schedule_redraw_grect(gw->root, &rect);
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
- CMP_BROWSER b;
+ GRECT area;
+ struct guiwin_scroll_info_s *slid;
+
if (gw == NULL)
return;
- b = gw->browser;
+
+ slid = guiwin_get_scroll_info(gw->root->win);
+
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
+
+ area.g_x += rect->x0 - slid->x_pos * slid->x_unit_px;
+ area.g_y += rect->y0 - slid->y_pos * slid->y_unit_px;
+ area.g_w = rect->x1 - rect->x0;
+ area.g_h = rect->y1 - rect->y0;
+ window_schedule_redraw_grect(gw->root, &area);
+/*
int x0 = rect->x0 - b->scroll.current.x;
int y0 = rect->y0 - b->scroll.current.y;
int w,h;
- w = rect->x1 - rect->x0;
- h = rect->y1 - rect->y0;
- browser_schedule_redraw_rect( gw, x0, y0, w, h );
+ */
+ //w = rect->x1 - rect->x0;
+ //h = rect->y1 - rect->y0;
+
+ //browser_schedule_redraw_rect( gw, x0, y0, w, h );
}
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
@@ -387,7 +401,8 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
if (w == NULL)
return false;
- window_get_scroll(w->root, &x, &y);
+ window_get_scroll(w->root, sx, sy);
+
return( true );
}
@@ -399,7 +414,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
|| (w->browser->bw->current_content == NULL))
return;
- printf("scroll %d, %d\n", sx, sy);
+ //printf("scroll %d, %d\n", sx, sy);
window_scroll_by(w->root, sx, sy);
return;
@@ -647,12 +662,11 @@ gui_window_set_search_ico(hlcache_handle *ico)
void gui_window_new_content(struct gui_window *w)
{
- w->browser->scroll.current.x = 0;
- w->browser->scroll.current.y = 0;
- w->browser->scroll.requested.x = 0;
- w->browser->scroll.requested.y = 0;
- w->browser->scroll.required = true;
- gui_window_redraw_window( w );
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w->root->win);
+ slid->x_pos = 0;
+ slid->y_pos = 0;
+ guiwin_update_slider(w->root->win, GUIWIN_VH_SLIDER);
+ gui_window_redraw_window(w);
}
bool gui_window_scroll_start(struct gui_window *w)
diff --git a/atari/misc.c b/atari/misc.c
index f12556b..60678dc 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -504,8 +504,8 @@ void dbg_lgrect( char * str, LGRECT * r )
void dbg_grect(const char * str, GRECT * r)
{
- printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
- r->g_x, r->g_y, r->g_w, r->g_h );
+ printf("%s: x: %d, y: %d, w: %d, h: %d (x2: %d, y2: %d)\n", str,
+ r->g_x, r->g_y, r->g_w, r->g_h, r->g_x + r->g_w, r->g_y + r->g_h);
}
void dbg_pxy(const char * str, short * pxy )
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 9806852..056a85d 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -96,7 +96,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
- printf("root win msg: %d\n", msg[0]);
+ //printf("root win msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
@@ -161,8 +161,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
- printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
}
return(retval);
@@ -364,33 +364,22 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
void window_scroll_by(ROOTWIN *root, int sx, int sy)
{
- int units;
- GRECT content_area;
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
-
- if (sx != 0) {
- units = sx / slid->x_unit_px;
- if (units == 0) {
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
- }
-
- guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
- if (sy != 0) {
- units = sy / slid->y_unit_px;
- if( sx < 0 ) {
- // units = -units;
- }
- if(units == 0){
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if(sx < 0) {
+ sx = 0;
}
+ if(sy<0) {
+ sy = 0;
+ }
+ int xunits = sx / slid->x_unit_px;
+ int yunits = sy / slid->y_unit_px;
+
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, yunits - slid->y_pos, false);
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, xunits - slid->x_pos, false);
+ guiwin_update_slider(root->win, GUIWIN_VH_SLIDER);
}
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
@@ -401,6 +390,10 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
slid->x_units = (width/slid->x_unit_px);
slid->y_units = (height/slid->y_unit_px);
+ if(slid->x_units < slid->x_pos)
+ slid->x_pos = 0;
+ if(slid->y_units < slid->y_pos)
+ slid->y_pos = 0;
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
// TODO: reset slider to 0
}
@@ -493,12 +486,12 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
{
- struct guiwin_scroll_info_s *slid;
+ struct guiwin_scroll_info_s *slid;
- slid = guiwin_get_scroll_info(rootwin->win);
+ slid = guiwin_get_scroll_info(rootwin->win);
- *x = slid->x_pos * slid->x_unit_px;
- *y = slid->y_pos * slid->y_unit_px;
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
}
@@ -559,7 +552,7 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
rc_intersect(area, &work);
- dbg_grect("window_schedule_redraw_grect intersection ", &work);
+ //dbg_grect("window_schedule_redraw_grect intersection ", &work);
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
}
@@ -603,7 +596,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
content_area_rel.g_y = 0;
}
- dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
+ //dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
redraw_area.x0 = content_area_rel.g_x;
redraw_area.y0 = content_area_rel.g_y;
@@ -612,6 +605,8 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
plot_clip(&redraw_area);
+ //dbg_rect("rdrw area", &redraw_area);
+
browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
-(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
}
@@ -630,6 +625,8 @@ void window_process_redraws(ROOTWIN * rootwin)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
+ //dbg_grect("content area", &content_area);
+
short pxy_clip[4];
pxy_clip[0] = tb_area.g_x;
@@ -696,7 +693,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
gw = window_get_active_gui_window(rootwin);
if( input_window != gw ) {
- input_window = gw;
+ gui_set_input_gui_window(gw);
}
window_set_focus(gw->root, BROWSER, (void*)gw->browser );
@@ -705,6 +702,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert screen coords to component coords: */
mx = aes_event_out.emo_mouse.p_x - cwork.g_x;
my = aes_event_out.emo_mouse.p_y - cwork.g_y;
+ //printf("content click at %d,%d\n", mx, my);
/* Translate GEM key state to netsurf mouse modifier */
if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
@@ -725,8 +723,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert component coords to scrolled content coords: */
slid = guiwin_get_scroll_info(rootwin->win);
- int sx_origin = (mx + slid->x_pos * slid->x_unit_px);
- int sy_origin = (my + slid->y_pos * slid->y_unit_px);
+ int sx_origin = mx;
+ int sy_origin = my;
short rel_cur_x, rel_cur_y;
short prev_x=sx_origin, prev_y=sy_origin;
@@ -736,39 +734,48 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
/* Mouse still pressed, report drag */
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
browser_window_mouse_click( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- sx_origin, sy_origin);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
do {
+ printf("rel click coords: %d,%d\n", rel_cur_x, rel_cur_y);
// only consider movements of 5px or more as drag...:
if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
browser_window_mouse_track( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
prev_x = rel_cur_x;
prev_y = rel_cur_y;
dragmode = true;
+ printf("now dragmode is true...\n");
} else {
if( dragmode == false ) {
+ printf("dragmode = false\n");
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
}
}
// we may need to process scrolling:
// TODO: this doesn't work, because gemtk schedules redraw via
// AES window messages but we do not process them right here...
- if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+ evnt_timer(150);
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
} while( mbut & 1 );
- browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
+ browser_window_mouse_track(gw->browser->bw, 0,
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
} else {
/* Right button pressed? */
if ((aes_event_out.emo_mbutton & 2 ) ) {
@@ -777,15 +784,17 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
} else {
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_PRESS_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_CLICK_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
}
}
if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ window_process_redraws(rootwin);
+ }
}
/*
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 4b04911..40cee80 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -218,7 +218,7 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
area.g_y += y;
area.g_w = w;
area.g_h = h;
- dbg_grect("tb_txt_request_redraw", &area);
+ //dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
return;
}
-----------------------------------------------------------------------
Summary of changes:
atari/gemtk/guiwin.c | 33 ++++++++++++++-
atari/gui.c | 44 +++++++++++++-------
atari/misc.c | 4 +-
atari/plot/plot.c | 6 ++-
atari/rootwin.c | 115 +++++++++++++++++++++++++++-----------------------
atari/toolbar.c | 2 +-
6 files changed, 131 insertions(+), 73 deletions(-)
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 54d043e..1f96232 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -471,8 +471,12 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_h/slid->y_unit_px;
newpos = slid->y_pos = MIN(slid->y_units-vis_units,
MAX(0, slid->y_pos+units));
+ if(newpos < 0){
+ newpos = slid->y_pos = 0;
+ }
if(oldpos == newpos)
return;
+
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
// send complete redraw
redraw = &g_ro;
@@ -502,6 +506,11 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_w/slid->x_unit_px;
newpos = slid->x_pos = MIN(slid->x_units-vis_units,
MAX(0, slid->x_pos+units));
+
+ if(newpos < 0){
+ newpos = slid->x_pos = 0;
+ }
+
if(oldpos == newpos)
return;
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
@@ -635,11 +644,30 @@ struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
return(&win->scroll_info);
}
+void guiwin_request_redraw(GUIWIN *win, GRECT *area)
+{
+
+}
+
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
short msg[8];
GRECT work;
+ EVMULT_IN event_in = {
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+ };
+ EVMULT_OUT event_out;
+
if(area == NULL) {
guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
area = &work;
@@ -654,7 +682,10 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
msg[6] = area->g_w;
msg[7] = area->g_h;
- appl_write(gl_apid, 16, &msg);
+ event_out.emo_events = MU_MESAG;
+ win->handler_func(win, &event_out, msg);
+
+ //appl_write(gl_apid, 16, &msg);
}
diff --git a/atari/gui.c b/atari/gui.c
index d930b0c..80e98c2 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -363,22 +363,36 @@ void gui_window_redraw_window(struct gui_window *gw)
if (gw == NULL)
return;
b = gw->browser;
- browser_get_rect(gw, BR_CONTENT, &rect);
- browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &rect);
+ window_schedule_redraw_grect(gw->root, &rect);
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
- CMP_BROWSER b;
+ GRECT area;
+ struct guiwin_scroll_info_s *slid;
+
if (gw == NULL)
return;
- b = gw->browser;
+
+ slid = guiwin_get_scroll_info(gw->root->win);
+
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
+
+ area.g_x += rect->x0 - slid->x_pos * slid->x_unit_px;
+ area.g_y += rect->y0 - slid->y_pos * slid->y_unit_px;
+ area.g_w = rect->x1 - rect->x0;
+ area.g_h = rect->y1 - rect->y0;
+ window_schedule_redraw_grect(gw->root, &area);
+/*
int x0 = rect->x0 - b->scroll.current.x;
int y0 = rect->y0 - b->scroll.current.y;
int w,h;
- w = rect->x1 - rect->x0;
- h = rect->y1 - rect->y0;
- browser_schedule_redraw_rect( gw, x0, y0, w, h );
+ */
+ //w = rect->x1 - rect->x0;
+ //h = rect->y1 - rect->y0;
+
+ //browser_schedule_redraw_rect( gw, x0, y0, w, h );
}
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
@@ -387,7 +401,8 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
if (w == NULL)
return false;
- window_get_scroll(w->root, &x, &y);
+ window_get_scroll(w->root, sx, sy);
+
return( true );
}
@@ -399,7 +414,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
|| (w->browser->bw->current_content == NULL))
return;
- printf("scroll %d, %d\n", sx, sy);
+ //printf("scroll %d, %d\n", sx, sy);
window_scroll_by(w->root, sx, sy);
return;
@@ -647,12 +662,11 @@ gui_window_set_search_ico(hlcache_handle *ico)
void gui_window_new_content(struct gui_window *w)
{
- w->browser->scroll.current.x = 0;
- w->browser->scroll.current.y = 0;
- w->browser->scroll.requested.x = 0;
- w->browser->scroll.requested.y = 0;
- w->browser->scroll.required = true;
- gui_window_redraw_window( w );
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w->root->win);
+ slid->x_pos = 0;
+ slid->y_pos = 0;
+ guiwin_update_slider(w->root->win, GUIWIN_VH_SLIDER);
+ gui_window_redraw_window(w);
}
bool gui_window_scroll_start(struct gui_window *w)
diff --git a/atari/misc.c b/atari/misc.c
index f12556b..60678dc 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -504,8 +504,8 @@ void dbg_lgrect( char * str, LGRECT * r )
void dbg_grect(const char * str, GRECT * r)
{
- printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
- r->g_x, r->g_y, r->g_w, r->g_h );
+ printf("%s: x: %d, y: %d, w: %d, h: %d (x2: %d, y2: %d)\n", str,
+ r->g_x, r->g_y, r->g_w, r->g_h, r->g_x + r->g_w, r->g_y + r->g_h);
}
void dbg_pxy(const char * str, short * pxy )
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 9937c0b..e0d52a4 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -325,7 +325,7 @@ inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
inline static void plot_vdi_clip(bool set)
{
// TODO : check this
- return;
+
if( set == true ) {
struct rect c;
short vdiflags[58];
@@ -340,6 +340,7 @@ inline static void plot_vdi_clip(bool set)
newclip[1] = view.y + MAX(c.y0, 0);
newclip[2] = MIN(view.x+view.w, newclip[0] + (c.x1 - c.x0) )-1;
newclip[3] = MIN(view.y+view.h, newclip[1] + (c.y1 - c.y0) )-1;
+ //dbg_pxy("plot_vdi_clip", newclip);
vs_clip(atari_plot_vdi_handle, 1, (short*)&newclip );
} else {
vs_clip(atari_plot_vdi_handle, 1, (short *)&prev_vdi_clip );
@@ -1825,10 +1826,13 @@ bool plot_line(int x0, int y0, int x1, int y1,
pxy[2] = view.x + MAX(0,x1);
pxy[3] = view.y + MAX(0,y1);
+ if((y0 > view.h-1) && (y1 > view.h-1))
+ return(true);
//printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h);
//printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1);
+
plot_vdi_clip(true);
if( sw == 0)
sw = 1;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 9806852..056a85d 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -96,7 +96,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
- printf("root win msg: %d\n", msg[0]);
+ //printf("root win msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
@@ -161,8 +161,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
- printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
}
return(retval);
@@ -364,33 +364,22 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
void window_scroll_by(ROOTWIN *root, int sx, int sy)
{
- int units;
- GRECT content_area;
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
-
- if (sx != 0) {
- units = sx / slid->x_unit_px;
- if (units == 0) {
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
- }
-
- guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
- if (sy != 0) {
- units = sy / slid->y_unit_px;
- if( sx < 0 ) {
- // units = -units;
- }
- if(units == 0){
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if(sx < 0) {
+ sx = 0;
}
+ if(sy<0) {
+ sy = 0;
+ }
+ int xunits = sx / slid->x_unit_px;
+ int yunits = sy / slid->y_unit_px;
+
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, yunits - slid->y_pos, false);
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, xunits - slid->x_pos, false);
+ guiwin_update_slider(root->win, GUIWIN_VH_SLIDER);
}
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
@@ -401,6 +390,10 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
slid->x_units = (width/slid->x_unit_px);
slid->y_units = (height/slid->y_unit_px);
+ if(slid->x_units < slid->x_pos)
+ slid->x_pos = 0;
+ if(slid->y_units < slid->y_pos)
+ slid->y_pos = 0;
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
// TODO: reset slider to 0
}
@@ -493,12 +486,12 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
{
- struct guiwin_scroll_info_s *slid;
+ struct guiwin_scroll_info_s *slid;
- slid = guiwin_get_scroll_info(rootwin->win);
+ slid = guiwin_get_scroll_info(rootwin->win);
- *x = slid->x_pos * slid->x_unit_px;
- *y = slid->y_pos * slid->y_unit_px;
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
}
@@ -559,7 +552,7 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
rc_intersect(area, &work);
- dbg_grect("window_schedule_redraw_grect intersection ", &work);
+ //dbg_grect("window_schedule_redraw_grect intersection ", &work);
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
}
@@ -603,7 +596,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
content_area_rel.g_y = 0;
}
- dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
+ //dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
redraw_area.x0 = content_area_rel.g_x;
redraw_area.y0 = content_area_rel.g_y;
@@ -612,6 +605,8 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
plot_clip(&redraw_area);
+ //dbg_rect("rdrw area", &redraw_area);
+
browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
-(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
}
@@ -630,6 +625,8 @@ void window_process_redraws(ROOTWIN * rootwin)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
+ //dbg_grect("content area", &content_area);
+
short pxy_clip[4];
pxy_clip[0] = tb_area.g_x;
@@ -696,7 +693,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
gw = window_get_active_gui_window(rootwin);
if( input_window != gw ) {
- input_window = gw;
+ gui_set_input_gui_window(gw);
}
window_set_focus(gw->root, BROWSER, (void*)gw->browser );
@@ -705,6 +702,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert screen coords to component coords: */
mx = aes_event_out.emo_mouse.p_x - cwork.g_x;
my = aes_event_out.emo_mouse.p_y - cwork.g_y;
+ //printf("content click at %d,%d\n", mx, my);
/* Translate GEM key state to netsurf mouse modifier */
if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
@@ -725,8 +723,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert component coords to scrolled content coords: */
slid = guiwin_get_scroll_info(rootwin->win);
- int sx_origin = (mx + slid->x_pos * slid->x_unit_px);
- int sy_origin = (my + slid->y_pos * slid->y_unit_px);
+ int sx_origin = mx;
+ int sy_origin = my;
short rel_cur_x, rel_cur_y;
short prev_x=sx_origin, prev_y=sy_origin;
@@ -736,39 +734,48 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
/* Mouse still pressed, report drag */
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
browser_window_mouse_click( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- sx_origin, sy_origin);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
do {
+ printf("rel click coords: %d,%d\n", rel_cur_x, rel_cur_y);
// only consider movements of 5px or more as drag...:
if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
browser_window_mouse_track( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
prev_x = rel_cur_x;
prev_y = rel_cur_y;
dragmode = true;
+ printf("now dragmode is true...\n");
} else {
if( dragmode == false ) {
+ printf("dragmode = false\n");
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
}
}
// we may need to process scrolling:
// TODO: this doesn't work, because gemtk schedules redraw via
// AES window messages but we do not process them right here...
- if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+ evnt_timer(150);
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
} while( mbut & 1 );
- browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
+ browser_window_mouse_track(gw->browser->bw, 0,
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
} else {
/* Right button pressed? */
if ((aes_event_out.emo_mbutton & 2 ) ) {
@@ -777,15 +784,17 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
} else {
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_PRESS_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_CLICK_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
}
}
if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ window_process_redraws(rootwin);
+ }
}
/*
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 4b04911..40cee80 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -218,7 +218,7 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
area.g_y += y;
area.g_w = w;
area.g_h = h;
- dbg_grect("tb_txt_request_redraw", &area);
+ //dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
return;
}
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. 878fe3e68cbda4f3d51cce7bc3b0ffcc27135367
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/878fe3e68cbda4f3d51cc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/878fe3e68cbda4f3d51cce7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/878fe3e68cbda4f3d51cce7bc...
The branch, master has been updated
via 878fe3e68cbda4f3d51cce7bc3b0ffcc27135367 (commit)
from 70ece8a428de80d2efacef58d4a2ec259def54b8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/878fe3e68cbda4f3d51...
commit 878fe3e68cbda4f3d51cce7bc3b0ffcc27135367
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fix disabled javascript function signature
diff --git a/javascript/none.c b/javascript/none.c
index 6354a12..3e7b39c 100644
--- a/javascript/none.c
+++ b/javascript/none.c
@@ -54,7 +54,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
return true;
}
-bool js_fire_event(jscontext *ctx, const char *type, void *target)
+bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target)
{
return true;
}
-----------------------------------------------------------------------
Summary of changes:
javascript/none.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/javascript/none.c b/javascript/none.c
index 6354a12..3e7b39c 100644
--- a/javascript/none.c
+++ b/javascript/none.c
@@ -54,7 +54,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
return true;
}
-bool js_fire_event(jscontext *ctx, const char *type, void *target)
+bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target)
{
return true;
}
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. 70ece8a428de80d2efacef58d4a2ec259def54b8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/70ece8a428de80d2eface...
...commit http://git.netsurf-browser.org/netsurf.git/commit/70ece8a428de80d2efacef5...
...tree http://git.netsurf-browser.org/netsurf.git/tree/70ece8a428de80d2efacef58d...
The branch, master has been updated
via 70ece8a428de80d2efacef58d4a2ec259def54b8 (commit)
from 30528647735b5bcb689427b3a865f78c57a6070c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/70ece8a428de80d2efa...
commit 70ece8a428de80d2efacef58d4a2ec259def54b8
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add stub implemntation for event handling in elements
diff --git a/javascript/js.h b/javascript/js.h
index d7943b1..643ce5a 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -51,10 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
-typedef struct dom_document dom_document;
-typedef struct dom_node dom_node;
+struct dom_document;
+struct dom_node;
/* fire an event at a dom node */
-bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target);
+bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 71bb31b..15fe83e 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -36,6 +36,8 @@ binding htmlelement {
private "dom_element *" node;
private "struct html_content *" htmlc;
+
+ property unshared type EventHandler;
}
api finalise %{
@@ -214,3 +216,26 @@ getter childElementCount %{
}
}
%}
+
+getter EventHandler %{
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
+%}
+
+setter EventHandler %{
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
+
+/*
+1. Create a dom_event_listener From a handle_event function pointer
+ and a private word In a document context
+
+2. Register for your events on a target (dom nodes are targets)
+ dom_event_target_add_event_listener(node, evt_name, listener,
+ capture_or_not)
+
+ */
+
+%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 56b2ff0..d7f47ce 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -258,12 +258,16 @@ getter EventHandler %{
/* this implementation is unique to the window object as it is
* not a dom node.
*/
- JSLOG("propname[%d] %s %s", tinyid , jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
%}
setter EventHandler %{
/* this implementation is unique to the window object as it is
* not a dom node.
*/
- JSLOG("propname[%d] %s %s", tinyid, jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
%}
-----------------------------------------------------------------------
Summary of changes:
javascript/js.h | 6 +++---
javascript/jsapi/htmlelement.bnd | 25 +++++++++++++++++++++++++
javascript/jsapi/window.bnd | 8 ++++++--
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/javascript/js.h b/javascript/js.h
index d7943b1..643ce5a 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -51,10 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
-typedef struct dom_document dom_document;
-typedef struct dom_node dom_node;
+struct dom_document;
+struct dom_node;
/* fire an event at a dom node */
-bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target);
+bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 71bb31b..15fe83e 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -36,6 +36,8 @@ binding htmlelement {
private "dom_element *" node;
private "struct html_content *" htmlc;
+
+ property unshared type EventHandler;
}
api finalise %{
@@ -214,3 +216,26 @@ getter childElementCount %{
}
}
%}
+
+getter EventHandler %{
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
+%}
+
+setter EventHandler %{
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
+
+/*
+1. Create a dom_event_listener From a handle_event function pointer
+ and a private word In a document context
+
+2. Register for your events on a target (dom nodes are targets)
+ dom_event_target_add_event_listener(node, evt_name, listener,
+ capture_or_not)
+
+ */
+
+%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 56b2ff0..d7f47ce 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -258,12 +258,16 @@ getter EventHandler %{
/* this implementation is unique to the window object as it is
* not a dom node.
*/
- JSLOG("propname[%d] %s %s", tinyid , jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
%}
setter EventHandler %{
/* this implementation is unique to the window object as it is
* not a dom node.
*/
- JSLOG("propname[%d] %s %s", tinyid, jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
+ JSLOG("propname[%d]=\"%s\"",
+ tinyid,
+ jsclass_properties[tinyid].name);
%}
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. 30528647735b5bcb689427b3a865f78c57a6070c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/30528647735b5bcb68942...
...commit http://git.netsurf-browser.org/netsurf.git/commit/30528647735b5bcb689427b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/30528647735b5bcb689427b3a...
The branch, master has been updated
via 30528647735b5bcb689427b3a865f78c57a6070c (commit)
from 22fbe5abfc2797ebba6f330a48b3b6d2ec2058a3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/30528647735b5bcb689...
commit 30528647735b5bcb689427b3a865f78c57a6070c
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
issue click events at dom
diff --git a/javascript/js.h b/javascript/js.h
index 4dd8f15..d7943b1 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -51,7 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
+typedef struct dom_document dom_document;
+typedef struct dom_node dom_node;
+
/* fire an event at a dom node */
-bool js_fire_event(jscontext *ctx, const char *type, void *target);
+bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target);
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index bec5653..e5b4ddf 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -153,7 +153,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
dom_exception _dom_event_create(dom_document *doc, dom_event **evt);
#define dom_event_create(d, e) _dom_event_create((dom_document *)(d), (dom_event **) (e))
-bool js_fire_event(jscontext *ctx, const char *type, void *target)
+bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target)
{
JSContext *cx = (JSContext *)ctx;
dom_node *node = target;
@@ -165,18 +165,23 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
dom_event *event;
dom_string *type_dom;
+ if (cx == NULL) {
+ return false;
+ }
+
if (node == NULL) {
- /* deliver to window */
- if (cx == NULL) {
- return false;
- }
+ /* deliver manufactured event to window */
+ JSLOG("Dispatching event %s at window", type);
- exc = dom_string_create((unsigned char*)type, strlen(type), &type_dom);
+ /* create and initialise and event object */
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
+ &type_dom);
if (exc != DOM_NO_ERR) {
return false;
}
- exc = dom_event_create(-1, &event);
+ exc = dom_event_create(doc, &event);
if (exc != DOM_NO_ERR) {
return false;
}
@@ -192,6 +197,7 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
return false;
}
+ /* dispatch event at the window object */
argv[0] = OBJECT_TO_JSVAL(jsevent);
ret = JS_CallFunctionName(cx,
@@ -200,7 +206,31 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
1,
argv,
&rval);
- }
+ } else {
+ JSLOG("Dispatching event %s at %p", type, node);
+
+ /* create and initialise and event object */
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
+ &type_dom);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ exc = dom_event_create(doc, &event);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ exc = dom_event_init(event, type_dom, true, true);
+ dom_string_unref(type_dom);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ dom_event_target_dispatch_event(node, event, &ret);
+
+ }
if (ret == JS_TRUE) {
return true;
diff --git a/render/html.c b/render/html.c
index f90d1ee..812c690 100644
--- a/render/html.c
+++ b/render/html.c
@@ -336,7 +336,7 @@ void html_finish_conversion(html_content *c)
* object, but with its target set to the Document object (and
* the currentTarget set to the Window object)
*/
- js_fire_event(c->jscontext, "load", NULL);
+ js_fire_event(c->jscontext, "load", c->document, NULL);
/* convert dom tree to box tree */
LOG(("DOM to box (%p)", c));
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 2b6bc9a..8dd613b 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -42,6 +42,7 @@
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "render/textinput.h"
+#include "javascript/js.h"
#include "utils/messages.h"
#include "utils/utils.h"
@@ -323,6 +324,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
int padding_left, padding_right, padding_top, padding_bottom;
browser_drag_type drag_type = browser_window_get_drag_type(bw);
union content_msg_data msg_data;
+ struct dom_node *node = NULL;
if (drag_type != DRAGGING_NONE && !mouse &&
html->visible_select_menu != NULL) {
@@ -389,7 +391,8 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
/* search the box tree for a link, imagemap, form control, or
- * box with scrollbars */
+ * box with scrollbars
+ */
box = html->layout;
@@ -397,14 +400,17 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
box_x = box->margin[LEFT];
box_y = box->margin[TOP];
- while ((next_box = box_at_point(box, x, y, &box_x, &box_y)) !=
- NULL) {
+ while ((next_box = box_at_point(box, x, y, &box_x, &box_y)) != NULL) {
box = next_box;
if (box->style && css_computed_visibility(box->style) ==
CSS_VISIBILITY_HIDDEN)
continue;
+ if (box->node != NULL) {
+ node = box->node;
+ }
+
if (box->object) {
if (content_get_type(box->object) == CONTENT_HTML) {
html_object_box = box;
@@ -447,11 +453,12 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
pointer = get_pointer_shape(box, false);
- if ((box->scroll_x != NULL || box->scroll_y != NULL) &&
- drag_candidate == NULL)
- drag_candidate = box;
-
if (box->scroll_y != NULL || box->scroll_x != NULL) {
+
+ if (drag_candidate == NULL) {
+ drag_candidate = box;
+ }
+
padding_left = box_x +
scrollbar_get_offset(box->scroll_x);
padding_right = padding_left + box->padding[LEFT] +
@@ -842,6 +849,12 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
content_broadcast(c, CONTENT_MSG_POINTER, msg_data);
}
+ /* fire dom click event */
+ if ((mouse & BROWSER_MOUSE_CLICK_1) ||
+ (mouse & BROWSER_MOUSE_CLICK_2)) {
+ js_fire_event(html->jscontext, "click", html->document, node);
+ }
+
/* deferred actions that can cause this browser_window to be destroyed
* and must therefore be done after set_status/pointer
*/
diff --git a/test/js/event-onload.html b/test/js/event-onload.html
index aede985..cd9e705 100644
--- a/test/js/event-onload.html
+++ b/test/js/event-onload.html
@@ -6,9 +6,7 @@
function addTextNode()
{
-var newtext = document.createTextNode(" Some text added dynamically. ");
-var para = document.getElementById("p1");
-para.appendChild(newtext);
+para.appendChild(document.createTextNode(" Some text added dynamically. "));
}
</script>
@@ -19,10 +17,14 @@ para.appendChild(newtext);
<p id="p1">First line of paragraph.<br /></p>
</div><br />
-<button onclick="addTextNode();">add another textNode.</button>
+<button id="button1" >add another textNode.</button>
<script>
+var button = document.getElementById("button1");
+var para = document.getElementById("p1");
+
window.onload = addTextNode;
+button.onclick = addTextNode;
</script>
</body>
-----------------------------------------------------------------------
Summary of changes:
javascript/js.h | 5 +++-
javascript/jsapi.c | 46 +++++++++++++++++++++++++++++++++++++-------
render/html.c | 2 +-
render/html_interaction.c | 27 +++++++++++++++++++------
test/js/event-onload.html | 10 +++++---
5 files changed, 69 insertions(+), 21 deletions(-)
diff --git a/javascript/js.h b/javascript/js.h
index 4dd8f15..d7943b1 100644
--- a/javascript/js.h
+++ b/javascript/js.h
@@ -51,7 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
+typedef struct dom_document dom_document;
+typedef struct dom_node dom_node;
+
/* fire an event at a dom node */
-bool js_fire_event(jscontext *ctx, const char *type, void *target);
+bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target);
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index bec5653..e5b4ddf 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -153,7 +153,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
dom_exception _dom_event_create(dom_document *doc, dom_event **evt);
#define dom_event_create(d, e) _dom_event_create((dom_document *)(d), (dom_event **) (e))
-bool js_fire_event(jscontext *ctx, const char *type, void *target)
+bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target)
{
JSContext *cx = (JSContext *)ctx;
dom_node *node = target;
@@ -165,18 +165,23 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
dom_event *event;
dom_string *type_dom;
+ if (cx == NULL) {
+ return false;
+ }
+
if (node == NULL) {
- /* deliver to window */
- if (cx == NULL) {
- return false;
- }
+ /* deliver manufactured event to window */
+ JSLOG("Dispatching event %s at window", type);
- exc = dom_string_create((unsigned char*)type, strlen(type), &type_dom);
+ /* create and initialise and event object */
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
+ &type_dom);
if (exc != DOM_NO_ERR) {
return false;
}
- exc = dom_event_create(-1, &event);
+ exc = dom_event_create(doc, &event);
if (exc != DOM_NO_ERR) {
return false;
}
@@ -192,6 +197,7 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
return false;
}
+ /* dispatch event at the window object */
argv[0] = OBJECT_TO_JSVAL(jsevent);
ret = JS_CallFunctionName(cx,
@@ -200,7 +206,31 @@ bool js_fire_event(jscontext *ctx, const char *type, void *target)
1,
argv,
&rval);
- }
+ } else {
+ JSLOG("Dispatching event %s at %p", type, node);
+
+ /* create and initialise and event object */
+ exc = dom_string_create((unsigned char*)type,
+ strlen(type),
+ &type_dom);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ exc = dom_event_create(doc, &event);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ exc = dom_event_init(event, type_dom, true, true);
+ dom_string_unref(type_dom);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ dom_event_target_dispatch_event(node, event, &ret);
+
+ }
if (ret == JS_TRUE) {
return true;
diff --git a/render/html.c b/render/html.c
index f90d1ee..812c690 100644
--- a/render/html.c
+++ b/render/html.c
@@ -336,7 +336,7 @@ void html_finish_conversion(html_content *c)
* object, but with its target set to the Document object (and
* the currentTarget set to the Window object)
*/
- js_fire_event(c->jscontext, "load", NULL);
+ js_fire_event(c->jscontext, "load", c->document, NULL);
/* convert dom tree to box tree */
LOG(("DOM to box (%p)", c));
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 2b6bc9a..8dd613b 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -42,6 +42,7 @@
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "render/textinput.h"
+#include "javascript/js.h"
#include "utils/messages.h"
#include "utils/utils.h"
@@ -323,6 +324,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
int padding_left, padding_right, padding_top, padding_bottom;
browser_drag_type drag_type = browser_window_get_drag_type(bw);
union content_msg_data msg_data;
+ struct dom_node *node = NULL;
if (drag_type != DRAGGING_NONE && !mouse &&
html->visible_select_menu != NULL) {
@@ -389,7 +391,8 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
/* search the box tree for a link, imagemap, form control, or
- * box with scrollbars */
+ * box with scrollbars
+ */
box = html->layout;
@@ -397,14 +400,17 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
box_x = box->margin[LEFT];
box_y = box->margin[TOP];
- while ((next_box = box_at_point(box, x, y, &box_x, &box_y)) !=
- NULL) {
+ while ((next_box = box_at_point(box, x, y, &box_x, &box_y)) != NULL) {
box = next_box;
if (box->style && css_computed_visibility(box->style) ==
CSS_VISIBILITY_HIDDEN)
continue;
+ if (box->node != NULL) {
+ node = box->node;
+ }
+
if (box->object) {
if (content_get_type(box->object) == CONTENT_HTML) {
html_object_box = box;
@@ -447,11 +453,12 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
pointer = get_pointer_shape(box, false);
- if ((box->scroll_x != NULL || box->scroll_y != NULL) &&
- drag_candidate == NULL)
- drag_candidate = box;
-
if (box->scroll_y != NULL || box->scroll_x != NULL) {
+
+ if (drag_candidate == NULL) {
+ drag_candidate = box;
+ }
+
padding_left = box_x +
scrollbar_get_offset(box->scroll_x);
padding_right = padding_left + box->padding[LEFT] +
@@ -842,6 +849,12 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
content_broadcast(c, CONTENT_MSG_POINTER, msg_data);
}
+ /* fire dom click event */
+ if ((mouse & BROWSER_MOUSE_CLICK_1) ||
+ (mouse & BROWSER_MOUSE_CLICK_2)) {
+ js_fire_event(html->jscontext, "click", html->document, node);
+ }
+
/* deferred actions that can cause this browser_window to be destroyed
* and must therefore be done after set_status/pointer
*/
diff --git a/test/js/event-onload.html b/test/js/event-onload.html
index aede985..cd9e705 100644
--- a/test/js/event-onload.html
+++ b/test/js/event-onload.html
@@ -6,9 +6,7 @@
function addTextNode()
{
-var newtext = document.createTextNode(" Some text added dynamically. ");
-var para = document.getElementById("p1");
-para.appendChild(newtext);
+para.appendChild(document.createTextNode(" Some text added dynamically. "));
}
</script>
@@ -19,10 +17,14 @@ para.appendChild(newtext);
<p id="p1">First line of paragraph.<br /></p>
</div><br />
-<button onclick="addTextNode();">add another textNode.</button>
+<button id="button1" >add another textNode.</button>
<script>
+var button = document.getElementById("button1");
+var para = document.getElementById("p1");
+
window.onload = addTextNode;
+button.onclick = addTextNode;
</script>
</body>
--
NetSurf Browser
10 years, 1 month
netsurf: branch mono/removing-windom-dependency updated. 2c5b24d717613211ea4d9c805c19c12436397ec0
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2c5b24d717613211ea4d9...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2c5b24d717613211ea4d9c8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2c5b24d717613211ea4d9c805...
The branch, mono/removing-windom-dependency has been updated
via 2c5b24d717613211ea4d9c805c19c12436397ec0 (commit)
via 59e2775055ac4cd4a42b1ff510b1255e17afdfbb (commit)
via e697603f12c73e11fe3b6a3cadf2f6ae3e22addc (commit)
via d5f0ea51557fb6a6a6830b600d36f6b365ed180a (commit)
from 40313798ee3024a530f2d677155290775526899e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/2c5b24d717613211ea4...
commit 2c5b24d717613211ea4d9c805c19c12436397ec0
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Implemented scrolling for gui windows.
Doesn't work correctly for drag-scrolling, because gemtk
schedules window messages for redraw regions... the rectangle
list must be managed by gemtk...
diff --git a/atari/gui.c b/atari/gui.c
index 8429c15..d930b0c 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -116,9 +116,11 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
+
+
void gui_poll(bool active)
{
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_M1 | MU_MX;
short mx, my, dummy;
unsigned short nkc = 0;
@@ -172,12 +174,17 @@ void gui_poll(bool active)
}
}
- if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ if((aes_event_out.emo_events & MU_KEYBD) != 0) {
uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
(short)aes_event_out.emo_kreturn);
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
aes_event_out.emo_kmeta, nkc);
}
+/*
+ if((aes_event_out.emo_events & MU_KEYBD|MU_MX) != 0) {
+ on_m1();
+ }
+*/
}
} while ( gui_poll_repeat && !(active||rendering));
@@ -376,34 +383,24 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
+ int x,y;
if (w == NULL)
return false;
- *sx = w->browser->scroll.current.x;
- *sy = w->browser->scroll.current.y;
+
+ window_get_scroll(w->root, &x, &y);
return( true );
}
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- if ((w == NULL) ||
- (w->browser->bw == NULL) ||
- (w->browser->bw->current_content == NULL))
- return;
- if( sx != 0 ) {
- if( sx < 0 ) {
- browser_scroll(w, WA_LFLINE, abs(sx), true );
- } else {
- browser_scroll(w, WA_RTLINE, abs(sx), true );
- }
- }
-
- if( sy != 0 ) {
- if( sy < 0) {
- browser_scroll(w, WA_UPLINE, abs(sy), true );
- } else {
- browser_scroll(w, WA_DNLINE, abs(sy), true );
- }
- }
+ int units = 0;
+ if ((w == NULL)
+ || (w->browser->bw == NULL)
+ || (w->browser->bw->current_content == NULL))
+ return;
+
+ printf("scroll %d, %d\n", sx, sy);
+ window_scroll_by(w->root, sx, sy);
return;
}
@@ -411,8 +408,9 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
{
LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
+ printf("scroll visible\n");
gui_window_set_scroll(w,x0,y0);
- browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
+ //browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
}
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 20fbc49..9806852 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -160,6 +160,10 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_content_mouse_click(data->rootwin);
}
}
+ if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ }
return(retval);
}
@@ -358,6 +362,37 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
+void window_scroll_by(ROOTWIN *root, int sx, int sy)
+{
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if (sx != 0) {
+ units = sx / slid->x_unit_px;
+ if (units == 0) {
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
+ }
+
+ guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
+ if (sy != 0) {
+ units = sy / slid->y_unit_px;
+ if( sx < 0 ) {
+ // units = -units;
+ }
+ if(units == 0){
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ }
+}
+
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
{
GRECT area;
@@ -456,6 +491,16 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
return(rootwin->active_gui_window);
}
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
+{
+ struct guiwin_scroll_info_s *slid;
+
+ slid = guiwin_get_scroll_info(rootwin->win);
+
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
+}
+
/**
* Redraw the favicon
@@ -689,7 +734,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* Detect left mouse button state and compare with event state: */
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
- if( (mbut & 1) && (evnt.mbut & 1) ) {
+ if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
/* Mouse still pressed, report drag */
rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
@@ -711,10 +756,14 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
rel_cur_x, rel_cur_y);
}
}
+
// we may need to process scrolling:
- if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ // TODO: this doesn't work, because gemtk schedules redraw via
+ // AES window messages but we do not process them right here...
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
@@ -722,7 +771,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
} else {
/* Right button pressed? */
- if( (evnt.mbut & 2 ) ) {
+ if ((aes_event_out.emo_mbutton & 2 ) ) {
context_popup( gw, aes_event_out.emo_mouse.p_x,
aes_event_out.emo_mouse.p_x);
} else {
@@ -734,6 +783,9 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
sx_origin,sy_origin);
}
}
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
}
/*
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 85aeff9..7eb5539 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -41,37 +41,35 @@
int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
-int window_destroy(struct s_gui_win_root * rootwin);
+int window_destroy(ROOTWIN *rootwin);
/* show the window */
-void window_open(struct s_gui_win_root * rootwin, GRECT pos);
+void window_open(ROOTWIN *rootwin, GRECT pos);
-void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
- short w, short h );
+void window_snd_redraw(ROOTWIN *rootwin, short x, short y, short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
-void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
+void window_attach_browser(ROOTWIN *rootwin, CMP_BROWSER b);
/* set focus element */
-void window_set_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type type, void * element );
-/* adjust scroll settings */
-void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
- int content_w);
+void window_set_focus(ROOTWIN *rootwin, enum focus_element_type type,
+ void * element );
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type t, void * element);
-bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
-void window_set_url(struct s_gui_win_root * rootwin, const char * text);
-void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
-void window_set_title(struct s_gui_win_root * rootwin, char * text);
-void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
-void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
+bool window_widget_has_focus(ROOTWIN *rootwin, enum focus_element_type t,
+ void * element);
+bool window_url_widget_has_focus(ROOTWIN *rootwin);
+void window_set_url(ROOTWIN *rootwin, const char * text);
+void window_set_stauts(ROOTWIN *rootwin, char * text);
+void window_set_title(ROOTWIN *rootwin, char * text);
+void window_set_content_size(ROOTWIN *rootwin, int w, int h);
+void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+void window_scroll_by(ROOTWIN *rootwin, int x, int y);
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
bool window_key_input(unsigned short kcode, unsigned short kstate,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/59e2775055ac4cd4a42...
commit 59e2775055ac4cd4a42b1ff510b1255e17afdfbb
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Implemented basic mouse input to browser component (click).
diff --git a/atari/gui.c b/atari/gui.c
index b11777b..8429c15 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -181,7 +181,7 @@ void gui_poll(bool active)
}
} while ( gui_poll_repeat && !(active||rendering));
- if(input_window->root->redraw_slots.areas_used > 0){
+ if(input_window && input_window->root->redraw_slots.areas_used > 0){
window_process_redraws(input_window->root);
}
}
@@ -213,7 +213,7 @@ gui_create_browser_window(struct browser_window *bw,
window_set_active_gui_window(gw->root, gw);
window_open(gw->root, pos );
/* Recalculate windows browser area now */
- input_window = gw;
+ gui_set_input_gui_window(gw);
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -243,7 +243,9 @@ void gui_window_destroy(struct gui_window *w)
LOG(("%s\n", __FUNCTION__ ));
- input_window = NULL;
+ if (input_window == w) {
+ gui_set_input_gui_window(NULL);
+ }
search_destroy(w);
browser_destroy(w->browser);
@@ -270,7 +272,7 @@ void gui_window_destroy(struct gui_window *w)
w = window_list;
while( w != NULL ) {
if(w->root) {
- input_window = w;
+ gui_set_input_gui_window(w);
break;
}
w = w->next;
@@ -431,6 +433,9 @@ void gui_window_update_extent(struct gui_window *gw)
content_get_height(gw->browser->bw->current_content)
);
window_update_back_forward(gw->root);
+ GRECT area;
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
+ window_schedule_redraw_grect(gw->root, &area);
}
}
}
@@ -858,6 +863,12 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
cb(bres, cbpw);
}
+void gui_set_input_gui_window(struct gui_window *gw)
+{
+ LOG(("Setting input window from: %p to %p\n", input_window, gw));
+ input_window = gw;
+}
+
void gui_quit(void)
{
LOG((""));
diff --git a/atari/gui.h b/atari/gui.h
index 8860191..7bedd2b 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -131,4 +131,9 @@ struct gui_window {
extern struct gui_window *window_list;
+/* -------------------------------------------------------------------------- */
+/* Public - non standard gui window functions */
+/* -------------------------------------------------------------------------- */
+void gui_set_input_gui_window(struct gui_window *gw);
+
#endif
diff --git a/atari/misc.c b/atari/misc.c
index 22f820e..f12556b 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -502,19 +502,19 @@ void dbg_lgrect( char * str, LGRECT * r )
r->g_x, r->g_y, r->g_w, r->g_h );
}
-void dbg_grect( char * str, GRECT * r )
+void dbg_grect(const char * str, GRECT * r)
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
r->g_x, r->g_y, r->g_w, r->g_h );
}
-void dbg_pxy( char * str, short * pxy )
+void dbg_pxy(const char * str, short * pxy )
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
pxy[0], pxy[1], pxy[2], pxy[3] );
}
-void dbg_rect( char * str, int * pxy )
+void dbg_rect(const char * str, int * pxy)
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
pxy[0], pxy[1], pxy[2], pxy[3] );
diff --git a/atari/misc.h b/atari/misc.h
index cab2a8c..b59f19d 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -1,22 +1,22 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * 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/>.
- */
-
-#ifndef NS_ATARI_MISC_H
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * 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/>.
+ */
+
+#ifndef NS_ATARI_MISC_H
#define NS_ATARI_MISC_H
#include <windom.h>
@@ -25,36 +25,37 @@
#include "content/hlcache.h"
#include "desktop/textinput.h"
#include "atari/gui.h"
-
-#define SBUF8_TO_LBUF8(sbuf,lbuf)\
- lbuf[0] = (long)sbuf[0];\
- lbuf[1] = (long)sbuf[1];\
- lbuf[2] = (long)sbuf[2];\
- lbuf[3] = (long)sbuf[3];\
- lbuf[4] = (long)sbuf[4];\
- lbuf[5] = (long)sbuf[5];\
- lbuf[6] = (long)sbuf[6];\
- lbuf[7] = (long)sbuf[7];
-
+
+#define SBUF8_TO_LBUF8(sbuf,lbuf)\
+ lbuf[0] = (long)sbuf[0];\
+ lbuf[1] = (long)sbuf[1];\
+ lbuf[2] = (long)sbuf[2];\
+ lbuf[3] = (long)sbuf[3];\
+ lbuf[4] = (long)sbuf[4];\
+ lbuf[5] = (long)sbuf[5];\
+ lbuf[6] = (long)sbuf[6];\
+ lbuf[7] = (long)sbuf[7];
+
/* Modes for find_gui_window: */
#define BY_WINDOM_HANDLE 0x0
#define BY_GEM_HANDLE 0x1
typedef int (*scan_process_callback)(int pid, void *data);
-
-struct gui_window * find_guiwin_by_aes_handle(short handle);
-bool is_process_running(const char * name);
+
+struct gui_window * find_guiwin_by_aes_handle(short handle);
+bool is_process_running(const char * name);
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
- void * pw );
-void dbg_grect( char * str, GRECT * r );
-void dbg_lgrect( char * str, LGRECT * r );
-void dbg_pxy( char * str, short * pxy );
-void * ldg_open( char * name, short * global );
-void * ldg_find( char * name, short * ldg );
+ void * pw );
+void dbg_grect(const char * str, GRECT * r);
+void dbg_lgrect( char * str, LGRECT * r);
+void dbg_pxy(const char * str, short * pxy);
+void dbg_rect(const char * str, int * pxy);
+void * ldg_open( char * name, short * global );
+void * ldg_find( char * name, short * ldg );
const char * file_select( const char * title, const char * name );
int ldg_close( void * ldg, short * global );
long nkc_to_input_key(short nkc, long * ucs4_out);
-#endif
+#endif
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 121a228..20fbc49 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -61,6 +61,7 @@
#include "atari/gemtk/gemtk.h"
extern struct gui_window *input_window;
+extern EVMULT_OUT aes_event_out;
struct rootwin_data_s {
struct s_gui_win_root *rootwin;
@@ -69,21 +70,14 @@ struct rootwin_data_s {
/* -------------------------------------------------------------------------- */
/* Static module methods */
/* -------------------------------------------------------------------------- */
-static void redraw(ROOTWIN *rootwin, short msg[8]);
-static void resized(ROOTWIN *rootwin);
-static void file_dropped(ROOTWIN *rootwin, short msg[8]);
-static short key_input(ROOTWIN * rootwin, unsigned short kcode,
- unsigned short kstate, unsigned short nkc);
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-
-#define FIND_NS_GUI_WINDOW(w) \
- find_guiwin_by_aes_handle(guiwin_get_handle(w));
+static void on_redraw(ROOTWIN *rootwin, short msg[8]);
+static void on_resized(ROOTWIN *rootwin);
+static void on_file_dropped(ROOTWIN *rootwin, short msg[8]);
+static short on_window_key_input(ROOTWIN * rootwin, unsigned short nkc);
+static bool on_content_mouse_click(ROOTWIN *rootwin);
static bool redraw_active = false;
-
static const struct redraw_context rootwin_rdrw_ctx = {
.interactive = true,
.background_images = true,
@@ -100,24 +94,23 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
short retval = 0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
- if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
printf("root win msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
- redraw(data->rootwin, msg);
+ on_redraw(data->rootwin, msg);
break;
case WM_REPOSED:
case WM_SIZED:
case WM_MOVED:
case WM_FULLED:
- resized(data->rootwin);
+ on_resized(data->rootwin);
break;
case WM_ICONIFY:
-
if( input_window->root == data->rootwin) {
input_window = NULL;
}
@@ -139,12 +132,10 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case AP_DRAGDROP:
- file_dropped(data->rootwin, msg);
+ on_file_dropped(data->rootwin, msg);
break;
case WM_TOOLBAR:
- printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, msg[4]);
toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
break;
@@ -152,24 +143,22 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
}
}
- if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ if ((ev_out->emo_events & MU_KEYBD) != 0) {
// handle key
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
(short)ev_out->emo_kreturn);
- retval = key_input(data->rootwin, ev_out->emo_kreturn,
- ev_out->emo_kmeta, nkc);
+ retval = on_window_key_input(data->rootwin, nkc);
}
- if( (ev_out->emo_events & MU_TIMER) != 0 ) {
- // handle_timer();
- }
- if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ if ((ev_out->emo_events & MU_BUTTON) != 0) {
LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y));
- printf("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
- //handle_mbutton(gw, ev_out);
+ GRECT carea;
+ guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT, &carea);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, carea)) {
+ on_content_mouse_click(data->rootwin);
+ }
}
return(retval);
@@ -267,7 +256,7 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
// find the next active tab:
while( w != NULL ) {
if(w->root == rootwin && w != gw) {
- input_window = w;
+ gui_set_input_gui_window(w);
break;
}
w = w->next;
@@ -378,6 +367,7 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
slid->x_units = (width/slid->x_unit_px);
slid->y_units = (height/slid->y_unit_px);
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
+ // TODO: reset slider to 0
}
/* set focus to an arbitary element */
@@ -595,6 +585,14 @@ void window_process_redraws(ROOTWIN * rootwin)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
+ short pxy_clip[4];
+
+ pxy_clip[0] = tb_area.g_x;
+ pxy_clip[0] = tb_area.g_y;
+ pxy_clip[0] = pxy_clip[0] + tb_area.g_w + content_area.g_w - 1;
+ pxy_clip[0] = pxy_clip[1] + tb_area.g_h + content_area.g_h - 1;
+ vs_clip(guiwin_get_vdi_handle(rootwin->win), 1, pxy_clip);
+
while(plot_lock() == false);
wind_get_grect(aes_handle, WF_FIRSTXYWH, &visible_ro);
@@ -631,6 +629,7 @@ void window_process_redraws(ROOTWIN * rootwin)
}
wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro);
}
+ vs_clip(guiwin_get_vdi_handle(rootwin->win), 0, pxy_clip);
rootwin->redraw_slots.areas_used = 0;
redraw_active = false;
@@ -642,114 +641,177 @@ void window_process_redraws(ROOTWIN * rootwin)
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
+static bool on_content_mouse_click(ROOTWIN *rootwin)
{
- bool abs = false;
+ short dummy, mbut, mx, my;
GRECT cwork;
- struct gui_window * gw = data;
- int value = BROWSER_SCROLL_SVAL;
-
- assert( gw != NULL );
-
- browser_get_rect(gw, BR_CONTENT, &cwork );
+ browser_mouse_state bmstate = 0;
+ struct gui_window *gw;
+ struct guiwin_scroll_info_s *slid;
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
+ gw = window_get_active_gui_window(rootwin);
+ if( input_window != gw ) {
+ input_window = gw;
+ }
+ window_set_focus(gw->root, BROWSER, (void*)gw->browser );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &cwork);
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
+ /* convert screen coords to component coords: */
+ mx = aes_event_out.emo_mouse.p_x - cwork.g_x;
+ my = aes_event_out.emo_mouse.p_y - cwork.g_y;
- default:
- break;
+ /* Translate GEM key state to netsurf mouse modifier */
+ if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
+ bmstate |= BROWSER_MOUSE_MOD_1;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_1);
+ }
+ if ( (aes_event_out.emo_kmeta & K_CTRL) ) {
+ bmstate |= BROWSER_MOUSE_MOD_2;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_2);
+ }
+ if ( (aes_event_out.emo_kmeta & K_ALT) ) {
+ bmstate |= BROWSER_MOUSE_MOD_3;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_3);
+ }
+
+ /* convert component coords to scrolled content coords: */
+ slid = guiwin_get_scroll_info(rootwin->win);
+ int sx_origin = (mx + slid->x_pos * slid->x_unit_px);
+ int sy_origin = (my + slid->y_pos * slid->y_unit_px);
+
+ short rel_cur_x, rel_cur_y;
+ short prev_x=sx_origin, prev_y=sy_origin;
+ bool dragmode = false;
+
+ /* Detect left mouse button state and compare with event state: */
+ graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
+ if( (mbut & 1) && (evnt.mbut & 1) ) {
+ /* Mouse still pressed, report drag */
+ rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ browser_window_mouse_click( gw->browser->bw,
+ BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
+ sx_origin, sy_origin);
+ do {
+ // only consider movements of 5px or more as drag...:
+ if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
+ browser_window_mouse_track( gw->browser->bw,
+ BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
+ rel_cur_x, rel_cur_y);
+ prev_x = rel_cur_x;
+ prev_y = rel_cur_y;
+ dragmode = true;
+ } else {
+ if( dragmode == false ) {
+ browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
+ rel_cur_x, rel_cur_y);
+ }
+ }
+ // we may need to process scrolling:
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+ graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
+ rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ } while( mbut & 1 );
+ browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
+ } else {
+ /* Right button pressed? */
+ if( (evnt.mbut & 2 ) ) {
+ context_popup( gw, aes_event_out.emo_mouse.p_x,
+ aes_event_out.emo_mouse.p_x);
+ } else {
+ browser_window_mouse_click(gw->browser->bw,
+ bmstate|BROWSER_MOUSE_PRESS_1,
+ sx_origin,sy_origin);
+ browser_window_mouse_click(gw->browser->bw,
+ bmstate|BROWSER_MOUSE_CLICK_1,
+ sx_origin,sy_origin);
+ }
}
- browser_scroll( gw, buff[4], value, abs );
}
+/*
+ Report keypress to browser component.
+ parameter:
+ - unsigned short nkc ( CFLIB normalised key code )
+*/
+static bool on_content_keypress(struct browser_window *bw, unsigned short nkc)
+{
+ bool r = false;
+ unsigned char ascii = (nkc & 0xFF);
+ long ucs4;
+ long ik = nkc_to_input_key( nkc, &ucs4 );
+
+ // pass event to specific control?
+
+ if (ik == 0) {
+ if (ascii >= 9) {
+ r = browser_window_key_press(bw, ucs4);
+ }
+ } else {
+ r = browser_window_key_press(bw, ik);
+ if (r == false) {
+
+ GRECT g;
+ GUIWIN * w = bw->window->root->win;
+ guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
+
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
+
+ switch( ik ) {
+ case KEY_LINE_START:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ false);
+ break;
-/*
- Report keypress to browser component.
- The browser component doesn't listen for keyinput by itself.
- parameter:
- - gui_window ( compocnent owner ).
- - unsigned short nkc ( CFLIB normalised key code )
-*/
-static bool content_input(struct browser_window *bw, unsigned short nkc)
-{
- bool r = false;
- unsigned char ascii = (nkc & 0xFF);
- long ucs4;
- long ik = nkc_to_input_key( nkc, &ucs4 );
-
- // pass event to specific control?
-
- if (ik == 0){
- if (ascii >= 9) {
- r = browser_window_key_press(bw, ucs4);
- }
- } else {
- r = browser_window_key_press(bw, ik);
- if (r == false){
-
- GRECT g;
- GUIWIN * w = bw->window->root->win;
- guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
-
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
-
- switch( ik ){
- case KEY_LINE_START:
- guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
- false);
- break;
-
- case KEY_LINE_END:
- guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
- false);
- break;
-
- case KEY_PAGE_UP:
- guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
- false);
- break;
-
- case KEY_PAGE_DOWN:
- guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
- false);
- break;
-
- case KEY_RIGHT:
- guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
- break;
-
- case KEY_LEFT:
- guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
- break;
-
- case KEY_UP:
- guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
- break;
-
- case KEY_DOWN:
- guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
- break;
-
- default:
- break;
- }
- }
- }
-
- return( r );
+ case KEY_LINE_END:
+ guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_RIGHT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
+ break;
+
+ case KEY_LEFT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
+ break;
+
+ case KEY_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
+ break;
+
+ case KEY_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
+ break;
+
+ default:
+ break;
+ }
+ guiwin_update_slider(w, GUIWIN_VSLIDER|GUIWIN_HSLIDER);
+ }
+ }
+
+ return(r);
}
-static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
+static short on_window_key_input(ROOTWIN *rootwin, unsigned short nkc)
{
bool done = false;
struct gui_window * gw = window_get_active_gui_window(rootwin);
@@ -758,9 +820,6 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
if( gw == NULL )
return(false);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
-
if(window_url_widget_has_focus((void*)gw->root)) {
/* make sure we report for the root window and report...: */
done = toolbar_key_input(gw->root->toolbar, nkc);
@@ -771,7 +830,7 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
/* todo: only handle when input_window == ontop */
if( window_widget_has_focus(input_window->root, BROWSER,
(void*)gw_tmp->browser)) {
- done = content_input(gw_tmp->browser->bw, nkc);
+ done = on_content_keypress(gw_tmp->browser->bw, nkc);
break;
} else {
gw_tmp = gw_tmp->next;
@@ -782,39 +841,7 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
}
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
-{
- LOG(("%s\n", __FUNCTION__ ));
-}
-
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
-{
- int dx = buff[4];
- int dy = buff[5];
- struct gui_window * gw = data;
-
- if (!dx && !dy) return;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
-
- /* update the sliders _before_ we call redraw
- (which might depend on the slider possitions) */
- WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
-
- if( dy > 0 )
- browser_scroll( gw, WA_DNPAGE, abs(dy), false );
- else if ( dy < 0)
- browser_scroll( gw, WA_UPPAGE, abs(dy), false );
- if( dx > 0 )
- browser_scroll( gw, WA_RTPAGE, abs(dx), false );
- else if( dx < 0 )
- browser_scroll( gw, WA_LFPAGE, abs(dx), false );
-}
-
-static void redraw(ROOTWIN *rootwin, short msg[8])
+static void on_redraw(ROOTWIN *rootwin, short msg[8])
{
short handle;
@@ -828,7 +855,7 @@ static void redraw(ROOTWIN *rootwin, short msg[8])
}
}
-static void resized(ROOTWIN *rootwin)
+static void on_resized(ROOTWIN *rootwin)
{
GRECT g;
short handle;
@@ -864,7 +891,7 @@ static void resized(ROOTWIN *rootwin)
toolbar_set_dimensions(rootwin->toolbar, &g);
}
-static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
+static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
{
char file[DD_NAMEMAX];
char name[DD_NAMEMAX];
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/e697603f12c73e11fe3...
commit e697603f12c73e11fe3b6a3cadf2f6ae3e22addc
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Use module variable h_gem_menu instead of local variable
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index eb13784..568d7a9 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -152,11 +152,9 @@ struct s_menu_item_evnt menu_evnt_tbl[] =
*/
static void register_menu_str( struct s_menu_item_evnt * mi )
{
- OBJECT *gem_menu = deskmenu_get_obj_tree();
+ assert(h_gem_menu != NULL);
- assert(gem_menu != NULL);
-
- char * str = ObjcString( gem_menu, mi->rid, NULL );
+ char * str = ObjcString(h_gem_menu, mi->rid, NULL );
int l = strlen(str);
int i = l;
int x = -1;
@@ -421,7 +419,7 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER,
+ menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER,
(html_redraw_debug) ? 1 : 0);
}
}
@@ -430,14 +428,14 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
static void __CDECL menu_fg_images(short item, short title, void *data)
{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
(nsoption_bool(foreground_images)) ? 1 : 0);
}
static void __CDECL menu_bg_images(short item, short title, void *data)
{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
(nsoption_bool(background_images)) ? 1 : 0);
}
@@ -501,7 +499,7 @@ static void __CDECL menu_vlog(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
verbose_log = !verbose_log;
- menu_icheck(gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
+ menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
}
static void __CDECL menu_help_content(short item, short title, void *data)
@@ -652,12 +650,10 @@ int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
*/
void deskmenu_update(void)
{
- OBJECT * gem_menu = deskmenu_get_obj_tree();
-
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
(nsoption_bool(foreground_images)) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
(nsoption_bool(background_images)) ? 1 : 0);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/d5f0ea51557fb6a6a68...
commit d5f0ea51557fb6a6a6830b600d36f6b365ed180a
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Replaces MenuIcheck() with calls to menu_icheck()
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 2502184..eb13784 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -421,8 +421,8 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
+ menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0);
}
}
}
@@ -430,14 +430,14 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
static void __CDECL menu_fg_images(short item, short title, void *data)
{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
(nsoption_bool(foreground_images)) ? 1 : 0);
}
static void __CDECL menu_bg_images(short item, short title, void *data)
{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
(nsoption_bool(background_images)) ? 1 : 0);
}
@@ -500,8 +500,8 @@ static void __CDECL menu_bookmarks(short item, short title, void *data)
static void __CDECL menu_vlog(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+ verbose_log = !verbose_log;
+ menu_icheck(gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
}
static void __CDECL menu_help_content(short item, short title, void *data)
-----------------------------------------------------------------------
Summary of changes:
atari/deskmenu.c | 26 ++--
atari/gui.c | 65 +++++----
atari/gui.h | 5 +
atari/misc.c | 6 +-
atari/misc.h | 81 ++++++------
atari/rootwin.c | 407 ++++++++++++++++++++++++++++++++----------------------
atari/rootwin.h | 34 ++---
7 files changed, 356 insertions(+), 268 deletions(-)
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 2502184..568d7a9 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -152,11 +152,9 @@ struct s_menu_item_evnt menu_evnt_tbl[] =
*/
static void register_menu_str( struct s_menu_item_evnt * mi )
{
- OBJECT *gem_menu = deskmenu_get_obj_tree();
+ assert(h_gem_menu != NULL);
- assert(gem_menu != NULL);
-
- char * str = ObjcString( gem_menu, mi->rid, NULL );
+ char * str = ObjcString(h_gem_menu, mi->rid, NULL );
int l = strlen(str);
int i = l;
int x = -1;
@@ -421,8 +419,8 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
+ menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0);
}
}
}
@@ -430,14 +428,14 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
static void __CDECL menu_fg_images(short item, short title, void *data)
{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
(nsoption_bool(foreground_images)) ? 1 : 0);
}
static void __CDECL menu_bg_images(short item, short title, void *data)
{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
(nsoption_bool(background_images)) ? 1 : 0);
}
@@ -500,8 +498,8 @@ static void __CDECL menu_bookmarks(short item, short title, void *data)
static void __CDECL menu_vlog(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+ verbose_log = !verbose_log;
+ menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
}
static void __CDECL menu_help_content(short item, short title, void *data)
@@ -652,12 +650,10 @@ int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
*/
void deskmenu_update(void)
{
- OBJECT * gem_menu = deskmenu_get_obj_tree();
-
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
(nsoption_bool(foreground_images)) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
(nsoption_bool(background_images)) ? 1 : 0);
}
diff --git a/atari/gui.c b/atari/gui.c
index b11777b..d930b0c 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -116,9 +116,11 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
+
+
void gui_poll(bool active)
{
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_M1 | MU_MX;
short mx, my, dummy;
unsigned short nkc = 0;
@@ -172,16 +174,21 @@ void gui_poll(bool active)
}
}
- if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ if((aes_event_out.emo_events & MU_KEYBD) != 0) {
uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
(short)aes_event_out.emo_kreturn);
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
aes_event_out.emo_kmeta, nkc);
}
+/*
+ if((aes_event_out.emo_events & MU_KEYBD|MU_MX) != 0) {
+ on_m1();
+ }
+*/
}
} while ( gui_poll_repeat && !(active||rendering));
- if(input_window->root->redraw_slots.areas_used > 0){
+ if(input_window && input_window->root->redraw_slots.areas_used > 0){
window_process_redraws(input_window->root);
}
}
@@ -213,7 +220,7 @@ gui_create_browser_window(struct browser_window *bw,
window_set_active_gui_window(gw->root, gw);
window_open(gw->root, pos );
/* Recalculate windows browser area now */
- input_window = gw;
+ gui_set_input_gui_window(gw);
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -243,7 +250,9 @@ void gui_window_destroy(struct gui_window *w)
LOG(("%s\n", __FUNCTION__ ));
- input_window = NULL;
+ if (input_window == w) {
+ gui_set_input_gui_window(NULL);
+ }
search_destroy(w);
browser_destroy(w->browser);
@@ -270,7 +279,7 @@ void gui_window_destroy(struct gui_window *w)
w = window_list;
while( w != NULL ) {
if(w->root) {
- input_window = w;
+ gui_set_input_gui_window(w);
break;
}
w = w->next;
@@ -374,34 +383,24 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
+ int x,y;
if (w == NULL)
return false;
- *sx = w->browser->scroll.current.x;
- *sy = w->browser->scroll.current.y;
+
+ window_get_scroll(w->root, &x, &y);
return( true );
}
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- if ((w == NULL) ||
- (w->browser->bw == NULL) ||
- (w->browser->bw->current_content == NULL))
- return;
- if( sx != 0 ) {
- if( sx < 0 ) {
- browser_scroll(w, WA_LFLINE, abs(sx), true );
- } else {
- browser_scroll(w, WA_RTLINE, abs(sx), true );
- }
- }
-
- if( sy != 0 ) {
- if( sy < 0) {
- browser_scroll(w, WA_UPLINE, abs(sy), true );
- } else {
- browser_scroll(w, WA_DNLINE, abs(sy), true );
- }
- }
+ int units = 0;
+ if ((w == NULL)
+ || (w->browser->bw == NULL)
+ || (w->browser->bw->current_content == NULL))
+ return;
+
+ printf("scroll %d, %d\n", sx, sy);
+ window_scroll_by(w->root, sx, sy);
return;
}
@@ -409,8 +408,9 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
{
LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
+ printf("scroll visible\n");
gui_window_set_scroll(w,x0,y0);
- browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
+ //browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
}
@@ -431,6 +431,9 @@ void gui_window_update_extent(struct gui_window *gw)
content_get_height(gw->browser->bw->current_content)
);
window_update_back_forward(gw->root);
+ GRECT area;
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
+ window_schedule_redraw_grect(gw->root, &area);
}
}
}
@@ -858,6 +861,12 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
cb(bres, cbpw);
}
+void gui_set_input_gui_window(struct gui_window *gw)
+{
+ LOG(("Setting input window from: %p to %p\n", input_window, gw));
+ input_window = gw;
+}
+
void gui_quit(void)
{
LOG((""));
diff --git a/atari/gui.h b/atari/gui.h
index 8860191..7bedd2b 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -131,4 +131,9 @@ struct gui_window {
extern struct gui_window *window_list;
+/* -------------------------------------------------------------------------- */
+/* Public - non standard gui window functions */
+/* -------------------------------------------------------------------------- */
+void gui_set_input_gui_window(struct gui_window *gw);
+
#endif
diff --git a/atari/misc.c b/atari/misc.c
index 22f820e..f12556b 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -502,19 +502,19 @@ void dbg_lgrect( char * str, LGRECT * r )
r->g_x, r->g_y, r->g_w, r->g_h );
}
-void dbg_grect( char * str, GRECT * r )
+void dbg_grect(const char * str, GRECT * r)
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
r->g_x, r->g_y, r->g_w, r->g_h );
}
-void dbg_pxy( char * str, short * pxy )
+void dbg_pxy(const char * str, short * pxy )
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
pxy[0], pxy[1], pxy[2], pxy[3] );
}
-void dbg_rect( char * str, int * pxy )
+void dbg_rect(const char * str, int * pxy)
{
printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
pxy[0], pxy[1], pxy[2], pxy[3] );
diff --git a/atari/misc.h b/atari/misc.h
index cab2a8c..b59f19d 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -1,22 +1,22 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * 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/>.
- */
-
-#ifndef NS_ATARI_MISC_H
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * 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/>.
+ */
+
+#ifndef NS_ATARI_MISC_H
#define NS_ATARI_MISC_H
#include <windom.h>
@@ -25,36 +25,37 @@
#include "content/hlcache.h"
#include "desktop/textinput.h"
#include "atari/gui.h"
-
-#define SBUF8_TO_LBUF8(sbuf,lbuf)\
- lbuf[0] = (long)sbuf[0];\
- lbuf[1] = (long)sbuf[1];\
- lbuf[2] = (long)sbuf[2];\
- lbuf[3] = (long)sbuf[3];\
- lbuf[4] = (long)sbuf[4];\
- lbuf[5] = (long)sbuf[5];\
- lbuf[6] = (long)sbuf[6];\
- lbuf[7] = (long)sbuf[7];
-
+
+#define SBUF8_TO_LBUF8(sbuf,lbuf)\
+ lbuf[0] = (long)sbuf[0];\
+ lbuf[1] = (long)sbuf[1];\
+ lbuf[2] = (long)sbuf[2];\
+ lbuf[3] = (long)sbuf[3];\
+ lbuf[4] = (long)sbuf[4];\
+ lbuf[5] = (long)sbuf[5];\
+ lbuf[6] = (long)sbuf[6];\
+ lbuf[7] = (long)sbuf[7];
+
/* Modes for find_gui_window: */
#define BY_WINDOM_HANDLE 0x0
#define BY_GEM_HANDLE 0x1
typedef int (*scan_process_callback)(int pid, void *data);
-
-struct gui_window * find_guiwin_by_aes_handle(short handle);
-bool is_process_running(const char * name);
+
+struct gui_window * find_guiwin_by_aes_handle(short handle);
+bool is_process_running(const char * name);
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
- void * pw );
-void dbg_grect( char * str, GRECT * r );
-void dbg_lgrect( char * str, LGRECT * r );
-void dbg_pxy( char * str, short * pxy );
-void * ldg_open( char * name, short * global );
-void * ldg_find( char * name, short * ldg );
+ void * pw );
+void dbg_grect(const char * str, GRECT * r);
+void dbg_lgrect( char * str, LGRECT * r);
+void dbg_pxy(const char * str, short * pxy);
+void dbg_rect(const char * str, int * pxy);
+void * ldg_open( char * name, short * global );
+void * ldg_find( char * name, short * ldg );
const char * file_select( const char * title, const char * name );
int ldg_close( void * ldg, short * global );
long nkc_to_input_key(short nkc, long * ucs4_out);
-#endif
+#endif
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 121a228..9806852 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -61,6 +61,7 @@
#include "atari/gemtk/gemtk.h"
extern struct gui_window *input_window;
+extern EVMULT_OUT aes_event_out;
struct rootwin_data_s {
struct s_gui_win_root *rootwin;
@@ -69,21 +70,14 @@ struct rootwin_data_s {
/* -------------------------------------------------------------------------- */
/* Static module methods */
/* -------------------------------------------------------------------------- */
-static void redraw(ROOTWIN *rootwin, short msg[8]);
-static void resized(ROOTWIN *rootwin);
-static void file_dropped(ROOTWIN *rootwin, short msg[8]);
-static short key_input(ROOTWIN * rootwin, unsigned short kcode,
- unsigned short kstate, unsigned short nkc);
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-
-#define FIND_NS_GUI_WINDOW(w) \
- find_guiwin_by_aes_handle(guiwin_get_handle(w));
+static void on_redraw(ROOTWIN *rootwin, short msg[8]);
+static void on_resized(ROOTWIN *rootwin);
+static void on_file_dropped(ROOTWIN *rootwin, short msg[8]);
+static short on_window_key_input(ROOTWIN * rootwin, unsigned short nkc);
+static bool on_content_mouse_click(ROOTWIN *rootwin);
static bool redraw_active = false;
-
static const struct redraw_context rootwin_rdrw_ctx = {
.interactive = true,
.background_images = true,
@@ -100,24 +94,23 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
short retval = 0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
- if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
printf("root win msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
- redraw(data->rootwin, msg);
+ on_redraw(data->rootwin, msg);
break;
case WM_REPOSED:
case WM_SIZED:
case WM_MOVED:
case WM_FULLED:
- resized(data->rootwin);
+ on_resized(data->rootwin);
break;
case WM_ICONIFY:
-
if( input_window->root == data->rootwin) {
input_window = NULL;
}
@@ -139,12 +132,10 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case AP_DRAGDROP:
- file_dropped(data->rootwin, msg);
+ on_file_dropped(data->rootwin, msg);
break;
case WM_TOOLBAR:
- printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, msg[4]);
toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
break;
@@ -152,24 +143,26 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
}
}
- if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ if ((ev_out->emo_events & MU_KEYBD) != 0) {
// handle key
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
(short)ev_out->emo_kreturn);
- retval = key_input(data->rootwin, ev_out->emo_kreturn,
- ev_out->emo_kmeta, nkc);
+ retval = on_window_key_input(data->rootwin, nkc);
}
- if( (ev_out->emo_events & MU_TIMER) != 0 ) {
- // handle_timer();
- }
- if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ if ((ev_out->emo_events & MU_BUTTON) != 0) {
LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y));
- printf("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
- //handle_mbutton(gw, ev_out);
+ GRECT carea;
+ guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT, &carea);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, carea)) {
+ on_content_mouse_click(data->rootwin);
+ }
+ }
+ if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
}
return(retval);
@@ -267,7 +260,7 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
// find the next active tab:
while( w != NULL ) {
if(w->root == rootwin && w != gw) {
- input_window = w;
+ gui_set_input_gui_window(w);
break;
}
w = w->next;
@@ -369,6 +362,37 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
+void window_scroll_by(ROOTWIN *root, int sx, int sy)
+{
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if (sx != 0) {
+ units = sx / slid->x_unit_px;
+ if (units == 0) {
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
+ }
+
+ guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
+ if (sy != 0) {
+ units = sy / slid->y_unit_px;
+ if( sx < 0 ) {
+ // units = -units;
+ }
+ if(units == 0){
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ }
+}
+
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
{
GRECT area;
@@ -378,6 +402,7 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
slid->x_units = (width/slid->x_unit_px);
slid->y_units = (height/slid->y_unit_px);
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
+ // TODO: reset slider to 0
}
/* set focus to an arbitary element */
@@ -466,6 +491,16 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
return(rootwin->active_gui_window);
}
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
+{
+ struct guiwin_scroll_info_s *slid;
+
+ slid = guiwin_get_scroll_info(rootwin->win);
+
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
+}
+
/**
* Redraw the favicon
@@ -595,6 +630,14 @@ void window_process_redraws(ROOTWIN * rootwin)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
+ short pxy_clip[4];
+
+ pxy_clip[0] = tb_area.g_x;
+ pxy_clip[0] = tb_area.g_y;
+ pxy_clip[0] = pxy_clip[0] + tb_area.g_w + content_area.g_w - 1;
+ pxy_clip[0] = pxy_clip[1] + tb_area.g_h + content_area.g_h - 1;
+ vs_clip(guiwin_get_vdi_handle(rootwin->win), 1, pxy_clip);
+
while(plot_lock() == false);
wind_get_grect(aes_handle, WF_FIRSTXYWH, &visible_ro);
@@ -631,6 +674,7 @@ void window_process_redraws(ROOTWIN * rootwin)
}
wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro);
}
+ vs_clip(guiwin_get_vdi_handle(rootwin->win), 0, pxy_clip);
rootwin->redraw_slots.areas_used = 0;
redraw_active = false;
@@ -642,114 +686,184 @@ void window_process_redraws(ROOTWIN * rootwin)
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
+static bool on_content_mouse_click(ROOTWIN *rootwin)
{
- bool abs = false;
+ short dummy, mbut, mx, my;
GRECT cwork;
- struct gui_window * gw = data;
- int value = BROWSER_SCROLL_SVAL;
-
- assert( gw != NULL );
+ browser_mouse_state bmstate = 0;
+ struct gui_window *gw;
+ struct guiwin_scroll_info_s *slid;
- browser_get_rect(gw, BR_CONTENT, &cwork );
+ gw = window_get_active_gui_window(rootwin);
+ if( input_window != gw ) {
+ input_window = gw;
+ }
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
+ window_set_focus(gw->root, BROWSER, (void*)gw->browser );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &cwork);
+ /* convert screen coords to component coords: */
+ mx = aes_event_out.emo_mouse.p_x - cwork.g_x;
+ my = aes_event_out.emo_mouse.p_y - cwork.g_y;
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
+ /* Translate GEM key state to netsurf mouse modifier */
+ if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
+ bmstate |= BROWSER_MOUSE_MOD_1;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_1);
+ }
+ if ( (aes_event_out.emo_kmeta & K_CTRL) ) {
+ bmstate |= BROWSER_MOUSE_MOD_2;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_2);
+ }
+ if ( (aes_event_out.emo_kmeta & K_ALT) ) {
+ bmstate |= BROWSER_MOUSE_MOD_3;
+ } else {
+ bmstate &= ~(BROWSER_MOUSE_MOD_3);
+ }
+
+ /* convert component coords to scrolled content coords: */
+ slid = guiwin_get_scroll_info(rootwin->win);
+ int sx_origin = (mx + slid->x_pos * slid->x_unit_px);
+ int sy_origin = (my + slid->y_pos * slid->y_unit_px);
+
+ short rel_cur_x, rel_cur_y;
+ short prev_x=sx_origin, prev_y=sy_origin;
+ bool dragmode = false;
+
+ /* Detect left mouse button state and compare with event state: */
+ graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
+ if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
+ /* Mouse still pressed, report drag */
+ rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ browser_window_mouse_click( gw->browser->bw,
+ BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
+ sx_origin, sy_origin);
+ do {
+ // only consider movements of 5px or more as drag...:
+ if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
+ browser_window_mouse_track( gw->browser->bw,
+ BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
+ rel_cur_x, rel_cur_y);
+ prev_x = rel_cur_x;
+ prev_y = rel_cur_y;
+ dragmode = true;
+ } else {
+ if( dragmode == false ) {
+ browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
+ rel_cur_x, rel_cur_y);
+ }
+ }
- default:
- break;
+ // we may need to process scrolling:
+ // TODO: this doesn't work, because gemtk schedules redraw via
+ // AES window messages but we do not process them right here...
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+
+ graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
+ rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ } while( mbut & 1 );
+ browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
+ } else {
+ /* Right button pressed? */
+ if ((aes_event_out.emo_mbutton & 2 ) ) {
+ context_popup( gw, aes_event_out.emo_mouse.p_x,
+ aes_event_out.emo_mouse.p_x);
+ } else {
+ browser_window_mouse_click(gw->browser->bw,
+ bmstate|BROWSER_MOUSE_PRESS_1,
+ sx_origin,sy_origin);
+ browser_window_mouse_click(gw->browser->bw,
+ bmstate|BROWSER_MOUSE_CLICK_1,
+ sx_origin,sy_origin);
+ }
}
- browser_scroll( gw, buff[4], value, abs );
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
}
+/*
+ Report keypress to browser component.
+ parameter:
+ - unsigned short nkc ( CFLIB normalised key code )
+*/
+static bool on_content_keypress(struct browser_window *bw, unsigned short nkc)
+{
+ bool r = false;
+ unsigned char ascii = (nkc & 0xFF);
+ long ucs4;
+ long ik = nkc_to_input_key( nkc, &ucs4 );
+
+ // pass event to specific control?
-/*
- Report keypress to browser component.
- The browser component doesn't listen for keyinput by itself.
- parameter:
- - gui_window ( compocnent owner ).
- - unsigned short nkc ( CFLIB normalised key code )
-*/
-static bool content_input(struct browser_window *bw, unsigned short nkc)
-{
- bool r = false;
- unsigned char ascii = (nkc & 0xFF);
- long ucs4;
- long ik = nkc_to_input_key( nkc, &ucs4 );
-
- // pass event to specific control?
-
- if (ik == 0){
- if (ascii >= 9) {
- r = browser_window_key_press(bw, ucs4);
- }
- } else {
- r = browser_window_key_press(bw, ik);
- if (r == false){
-
- GRECT g;
- GUIWIN * w = bw->window->root->win;
- guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
-
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
-
- switch( ik ){
- case KEY_LINE_START:
- guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
- false);
- break;
-
- case KEY_LINE_END:
- guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
- false);
- break;
-
- case KEY_PAGE_UP:
- guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
- false);
- break;
-
- case KEY_PAGE_DOWN:
- guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
- false);
- break;
-
- case KEY_RIGHT:
- guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
- break;
-
- case KEY_LEFT:
- guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
- break;
-
- case KEY_UP:
- guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
- break;
-
- case KEY_DOWN:
- guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
- break;
-
- default:
- break;
- }
- }
- }
-
- return( r );
+ if (ik == 0) {
+ if (ascii >= 9) {
+ r = browser_window_key_press(bw, ucs4);
+ }
+ } else {
+ r = browser_window_key_press(bw, ik);
+ if (r == false) {
+
+ GRECT g;
+ GUIWIN * w = bw->window->root->win;
+ guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
+
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
+
+ switch( ik ) {
+ case KEY_LINE_START:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_LINE_END:
+ guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_RIGHT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
+ break;
+
+ case KEY_LEFT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
+ break;
+
+ case KEY_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
+ break;
+
+ case KEY_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
+ break;
+
+ default:
+ break;
+ }
+ guiwin_update_slider(w, GUIWIN_VSLIDER|GUIWIN_HSLIDER);
+ }
+ }
+
+ return(r);
}
-static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
+static short on_window_key_input(ROOTWIN *rootwin, unsigned short nkc)
{
bool done = false;
struct gui_window * gw = window_get_active_gui_window(rootwin);
@@ -758,9 +872,6 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
if( gw == NULL )
return(false);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
-
if(window_url_widget_has_focus((void*)gw->root)) {
/* make sure we report for the root window and report...: */
done = toolbar_key_input(gw->root->toolbar, nkc);
@@ -771,7 +882,7 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
/* todo: only handle when input_window == ontop */
if( window_widget_has_focus(input_window->root, BROWSER,
(void*)gw_tmp->browser)) {
- done = content_input(gw_tmp->browser->bw, nkc);
+ done = on_content_keypress(gw_tmp->browser->bw, nkc);
break;
} else {
gw_tmp = gw_tmp->next;
@@ -782,39 +893,7 @@ static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short ks
}
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
-{
- LOG(("%s\n", __FUNCTION__ ));
-}
-
-
-static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
-{
- int dx = buff[4];
- int dy = buff[5];
- struct gui_window * gw = data;
-
- if (!dx && !dy) return;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
-
- /* update the sliders _before_ we call redraw
- (which might depend on the slider possitions) */
- WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
-
- if( dy > 0 )
- browser_scroll( gw, WA_DNPAGE, abs(dy), false );
- else if ( dy < 0)
- browser_scroll( gw, WA_UPPAGE, abs(dy), false );
- if( dx > 0 )
- browser_scroll( gw, WA_RTPAGE, abs(dx), false );
- else if( dx < 0 )
- browser_scroll( gw, WA_LFPAGE, abs(dx), false );
-}
-
-static void redraw(ROOTWIN *rootwin, short msg[8])
+static void on_redraw(ROOTWIN *rootwin, short msg[8])
{
short handle;
@@ -828,7 +907,7 @@ static void redraw(ROOTWIN *rootwin, short msg[8])
}
}
-static void resized(ROOTWIN *rootwin)
+static void on_resized(ROOTWIN *rootwin)
{
GRECT g;
short handle;
@@ -864,7 +943,7 @@ static void resized(ROOTWIN *rootwin)
toolbar_set_dimensions(rootwin->toolbar, &g);
}
-static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
+static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
{
char file[DD_NAMEMAX];
char name[DD_NAMEMAX];
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 85aeff9..7eb5539 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -41,37 +41,35 @@
int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
-int window_destroy(struct s_gui_win_root * rootwin);
+int window_destroy(ROOTWIN *rootwin);
/* show the window */
-void window_open(struct s_gui_win_root * rootwin, GRECT pos);
+void window_open(ROOTWIN *rootwin, GRECT pos);
-void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
- short w, short h );
+void window_snd_redraw(ROOTWIN *rootwin, short x, short y, short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
-void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
+void window_attach_browser(ROOTWIN *rootwin, CMP_BROWSER b);
/* set focus element */
-void window_set_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type type, void * element );
-/* adjust scroll settings */
-void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
- int content_w);
+void window_set_focus(ROOTWIN *rootwin, enum focus_element_type type,
+ void * element );
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type t, void * element);
-bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
-void window_set_url(struct s_gui_win_root * rootwin, const char * text);
-void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
-void window_set_title(struct s_gui_win_root * rootwin, char * text);
-void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
-void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
+bool window_widget_has_focus(ROOTWIN *rootwin, enum focus_element_type t,
+ void * element);
+bool window_url_widget_has_focus(ROOTWIN *rootwin);
+void window_set_url(ROOTWIN *rootwin, const char * text);
+void window_set_stauts(ROOTWIN *rootwin, char * text);
+void window_set_title(ROOTWIN *rootwin, char * text);
+void window_set_content_size(ROOTWIN *rootwin, int w, int h);
+void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+void window_scroll_by(ROOTWIN *rootwin, int x, int y);
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
bool window_key_input(unsigned short kcode, unsigned short kstate,
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. 22fbe5abfc2797ebba6f330a48b3b6d2ec2058a3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/22fbe5abfc2797ebba6f3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/22fbe5abfc2797ebba6f330...
...tree http://git.netsurf-browser.org/netsurf.git/tree/22fbe5abfc2797ebba6f330a4...
The branch, master has been updated
via 22fbe5abfc2797ebba6f330a48b3b6d2ec2058a3 (commit)
from c88c4fa214b3dd23b8f68fe35d9c8eb738d80976 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/22fbe5abfc2797ebba6...
commit 22fbe5abfc2797ebba6f330a48b3b6d2ec2058a3
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Set the newly-created hotlist dirs to be "retain in memory" otherwise NetSurf crashes on hotlist cleanup.
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index b67e10f..c82b92f 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -45,12 +45,12 @@ void ami_hotlist_add_default_dirs(struct tree *tree)
{
if(ami_hotlist_find_dir(tree, messages_get("HotlistMenu")) == false) {
tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistMenu"), true, false, false);
+ messages_get("HotlistMenu"), true, true, false);
}
if(ami_hotlist_find_dir(tree, messages_get("HotlistToolbar")) == false) {
tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistToolbar"), true, false, false);
+ messages_get("HotlistToolbar"), true, true, false);
}
}
-----------------------------------------------------------------------
Summary of changes:
amiga/hotlist.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index b67e10f..c82b92f 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -45,12 +45,12 @@ void ami_hotlist_add_default_dirs(struct tree *tree)
{
if(ami_hotlist_find_dir(tree, messages_get("HotlistMenu")) == false) {
tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistMenu"), true, false, false);
+ messages_get("HotlistMenu"), true, true, false);
}
if(ami_hotlist_find_dir(tree, messages_get("HotlistToolbar")) == false) {
tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistToolbar"), true, false, false);
+ messages_get("HotlistToolbar"), true, true, false);
}
}
--
NetSurf Browser
10 years, 2 months
netsurf: branch master updated. c88c4fa214b3dd23b8f68fe35d9c8eb738d80976
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c88c4fa214b3dd23b8f68...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c88c4fa214b3dd23b8f68fe...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c88c4fa214b3dd23b8f68fe35...
The branch, master has been updated
via c88c4fa214b3dd23b8f68fe35d9c8eb738d80976 (commit)
via ee79de52446499e56ff6986af1c08d866fd670d5 (commit)
from 1e2cc766cdb16f1a5ef3201df5601ffbc22a8bc8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/c88c4fa214b3dd23b8f...
commit c88c4fa214b3dd23b8f68fe35d9c8eb738d80976
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Don't need to attempt to free on remove, as the only entry point has already done this.
diff --git a/amiga/gui.c b/amiga/gui.c
index 6efa99a..9fa83e1 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2563,8 +2563,6 @@ void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
gwin->redraw_required = true;
gwin->bw->reformat_pending = true;
-
- ami_gui_hotlist_toolbar_free(gwin, &gwin->hotlist_toolbar_list);
}
void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ee79de52446499e56ff...
commit ee79de52446499e56ff6986af1c08d866fd670d5
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Attempt to do some re-layout if the toolbar is added after the window opens.
diff --git a/amiga/gui.c b/amiga/gui.c
index 92ad354..6efa99a 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2517,6 +2517,11 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
+
+ if(gwin->win) {
+ gwin->redraw_required = true;
+ gwin->bw->reformat_pending = true;
+ }
}
}
@@ -4295,7 +4300,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
break;
case GID_HOTLIST:
- if(node = GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
+ if(node = (struct Node *)GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
browser_window_go(gwin->bw, url, NULL, true);
}
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 92ad354..9fa83e1 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2517,6 +2517,11 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
+
+ if(gwin->win) {
+ gwin->redraw_required = true;
+ gwin->bw->reformat_pending = true;
+ }
}
}
@@ -2558,8 +2563,6 @@ void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
gwin->redraw_required = true;
gwin->bw->reformat_pending = true;
-
- ami_gui_hotlist_toolbar_free(gwin, &gwin->hotlist_toolbar_list);
}
void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
@@ -4295,7 +4298,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
break;
case GID_HOTLIST:
- if(node = GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
+ if(node = (struct Node *)GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
browser_window_go(gwin->bw, url, NULL, true);
}
--
NetSurf Browser
10 years, 2 months
netsurf: branch mono/removing-windom-dependency updated. 40313798ee3024a530f2d677155290775526899e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/40313798ee3024a530f2d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/40313798ee3024a530f2d67...
...tree http://git.netsurf-browser.org/netsurf.git/tree/40313798ee3024a530f2d6771...
The branch, mono/removing-windom-dependency has been updated
via 40313798ee3024a530f2d677155290775526899e (commit)
via 2705884b65a726e3fb8d0cb5ceedbd0877cbe8c5 (commit)
via 4360905000fe21a2339967ff012f2d76399c6f90 (commit)
via ea025e60083af859001ea709065efab6600c5bab (commit)
via 67d4da38ad994e3468119e3d6cc6f6041786144b (commit)
via c374f7fcf02068622e20682599903a7f7743ca0d (commit)
from b1018779f984ed1ac57663b97fa439602074d1d9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/40313798ee3024a530f...
commit 40313798ee3024a530f2d677155290775526899e
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Implemented Browser key input handling.
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index ddcad78..ad9253c 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -111,6 +111,7 @@ void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
bool guiwin_update_slider(GUIWIN *win, short mode);
+void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 4558363..54d043e 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -57,90 +57,6 @@ static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
wind_update(END_UPDATE);
}
-static void preproc_scroll(GUIWIN *gw, short orientation, int units,
- bool refresh)
-{
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw);
- int oldpos = 0, newpos = 0, vis_units=0, pix = 0;
- int abs_pix = 0;
- GRECT *redraw=NULL, g, g_ro;
-
- guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
- g_ro = g;
-
- if (orientation == GUIWIN_VSLIDER) {
- pix = units*slid->y_unit_px;
- abs_pix = abs(pix);
- oldpos = slid->y_pos;
- vis_units = g.g_h/slid->y_unit_px;
- newpos = slid->y_pos = MIN(slid->y_units-vis_units,
- MAX(0, slid->y_pos+units));
- if(oldpos == newpos)
- return;
- if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
- // send complete redraw
- redraw = &g_ro;
- } else {
- // only adjust ypos when scrolling down:
- if(pix < 0 ) {
- // blit screen area:
- g.g_h -= abs_pix;
- move_rect(gw, &g, 0, abs_pix);
- g.g_y = g_ro.g_y;
- g.g_h = abs_pix;
- redraw = &g;
- } else {
- // blit screen area:
- g.g_y += abs_pix;
- g.g_h -= abs_pix;
- move_rect(gw, &g, 0, -abs_pix);
- g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
- g.g_h = abs_pix;
- redraw = &g;
- }
- }
- } else {
- pix = units*slid->x_unit_px;
- abs_pix = abs(pix);
- oldpos = slid->x_pos;
- vis_units = g.g_w/slid->x_unit_px;
- newpos = slid->x_pos = MIN(slid->x_units-vis_units,
- MAX(0, slid->x_pos+units));
- if(oldpos == newpos)
- return;
- if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
- // send complete redraw
- redraw = &g_ro;
- } else {
- // only adjust ypos when scrolling down:
- if(pix < 0 ) {
- // blit screen area:
- g.g_w -= abs_pix;
- move_rect(gw, &g, abs_pix, 0);
- g.g_x = g_ro.g_x;
- g.g_w = abs_pix;
- redraw = &g;
- } else {
- // blit screen area:
- g.g_x += abs_pix;
- g.g_w -= abs_pix;
- move_rect(gw, &g, -abs_pix, 0);
- g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
- g.g_w = abs_pix;
- redraw = &g;
- }
- }
- }
-
- if (refresh) {
- guiwin_update_slider(gw, orientation);
- }
-
- if ((redraw != NULL) && (redraw->g_h > 0)) {
- guiwin_send_redraw(gw, redraw);
- }
-}
-
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, g2;
@@ -162,7 +78,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
else {
val = val-slid->x_pos;
}
- preproc_scroll(gw, GUIWIN_HSLIDER, val, false);
+ guiwin_scroll(gw, GUIWIN_HSLIDER, val, false);
}
break;
@@ -178,7 +94,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
else {
val = val -slid->y_pos;
}
- preproc_scroll(gw, GUIWIN_VSLIDER, val, false);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, val, false);
}
break;
@@ -193,47 +109,47 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WA_UPPAGE:
/* scroll page up */
- preproc_scroll(gw, GUIWIN_VSLIDER, -(g.g_h/slid->y_unit_px),
+ guiwin_scroll(gw, GUIWIN_VSLIDER, -(g.g_h/slid->y_unit_px),
true);
break;
case WA_UPLINE:
/* scroll line up */
- preproc_scroll(gw, GUIWIN_VSLIDER, -1, true);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, -1, true);
break;
case WA_DNPAGE:
/* scroll page down */
- preproc_scroll(gw, GUIWIN_VSLIDER, g.g_h/slid->y_unit_px,
+ guiwin_scroll(gw, GUIWIN_VSLIDER, g.g_h/slid->y_unit_px,
true);
break;
case WA_DNLINE:
/* scroll line down */
- preproc_scroll(gw, GUIWIN_VSLIDER, +1, true);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, +1, true);
break;
case WA_LFPAGE:
/* scroll page left */
- preproc_scroll(gw, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ guiwin_scroll(gw, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
true);
break;
case WA_LFLINE:
/* scroll line left */
- preproc_scroll(gw, GUIWIN_HSLIDER, -1,
+ guiwin_scroll(gw, GUIWIN_HSLIDER, -1,
true);
break;
case WA_RTPAGE:
/* scroll page right */
- preproc_scroll(gw, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ guiwin_scroll(gw, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
true);
break;
case WA_RTLINE:
/* scroll line right */
- preproc_scroll(gw, GUIWIN_HSLIDER, 1,
+ guiwin_scroll(gw, GUIWIN_HSLIDER, 1,
true);
break;
@@ -538,6 +454,89 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
}
}
+void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
+{
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw);
+ int oldpos = 0, newpos = 0, vis_units=0, pix = 0;
+ int abs_pix = 0;
+ GRECT *redraw=NULL, g, g_ro;
+
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
+ g_ro = g;
+
+ if (orientation == GUIWIN_VSLIDER) {
+ pix = units*slid->y_unit_px;
+ abs_pix = abs(pix);
+ oldpos = slid->y_pos;
+ vis_units = g.g_h/slid->y_unit_px;
+ newpos = slid->y_pos = MIN(slid->y_units-vis_units,
+ MAX(0, slid->y_pos+units));
+ if(oldpos == newpos)
+ return;
+ if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
+ // send complete redraw
+ redraw = &g_ro;
+ } else {
+ // only adjust ypos when scrolling down:
+ if(pix < 0 ) {
+ // blit screen area:
+ g.g_h -= abs_pix;
+ move_rect(gw, &g, 0, abs_pix);
+ g.g_y = g_ro.g_y;
+ g.g_h = abs_pix;
+ redraw = &g;
+ } else {
+ // blit screen area:
+ g.g_y += abs_pix;
+ g.g_h -= abs_pix;
+ move_rect(gw, &g, 0, -abs_pix);
+ g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
+ g.g_h = abs_pix;
+ redraw = &g;
+ }
+ }
+ } else {
+ pix = units*slid->x_unit_px;
+ abs_pix = abs(pix);
+ oldpos = slid->x_pos;
+ vis_units = g.g_w/slid->x_unit_px;
+ newpos = slid->x_pos = MIN(slid->x_units-vis_units,
+ MAX(0, slid->x_pos+units));
+ if(oldpos == newpos)
+ return;
+ if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
+ // send complete redraw
+ redraw = &g_ro;
+ } else {
+ // only adjust ypos when scrolling down:
+ if(pix < 0 ) {
+ // blit screen area:
+ g.g_w -= abs_pix;
+ move_rect(gw, &g, abs_pix, 0);
+ g.g_x = g_ro.g_x;
+ g.g_w = abs_pix;
+ redraw = &g;
+ } else {
+ // blit screen area:
+ g.g_x += abs_pix;
+ g.g_w -= abs_pix;
+ move_rect(gw, &g, -abs_pix, 0);
+ g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
+ g.g_w = abs_pix;
+ redraw = &g;
+ }
+ }
+ }
+
+ if (refresh) {
+ guiwin_update_slider(gw, orientation);
+ }
+
+ if ((redraw != NULL) && (redraw->g_h > 0)) {
+ guiwin_send_redraw(gw, redraw);
+ }
+}
+
bool guiwin_update_slider(GUIWIN *win, short mode)
{
GRECT viewport;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index dc37543..121a228 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -67,7 +67,7 @@ struct rootwin_data_s {
};
/* -------------------------------------------------------------------------- */
-/* Static module methods: */
+/* Static module methods */
/* -------------------------------------------------------------------------- */
static void redraw(ROOTWIN *rootwin, short msg[8]);
static void resized(ROOTWIN *rootwin);
@@ -83,11 +83,12 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data
static bool redraw_active = false;
-static const struct redraw_context rootwin_rdrw_ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
+
+static const struct redraw_context rootwin_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+};
/* -------------------------------------------------------------------------- */
/* Module public functions: */
@@ -105,47 +106,47 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
switch (msg[0]) {
case WM_REDRAW:
- redraw(data->rootwin, msg);
+ redraw(data->rootwin, msg);
+ break;
+
+ case WM_REPOSED:
+ case WM_SIZED:
+ case WM_MOVED:
+ case WM_FULLED:
+ resized(data->rootwin);
+ break;
+
+ case WM_ICONIFY:
+
+ if( input_window->root == data->rootwin) {
+ input_window = NULL;
+ }
+ break;
+
+ case WM_TOPPED:
+ case WM_NEWTOP:
+ case WM_UNICONIFY:
+ input_window = data->rootwin->active_gui_window;
+ break;
+
+ case WM_CLOSED:
+ // TODO: this needs to iterate through all gui windows and
+ // check if the rootwin is this window...
+ if (data->rootwin->active_gui_window != NULL) {
+ browser_window_destroy(
+ data->rootwin->active_gui_window->browser->bw);
+ }
+ break;
+
+ case AP_DRAGDROP:
+ file_dropped(data->rootwin, msg);
break;
- case WM_REPOSED:
- case WM_SIZED:
- case WM_MOVED:
- case WM_FULLED:
- resized(data->rootwin);
- break;
-
- case WM_ICONIFY:
-
- if( input_window->root == data->rootwin) {
- input_window = NULL;
- }
- break;
-
- case WM_TOPPED:
- case WM_NEWTOP:
- case WM_UNICONIFY:
- input_window = data->rootwin->active_gui_window;
- break;
-
- case WM_CLOSED:
- // TODO: this needs to iterate through all gui windows and
- // check if the rootwin is this window...
- if (data->rootwin->active_gui_window != NULL) {
- browser_window_destroy(
- data->rootwin->active_gui_window->browser->bw);
- }
- break;
-
- case AP_DRAGDROP:
- file_dropped(data->rootwin, msg);
- break;
-
- case WM_TOOLBAR:
- printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, msg[4]);
+ case WM_TOOLBAR:
+ printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, msg[4]);
toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
- break;
+ break;
default:
break;
@@ -155,9 +156,9 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
// handle key
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
- (short)ev_out->emo_kreturn);
+ (short)ev_out->emo_kreturn);
retval = key_input(data->rootwin, ev_out->emo_kreturn,
- ev_out->emo_kmeta, nkc);
+ ev_out->emo_kmeta, nkc);
}
if( (ev_out->emo_events & MU_TIMER) != 0 ) {
@@ -176,8 +177,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
int window_create(struct gui_window * gw,
- struct browser_window * bw,
- unsigned long inflags)
+ struct browser_window * bw,
+ unsigned long inflags)
{
int err = 0;
bool tb, sb;
@@ -198,10 +199,10 @@ int window_create(struct gui_window * gw,
flags |= ( INFO );
}
- gw->root = malloc( sizeof(struct s_gui_win_root) );
- if( gw->root == NULL )
- return( -1 );
- memset( gw->root, 0, sizeof(struct s_gui_win_root) );
+ gw->root = malloc(sizeof(struct s_gui_win_root));
+ if (gw->root == NULL)
+ return(-1);
+ memset(gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
redraw_slots_init(&gw->root->redraw_slots, 8);
@@ -214,14 +215,14 @@ int window_create(struct gui_window * gw,
return( -1 );
}
gw->root->win = guiwin_add(aes_handle,
- GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
- struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
+ struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
data->rootwin = gw->root;
- guiwin_set_user_data(gw->root->win, (void*)data);
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw->root->win);
- slid->y_unit_px = 16;
- slid->x_unit_px = 16;
+ guiwin_set_user_data(gw->root->win, (void*)data);
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw->root->win);
+ slid->y_unit_px = 16;
+ slid->x_unit_px = 16;
/* create toolbar component: */
guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
@@ -271,7 +272,7 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
}
w = w->next;
}
- if(input_window == NULL){
+ if(input_window == NULL) {
// the last gui window for this rootwin was removed:
redraw_slots_free(&rootwin->redraw_slots);
window_destroy(rootwin);
@@ -300,7 +301,7 @@ int window_destroy(ROOTWIN *rootwin)
w = w->next;
}
- if (rootwin->toolbar)
+ if (rootwin->toolbar)
toolbar_destroy(rootwin->toolbar);
if(rootwin->statusbar)
@@ -374,9 +375,9 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
- slid->x_units = (width/slid->x_unit_px);
- slid->y_units = (height/slid->y_unit_px);
- guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
+ slid->x_units = (width/slid->x_unit_px);
+ slid->y_units = (height/slid->y_unit_px);
+ guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
}
/* set focus to an arbitary element */
@@ -447,7 +448,7 @@ void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
{
if (rootwin->active_gui_window != NULL) {
- if(rootwin->active_gui_window == gw){
+ if(rootwin->active_gui_window == gw) {
return;
}
}
@@ -461,8 +462,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
// window_restore_browser(gw->browser);
}
-struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
-{
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
return(rootwin->active_gui_window);
}
@@ -482,7 +482,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
if (clip == NULL) {
clip = &work;
} else {
- if(!rc_intersect(&work, clip)){
+ if(!rc_intersect(&work, clip)) {
return;
}
}
@@ -538,7 +538,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
struct rect redraw_area;
GRECT content_area_rel;
- if(bw->window->browser->reformat_pending){
+ if(bw->window->browser->reformat_pending) {
browser_window_reformat(bw, true, content_area->g_w,
content_area->g_h);
bw->window->browser->reformat_pending = false;
@@ -558,27 +558,27 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
content_area_rel.g_w = clip->g_w;
content_area_rel.g_h = clip->g_h;
- if (content_area_rel.g_x < 0) {
- content_area_rel.g_w += content_area_rel.g_x;
- content_area_rel.g_x = 0;
- }
-
- if (content_area_rel.g_y < 0) {
- content_area_rel.g_h += content_area_rel.g_y;
- content_area_rel.g_y = 0;
+ if (content_area_rel.g_x < 0) {
+ content_area_rel.g_w += content_area_rel.g_x;
+ content_area_rel.g_x = 0;
+ }
+
+ if (content_area_rel.g_y < 0) {
+ content_area_rel.g_h += content_area_rel.g_y;
+ content_area_rel.g_y = 0;
}
dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
- redraw_area.x0 = content_area_rel.g_x;
- redraw_area.y0 = content_area_rel.g_y;
- redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w;
+ redraw_area.x0 = content_area_rel.g_x;
+ redraw_area.y0 = content_area_rel.g_y;
+ redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w;
redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h;
plot_clip(&redraw_area);
- browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
- -(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
+ browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
+ -(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
}
void window_process_redraws(ROOTWIN * rootwin)
@@ -603,15 +603,15 @@ void window_process_redraws(ROOTWIN * rootwin)
// TODO: optimze the rectangle list -
// remove rectangles which were completly inside the visible area.
// that way we don't have to loop over again...
- for(i=0; i<rootwin->redraw_slots.areas_used; i++){
+ for(i=0; i<rootwin->redraw_slots.areas_used; i++) {
GRECT rdrw_area_ro = {
- rootwin->redraw_slots.areas[i].x0,
- rootwin->redraw_slots.areas[i].y0,
- rootwin->redraw_slots.areas[i].x1 -
- rootwin->redraw_slots.areas[i].x0,
- rootwin->redraw_slots.areas[i].y1 -
- rootwin->redraw_slots.areas[i].y0
+ rootwin->redraw_slots.areas[i].x0,
+ rootwin->redraw_slots.areas[i].y0,
+ rootwin->redraw_slots.areas[i].x1 -
+ rootwin->redraw_slots.areas[i].x0,
+ rootwin->redraw_slots.areas[i].y1 -
+ rootwin->redraw_slots.areas[i].y0
};
rc_intersect(&visible_ro, &rdrw_area_ro);
GRECT rdrw_area = rdrw_area_ro;
@@ -625,7 +625,7 @@ void window_process_redraws(ROOTWIN * rootwin)
if(slid == NULL)
slid = guiwin_get_scroll_info(rootwin->win);
window_redraw_content(rootwin, &content_area, &rdrw_area, slid,
- rootwin->active_gui_window->browser->bw);
+ rootwin->active_gui_window->browser->bw);
}
}
@@ -671,38 +671,114 @@ static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
browser_scroll( gw, buff[4], value, abs );
}
-
-static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
+
+/*
+ Report keypress to browser component.
+ The browser component doesn't listen for keyinput by itself.
+ parameter:
+ - gui_window ( compocnent owner ).
+ - unsigned short nkc ( CFLIB normalised key code )
+*/
+static bool content_input(struct browser_window *bw, unsigned short nkc)
{
- bool done = false;
- struct gui_window * gw = window_get_active_gui_window(rootwin);
- struct gui_window * gw_tmp;
+ bool r = false;
+ unsigned char ascii = (nkc & 0xFF);
+ long ucs4;
+ long ik = nkc_to_input_key( nkc, &ucs4 );
- if( gw == NULL )
- return(false);
+ // pass event to specific control?
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
+ if (ik == 0){
+ if (ascii >= 9) {
+ r = browser_window_key_press(bw, ucs4);
+ }
+ } else {
+ r = browser_window_key_press(bw, ik);
+ if (r == false){
+
+ GRECT g;
+ GUIWIN * w = bw->window->root->win;
+ guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
+
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
+
+ switch( ik ){
+ case KEY_LINE_START:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ false);
+ break;
- if(window_url_widget_has_focus((void*)gw->root)) {
- /* make sure we report for the root window and report...: */
- done = toolbar_key_input(gw->root->toolbar, nkc);
- } else {
- gw_tmp = window_list;
- /* search for active browser component: */
- while( gw_tmp != NULL && done == false ) {
- /* todo: only handle when input_window == ontop */
- if( window_widget_has_focus(input_window->root, BROWSER,
- (void*)gw_tmp->browser)) {
- done = browser_input(gw_tmp, nkc);
+ case KEY_LINE_END:
+ guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_RIGHT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
+ break;
+
+ case KEY_LEFT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
+ break;
+
+ case KEY_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
+ break;
+
+ case KEY_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
+ break;
+
+ default:
break;
- } else {
- gw_tmp = gw_tmp->next;
}
}
- }
- return((done==true) ? 1 : 0);
+ }
+
+ return( r );
+}
+
+static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ bool done = false;
+ struct gui_window * gw = window_get_active_gui_window(rootwin);
+ struct gui_window * gw_tmp;
+
+ if( gw == NULL )
+ return(false);
+
+ if( kstate & (K_LSHIFT|K_RSHIFT))
+ kstate |= K_LSHIFT|K_RSHIFT;
+
+ if(window_url_widget_has_focus((void*)gw->root)) {
+ /* make sure we report for the root window and report...: */
+ done = toolbar_key_input(gw->root->toolbar, nkc);
+ } else {
+ gw_tmp = window_list;
+ /* search for active browser component: */
+ while( gw_tmp != NULL && done == false ) {
+ /* todo: only handle when input_window == ontop */
+ if( window_widget_has_focus(input_window->root, BROWSER,
+ (void*)gw_tmp->browser)) {
+ done = content_input(gw_tmp->browser->bw, nkc);
+ break;
+ } else {
+ gw_tmp = gw_tmp->next;
+ }
+ }
+ }
+ return((done==true) ? 1 : 0);
}
@@ -740,7 +816,7 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
static void redraw(ROOTWIN *rootwin, short msg[8])
{
- short handle;
+ short handle;
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
@@ -748,7 +824,7 @@ static void redraw(ROOTWIN *rootwin, short msg[8])
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(rootwin, &clip);
} else {
- window_schedule_redraw_grect(rootwin, &clip);
+ window_schedule_redraw_grect(rootwin, &clip);
}
}
@@ -798,7 +874,7 @@ static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
long size;
char ext[32];
short mx,my,bmstat,mkstat;
- struct gui_window *gw;
+ struct gui_window *gw;
graf_mkstate(&mx, &my, &bmstat, &mkstat);
@@ -807,8 +883,8 @@ static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
if( gw == NULL )
return;
- if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED)
- return;
+ if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED)
+ return;
dd_hdl = ddopen( msg[7], DD_OK);
if( dd_hdl<0)
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/2705884b65a726e3fb8...
commit 2705884b65a726e3fb8d0cb5ceedbd0877cbe8c5
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed image toolbar settings.
diff --git a/atari/settings.c b/atari/settings.c
index ff39903..0aa78cc 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -392,7 +392,7 @@ static char * toolbar_iconset_popup( int x, int y )
/* Get current set (for pre-selection): */
memset( avail, 0, MAX_SETS );
- current = nsoption_charp(atari_image_toolbar_folder);
+ current = "";
/* locate the toolbar folder: */
atari_find_resource( toolbar_folder, fullpath, fullpath );
@@ -846,14 +846,6 @@ static void display_settings( void )
snprintf( spare, 255, "%3d", nsoption_int(font_size) );
set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 );
- set_text(CHOICES_BT_TOOLBAR_ICONSET,
- nsoption_charp(atari_image_toolbar_folder), LABEL_ICONSET_MAX_LEN);
-
- tmp_option_atari_toolbar_bg = nsoption_int(atari_toolbar_bg);
- snprintf( spare, 255, "%06x", tmp_option_atari_toolbar_bg);
- set_text(CHOICES_INPUT_TOOLBAR_BGCOLOR, spare,
- INPUT_TOOLBAR_COLOR_MAX_LEN );
-
/* Only first tab is refreshed: */
ObjcDraw( OC_FORM, dlgwin, CHOICES_TAB_BROWSER, 4 );
@@ -892,10 +884,6 @@ static void apply_settings( void )
/* "Style" tab: */
nsoption_set_int(font_min_size, tmp_option_font_min_size);
nsoption_set_int(font_size, tmp_option_font_size);
- nsoption_set_colour(atari_toolbar_bg, tmp_option_atari_toolbar_bg);
- nsoption_set_charp(atari_image_toolbar_folder,
- ObjcString( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, NULL)
- );
/* "Rendering" tab: */
nsoption_set_charp(atari_font_driver,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/4360905000fe21a2339...
commit 4360905000fe21a2339967ff012f2d76399c6f90
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed image toolbar stuff
This is not related to windom, but makes the code less complex, too.
diff --git a/atari/options.h b/atari/options.h
index f48a0e8..f9bb3b4 100755
--- a/atari/options.h
+++ b/atari/options.h
@@ -29,9 +29,6 @@
int atari_font_monochrom; \
int atari_dither; \
int atari_transparency; \
- int atari_image_toolbar; \
- colour atari_toolbar_bg; \
- char *atari_image_toolbar_folder; \
char *atari_face_sans_serif; /* default sans face */ \
char *atari_face_sans_serif_bold; /* bold sans face */ \
char *atari_face_sans_serif_italic; /* bold sans face */ \
@@ -53,9 +50,6 @@
.atari_font_monochrom = 0, \
.atari_dither = 1, \
.atari_transparency = 1, \
- .atari_image_toolbar_folder = (char*)"default", \
- .atari_image_toolbar = 1, \
- .atari_toolbar_bg = 0xbbbbbb, \
.atari_face_sans_serif = NULL, \
.atari_face_sans_serif_bold = NULL, \
.atari_face_sans_serif_italic = NULL, \
@@ -75,12 +69,9 @@
#define NSOPTION_EXTRA_TABLE \
{ "atari_font_driver", OPTION_STRING, &nsoptions.atari_font_driver },\
{ "atari_font_monochrom", OPTION_INTEGER, &nsoptions.atari_font_monochrom },\
- { "atari_image_toolbar", OPTION_INTEGER, &nsoptions.atari_image_toolbar },\
- { "atari_toolbar_bg", OPTION_COLOUR, &nsoptions.atari_toolbar_bg },\
{ "atari_transparency", OPTION_INTEGER, &nsoptions.atari_transparency },\
{ "atari_dither", OPTION_INTEGER, &nsoptions.atari_dither },\
{ "atari_editor", OPTION_STRING, &nsoptions.atari_editor },\
- { "atari_image_toolbar_folder", OPTION_STRING, &nsoptions.atari_image_toolbar_folder },\
{ "font_face_sans_serif", OPTION_STRING, &nsoptions.atari_face_sans_serif },\
{ "font_face_sans_serif_bold", OPTION_STRING, &nsoptions.atari_face_sans_serif_bold },\
{ "font_face_sans_serif_italic", OPTION_STRING, &nsoptions.atari_face_sans_serif_italic },\
diff --git a/atari/toolbar.c b/atari/toolbar.c
index a6cb548..4b04911 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -96,7 +96,6 @@ extern EVMULT_OUT aes_event_out;
static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
-static bool img_toolbar = false;
static char * toolbar_image_folder = (char *)"default";
static uint32_t toolbar_bg_color = 0xFFFFFF;
static hlcache_handle * toolbar_image;
@@ -224,28 +223,6 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
return;
}
-/**
- * Callback for load_icon(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror toolbar_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
-{
- if( event->type == CONTENT_MSG_READY ){
- if( handle == toolbar_image ){
- toolbar_image_ready = true;
- if(input_window != NULL )
- toolbar_update_buttons(input_window->root->toolbar,
- input_window->browser->bw, 0);
- }
- else if(handle == throbber_image ){
- throbber_image_ready = true;
- }
- }
-
- return NSERROR_OK;
-}
-
static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
struct s_tb_button * instance)
{
@@ -265,35 +242,8 @@ void toolbar_init( void )
short vdicolor[3];
uint32_t rgbcolor;
- toolbar_image_folder = nsoption_charp(atari_image_toolbar_folder);
- toolbar_bg_color = (nsoption_colour(atari_toolbar_bg));
- img_toolbar = (nsoption_int(atari_image_toolbar) > 0 ) ? true : false;
- if( img_toolbar ){
-
- char imgfile[PATH_MAX];
- const char * imgfiletmpl = "toolbar/%s/%s";
-
- while( tb_buttons[i].rsc_id != 0){
- tb_buttons[i].index = i;
- i++;
- }
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "main.png" );
- toolbar_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "throbber.png" );
- throbber_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
-
- } else {
- aes_toolbar = get_tree(TOOLBAR);
- throbber_form = get_tree(THROBBER);
- }
- n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
- for (i=0; i<n; i++) {
- toolbar_styles[i].icon_bgcolor = ABGR_TO_RGB(toolbar_bg_color);
- }
+ aes_toolbar = get_tree(TOOLBAR);
+ throbber_form = get_tree(THROBBER);
}
@@ -347,14 +297,8 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
t->throbber.area.g_h = toolbar_styles[t->style].height;
t->throbber.area.g_w = toolbar_styles[t->style].icon_width + \
(2*toolbar_styles[t->style].button_vmargin );
- if( img_toolbar == true ){
- t->throbber.index = 0;
- t->throbber.max_index = 8;
- } else {
- t->throbber.running = false;
- t->throbber.index = THROBBER_INACTIVE_INDEX;
- t->throbber.max_index = THROBBER_MAX_INDEX;
- }
+ t->throbber.index = THROBBER_INACTIVE_INDEX;
+ t->throbber.max_index = THROBBER_MAX_INDEX;
t->throbber.running = false;
LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ea025e60083af859001...
commit ea025e60083af859001ea709065efab6600c5bab
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Toolbar is now finished, started work on browser redraw/scrolling.
diff --git a/atari/browser.c b/atari/browser.c
index d0337f5..fb0e673 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -581,12 +581,12 @@ bool browser_redraw_required( struct gui_window * gw)
/* coords are relative to the framebuffer */
void browser_schedule_redraw_rect(struct gui_window * gw, short x, short y, short w, short h)
{
- if( x < 0 ){
+ if(x < 0){
w += x;
x = 0;
}
- if( y < 0 ) {
+ if(y < 0) {
h += y;
y = 0;
}
@@ -612,7 +612,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
if( y0 > work.g_h )
return;
- redraw_slot_schedule( &b->redraw, x0, y0, x1, y1 );
+ redraw_slot_schedule(&b->redraw, x0, y0, x1, y1, false);
return;
}
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index dfee0dd..930b056 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -150,8 +150,8 @@ void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
}
}
}
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+ //if(!done)
+ // deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
diff --git a/atari/gui.c b/atari/gui.c
index 753dd08..b11777b 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -173,9 +173,7 @@ void gui_poll(bool active)
}
if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
- printf("key: %d, %d\n", aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta);
- nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
(short)aes_event_out.emo_kreturn);
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
aes_event_out.emo_kmeta, nkc);
@@ -215,7 +213,6 @@ gui_create_browser_window(struct browser_window *bw,
window_set_active_gui_window(gw->root, gw);
window_open(gw->root, pos );
/* Recalculate windows browser area now */
- toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -427,10 +424,14 @@ void gui_window_update_extent(struct gui_window *gw)
oldx = gw->browser->scroll.current.x;
oldy = gw->browser->scroll.current.y;
if( gw->browser->bw->current_content != NULL ) {
- browser_set_content_size( gw,
- content_get_width(gw->browser->bw->current_content),
- content_get_height(gw->browser->bw->current_content)
- );
+ // TODO: store content size!
+ if(window_get_active_gui_window(gw->root) == gw){
+ window_set_content_size( gw->root,
+ content_get_width(gw->browser->bw->current_content),
+ content_get_height(gw->browser->bw->current_content)
+ );
+ window_update_back_forward(gw->root);
+ }
}
}
@@ -586,9 +587,6 @@ void gui_window_stop_throbber(struct gui_window *w)
toolbar_set_throbber_state(w->root->toolbar, false);
- /* refresh toolbar buttons: */
- toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
-
rendering = false;
}
diff --git a/atari/redrawslots.c b/atari/redrawslots.c
index d2f74e4..fdc3555 100644
--- a/atari/redrawslots.c
+++ b/atari/redrawslots.c
@@ -52,45 +52,48 @@ static inline bool rect_intersect( struct rect * box1, struct rect * box2 )
}
-void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area)
+void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
+ bool force)
{
redraw_slot_schedule(slots, area->g_x, area->g_y,
- area->g_x + area->g_w, area->g_y + area->g_h);
+ area->g_x + area->g_w, area->g_y + area->g_h, force);
}
/*
schedule redraw coords.
*/
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
- short x1, short y1)
+ short x1, short y1, bool force)
{
- int i;
+ int i = 0;
struct rect area;
area.x0 = x0;
area.y0 = y0;
area.x1 = x1;
area.y1 = y1;
-
- for( i=0; i<slots->areas_used; i++) {
- if( slots->areas[i].x0 <= x0
- && slots->areas[i].x1 >= x1
- && slots->areas[i].y0 <= y0
- && slots->areas[i].y1 >= y1 ){
- /* the area is already queued for redraw */
- return;
- } else {
- if( rect_intersect(&slots->areas[i], &area ) ){
- slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
- slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
- slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
- slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
- return;
- }
- }
+
+ if (force == false) {
+ for (i=0; i<slots->areas_used; i++) {
+ if (slots->areas[i].x0 <= x0
+ && slots->areas[i].x1 >= x1
+ && slots->areas[i].y0 <= y0
+ && slots->areas[i].y1 >= y1) {
+ /* the area is already queued for redraw */
+ return;
+ } else {
+ if (rect_intersect(&slots->areas[i], &area )) {
+ slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
+ slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
+ slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
+ slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
+ return;
+ }
+ }
+ }
}
- if( slots->areas_used < slots->size ) {
+ if (slots->areas_used < slots->size) {
slots->areas[slots->areas_used].x0 = x0;
slots->areas[slots->areas_used].x1 = x1;
slots->areas[slots->areas_used].y0 = y0;
diff --git a/atari/redrawslots.h b/atari/redrawslots.h
index 8558b7e..2c932bb 100644
--- a/atari/redrawslots.h
+++ b/atari/redrawslots.h
@@ -40,13 +40,14 @@ struct s_redrw_slots
{
struct rect areas[MAX_REDRW_SLOTS];
short size;
- short areas_used;
+ short volatile areas_used;
};
void redraw_slots_init(struct s_redrw_slots * slots, short size);
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
- short x1, short y1);
-void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area);
+ short x1, short y1, bool force);
+void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
+ bool force);
void redraw_slots_remove_area(struct s_redrw_slots * slots, int i);
void redraw_slots_free(struct s_redrw_slots * slots);
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 11a4a42..dc37543 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -69,9 +69,11 @@ struct rootwin_data_s {
/* -------------------------------------------------------------------------- */
/* Static module methods: */
/* -------------------------------------------------------------------------- */
-static void redraw(GUIWIN *win, short msg[8]);
-static void resized(GUIWIN *win);
-static void file_dropped(GUIWIN *win, short msg[8]);
+static void redraw(ROOTWIN *rootwin, short msg[8]);
+static void resized(ROOTWIN *rootwin);
+static void file_dropped(ROOTWIN *rootwin, short msg[8]);
+static short key_input(ROOTWIN * rootwin, unsigned short kcode,
+ unsigned short kstate, unsigned short nkc);
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
@@ -79,14 +81,22 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data
#define FIND_NS_GUI_WINDOW(w) \
find_guiwin_by_aes_handle(guiwin_get_handle(w));
+static bool redraw_active = false;
+
+static const struct redraw_context rootwin_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
+
/* -------------------------------------------------------------------------- */
/* Module public functions: */
/* -------------------------------------------------------------------------- */
+
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
- struct gui_window * gw;
-
+ short retval = 0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
@@ -95,18 +105,18 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
switch (msg[0]) {
case WM_REDRAW:
- redraw(win, msg);
+ redraw(data->rootwin, msg);
break;
case WM_REPOSED:
case WM_SIZED:
case WM_MOVED:
case WM_FULLED:
- resized(win);
+ resized(data->rootwin);
break;
case WM_ICONIFY:
- data = guiwin_get_user_data(win);
+
if( input_window->root == data->rootwin) {
input_window = NULL;
}
@@ -115,27 +125,26 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
- data = guiwin_get_user_data(win);
input_window = data->rootwin->active_gui_window;
break;
case WM_CLOSED:
// TODO: this needs to iterate through all gui windows and
// check if the rootwin is this window...
- data = guiwin_get_user_data(win);
- gw = data->rootwin->active_gui_window;
- if( gw != NULL ) {
- browser_window_destroy(gw->browser->bw);
+ if (data->rootwin->active_gui_window != NULL) {
+ browser_window_destroy(
+ data->rootwin->active_gui_window->browser->bw);
}
break;
case AP_DRAGDROP:
- file_dropped(win, msg);
+ file_dropped(data->rootwin, msg);
break;
case WM_TOOLBAR:
printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y, msg[4]);
+ toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
break;
default:
@@ -143,8 +152,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
- printf("root win keybd\n");
+
// handle key
+ uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
+ (short)ev_out->emo_kreturn);
+ retval = key_input(data->rootwin, ev_out->emo_kreturn,
+ ev_out->emo_kmeta, nkc);
+
}
if( (ev_out->emo_events & MU_TIMER) != 0 ) {
// handle_timer();
@@ -157,7 +171,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
//handle_mbutton(gw, ev_out);
}
- return(0);
+ return(retval);
}
@@ -205,6 +219,9 @@ int window_create(struct gui_window * gw,
struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
data->rootwin = gw->root;
guiwin_set_user_data(gw->root->win, (void*)data);
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw->root->win);
+ slid->y_unit_px = 16;
+ slid->x_unit_px = 16;
/* create toolbar component: */
guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
@@ -303,6 +320,8 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
{
GRECT br, g;
+ assert(rootwin->active_gui_window != NULL);
+
short aes_handle = guiwin_get_handle(rootwin->win);
wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
wind_set_str(aes_handle, WF_NAME, (char *)"");
@@ -312,7 +331,9 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
sb_attach(rootwin->statusbar, rootwin->active_gui_window);
}
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
+ toolbar_set_attached(rootwin->toolbar, true);
toolbar_set_dimensions(rootwin->toolbar, &g);
+ window_update_back_forward(rootwin);
/*TBD: get already present content and set size? */
input_window = rootwin->active_gui_window;
window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
@@ -347,6 +368,17 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
+void window_set_content_size(ROOTWIN *rootwin, int width, int height)
+{
+ GRECT area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(rootwin->win);
+
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
+ slid->x_units = (width/slid->x_unit_px);
+ slid->y_units = (height/slid->y_unit_px);
+ guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
+}
+
/* set focus to an arbitary element */
void window_set_focus(struct s_gui_win_root *rootwin,
enum focus_element_type type, void * element)
@@ -381,6 +413,7 @@ void window_set_focus(struct s_gui_win_root *rootwin,
bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
{
assert(rootwin != NULL);
+
if (rootwin->focus.type == URL_WIDGET) {
return true;
}
@@ -419,6 +452,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
}
}
rootwin->active_gui_window = gw;
+
window_set_icon(rootwin, gw->icon);
window_set_stauts(rootwin, gw->status);
window_set_title(rootwin, gw->title);
@@ -474,34 +508,92 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
}
}
+/***
+* Schedule an redraw area, redraw requests during redraw are
+* not optimized (merged) into other areas, so that the redraw
+* functions can spot the change.
+*
+*/
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
{
GRECT work;
+
+ //dbg_grect("window_schedule_redraw_grect input ", area);
+
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
rc_intersect(area, &work);
- redraw_slot_schedule_grect(&rootwin->redraw_slots, &work);
+
+ dbg_grect("window_schedule_redraw_grect intersection ", &work);
+
+ redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
}
-/*
-bool window_requires_redraw(ROOTWIN * rootwin)
+static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
+ GRECT *clip,
+ struct guiwin_scroll_info_s * slid,
+ struct browser_window *bw)
{
- if (rootwin->redraw_slots.areas_used > 0)
- return(true);
- return(false);
+ struct rect redraw_area;
+ GRECT content_area_rel;
+
+ if(bw->window->browser->reformat_pending){
+ browser_window_reformat(bw, true, content_area->g_w,
+ content_area->g_h);
+ bw->window->browser->reformat_pending = false;
+ //return;
+ }
+
+ //dbg_grect("browser redraw, content area", content_area);
+ //dbg_grect("browser redraw, content clip", clip);
+
+ plot_set_dimensions(content_area->g_x, content_area->g_y,
+ content_area->g_w, content_area->g_h);
+
+
+ /* first, we make the coords relative to the content area: */
+ content_area_rel.g_x = clip->g_x - content_area->g_x;
+ content_area_rel.g_y = clip->g_y - content_area->g_y;
+ content_area_rel.g_w = clip->g_w;
+ content_area_rel.g_h = clip->g_h;
+
+ if (content_area_rel.g_x < 0) {
+ content_area_rel.g_w += content_area_rel.g_x;
+ content_area_rel.g_x = 0;
+ }
+
+ if (content_area_rel.g_y < 0) {
+ content_area_rel.g_h += content_area_rel.g_y;
+ content_area_rel.g_y = 0;
+ }
+
+ dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
+
+ redraw_area.x0 = content_area_rel.g_x;
+ redraw_area.y0 = content_area_rel.g_y;
+ redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w;
+ redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h;
+
+ plot_clip(&redraw_area);
+
+ browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
+ -(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
}
-*/
void window_process_redraws(ROOTWIN * rootwin)
{
- GRECT work, visible_ro, tb_area = {0,0,0,0};
+ GRECT work, visible_ro, tb_area, content_area;
short aes_handle, i;
bool toolbar_rdrw_required;
+ struct guiwin_scroll_info_s *slid =NULL;
+
+ redraw_active = true;
aes_handle = guiwin_get_handle(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
while(plot_lock() == false);
@@ -513,24 +605,34 @@ void window_process_redraws(ROOTWIN * rootwin)
// that way we don't have to loop over again...
for(i=0; i<rootwin->redraw_slots.areas_used; i++){
- GRECT rdrw_area = {
+ GRECT rdrw_area_ro = {
rootwin->redraw_slots.areas[i].x0,
rootwin->redraw_slots.areas[i].y0,
- rootwin->redraw_slots.areas[i].x1 +
- rootwin->redraw_slots.areas[i].x0,
- rootwin->redraw_slots.areas[i].y1 +
- rootwin->redraw_slots.areas[i].y0
+ rootwin->redraw_slots.areas[i].x1 -
+ rootwin->redraw_slots.areas[i].x0,
+ rootwin->redraw_slots.areas[i].y1 -
+ rootwin->redraw_slots.areas[i].y0
};
- GRECT visible = visible_ro;
+ rc_intersect(&visible_ro, &rdrw_area_ro);
+ GRECT rdrw_area = rdrw_area_ro;
+
+ if (rc_intersect(&tb_area, &rdrw_area)) {
+ toolbar_redraw(rootwin->toolbar, &rdrw_area);
+ }
- rc_intersect(&rdrw_area, &visible);
- if (rc_intersect(&tb_area, &visible)) {
- toolbar_redraw(rootwin->toolbar, &visible);
+ rdrw_area = rdrw_area_ro;
+ if (rc_intersect(&content_area, &rdrw_area)) {
+ if(slid == NULL)
+ slid = guiwin_get_scroll_info(rootwin->win);
+ window_redraw_content(rootwin, &content_area, &rdrw_area, slid,
+ rootwin->active_gui_window->browser->bw);
}
+
}
wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro);
}
rootwin->redraw_slots.areas_used = 0;
+ redraw_active = false;
plot_unlock();
}
@@ -569,101 +671,46 @@ static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
browser_scroll( gw, buff[4], value, abs );
}
-//
-//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-// char file[DD_NAMEMAX];
-// char name[DD_NAMEMAX];
-// char *buff=NULL;
-// int dd_hdl;
-// int dd_msg; /* pipe-handle */
-// long size;
-// char ext[32];
-// short mx,my,bmstat,mkstat;
-// graf_mkstate(&mx, &my, &bmstat, &mkstat);
-//
-// if( gw == NULL )
-// return;
-// if( (win->status & WS_ICONIFY))
-// return;
-//
-// dd_hdl = ddopen( wbuff[7], DD_OK);
-// if( dd_hdl<0)
-// return; /* pipe not open */
-// memset( ext, 0, 32);
-// strcpy( ext, "ARGS");
-// dd_msg = ddsexts( dd_hdl, ext);
-// if( dd_msg<0)
-// goto error;
-// dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
-// if( size+1 >= PATH_MAX )
-// goto error;
-// if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
-// ddreply(dd_hdl, DD_OK);
-// buff = (char*)malloc(sizeof(char)*(size+1));
-// if (buff != NULL) {
-// if (Fread(dd_hdl, size, buff ) == size)
-// buff[size] = 0;
-// LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
-// (char*)buff, (char*)&ext,
-// size, mx, my
-// ));
-// {
-// LGRECT bwrect;
-// struct browser_window * bw = gw->browser->bw;
-// browser_get_rect( gw, BR_CONTENT, &bwrect );
-// mx = mx - bwrect.g_x;
-// my = my - bwrect.g_y;
-// if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
-// return;
-//
-// utf8_convert_ret ret;
-// char *utf8_fn;
-//
-// ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
-// if (ret != UTF8_CONVERT_OK) {
-// free(buff);
-// /* A bad encoding should never happen */
-// LOG(("utf8_from_local_encoding failed"));
-// assert(ret != UTF8_CONVERT_BADENC);
-// /* no memory */
-// return;
-// }
-// browser_window_drop_file_at_point( gw->browser->bw,
-// mx+gw->browser->scroll.current.x,
-// my+gw->browser->scroll.current.y,
-// utf8_fn );
-// free(utf8_fn);
-// free(buff);
-// }
-// }
-// }
-//error:
-// ddclose( dd_hdl);
-//}
+
+static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ bool done = false;
+ struct gui_window * gw = window_get_active_gui_window(rootwin);
+ struct gui_window * gw_tmp;
+
+ if( gw == NULL )
+ return(false);
+
+ if( kstate & (K_LSHIFT|K_RSHIFT))
+ kstate |= K_LSHIFT|K_RSHIFT;
+
+ if(window_url_widget_has_focus((void*)gw->root)) {
+ /* make sure we report for the root window and report...: */
+ done = toolbar_key_input(gw->root->toolbar, nkc);
+ } else {
+ gw_tmp = window_list;
+ /* search for active browser component: */
+ while( gw_tmp != NULL && done == false ) {
+ /* todo: only handle when input_window == ontop */
+ if( window_widget_has_focus(input_window->root, BROWSER,
+ (void*)gw_tmp->browser)) {
+ done = browser_input(gw_tmp, nkc);
+ break;
+ } else {
+ gw_tmp = gw_tmp->next;
+ }
+ }
+ }
+ return((done==true) ? 1 : 0);
+}
+
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
{
LOG(("%s\n", __FUNCTION__ ));
}
-//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
-//{
-// struct gui_window * gw = (struct gui_window *) data ;
-// if( gw != NULL ) {
-// browser_window_destroy( gw->browser->bw );
-// }
-//}
-
-
-//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
-//{
-// input_window = (struct gui_window *) data;
-// window_set_focus( input_window, BROWSER, input_window->browser );
-// LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
-// assert( input_window != NULL );
-//}
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
{
@@ -691,46 +738,35 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
-static void redraw(GUIWIN *win, short msg[8])
+static void redraw(ROOTWIN *rootwin, short msg[8])
{
short handle;
- struct rootwin_data_s *data = guiwin_get_user_data(win);
- ROOTWIN *rootwin = data->rootwin;
+
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
- if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
+ if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(rootwin, &clip);
} else {
window_schedule_redraw_grect(rootwin, &clip);
-
- // TODO: remove this call when browser redraw is implemented:
- guiwin_clear(win);
}
}
-static void resized(GUIWIN *win)
+static void resized(ROOTWIN *rootwin)
{
GRECT g;
short handle;
struct gui_window *gw;
- struct rootwin_data_s *data = guiwin_get_user_data(win);
- ROOTWIN *rootwin = data->rootwin;
- printf("resized win: %p\n", win);
+ handle = guiwin_get_handle(rootwin->win);
+ gw = window_get_active_gui_window(rootwin);
- handle = guiwin_get_handle(win);
-
- printf("resized handle: %d\n", handle);
- gw = data->rootwin->active_gui_window;
+ //printf("resized...\n");
assert(gw != NULL);
- printf("resized gw: %p\n", gw);
-
if(gw == NULL)
return;
- //assert( gw != NULL );
wind_get_grect(handle, WF_CURRXYWH, &g);
@@ -739,6 +775,7 @@ static void resized(GUIWIN *win)
/* Reformat will happen when redraw is processed: */
// TODO: call reformat directly, this was introduced because
// of bad AES knowledge, it's ok to call it directly here...
+ //printf("reformat......\n");
rootwin->active_gui_window->browser->reformat_pending = true;
}
}
@@ -747,11 +784,11 @@ static void resized(GUIWIN *win)
// }
rootwin->loc = g;
- guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &g);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
toolbar_set_dimensions(rootwin->toolbar, &g);
}
-static void __CDECL file_dropped(GUIWIN *win, short msg[8])
+static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
{
char file[DD_NAMEMAX];
char name[DD_NAMEMAX];
@@ -765,12 +802,12 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
graf_mkstate(&mx, &my, &bmstat, &mkstat);
- gw = FIND_NS_GUI_WINDOW(win);
+ gw = window_get_active_gui_window(rootwin);
if( gw == NULL )
return;
- if(guiwin_get_state(win) & GW_STATUS_ICONIFIED)
+ if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED)
return;
dd_hdl = ddopen( msg[7], DD_OK);
@@ -797,7 +834,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
{
GRECT bwrect;
struct browser_window * bw = gw->browser->bw;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
+ browser_get_rect(gw, BR_CONTENT, &bwrect);
mx = mx - bwrect.g_x;
my = my - bwrect.g_y;
if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
@@ -828,41 +865,3 @@ error:
ddclose( dd_hdl);
}
-///* perform the actual resize */
-//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
-//{
-// short x,y,w,h;
-// struct gui_window * gw;
-//
-// wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
-// gw = (struct gui_window *)data;
-//
-// assert( gw != NULL );
-//
-// if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
-// /* report resize to component interface: */
-// browser_update_rects( gw );
-// tb_adjust_size( gw );
-// if( gw->browser->bw->current_content != NULL ){
-// /* Reformat will happen when next redraw message arrives: */
-// gw->browser->reformat_pending = true;
-// if( sys_XAAES() ){
-// if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
-// ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
-// gw->root->loc.g_x, gw->root->loc.g_y,
-// gw->root->loc.g_w, gw->root->loc.g_h );
-// }
-// }
-// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
-// (GRECT*)&gw->root->loc);
-// }
-// else {
-// WindClear( gw->root->handle );
-// }
-// } else {
-// if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
-// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
-// browser_update_rects( gw );
-// }
-// }
-//}
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 2fa3ec5..85aeff9 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -65,14 +65,17 @@ bool window_widget_has_focus(struct s_gui_win_root * rootwin,
bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
void window_set_url(struct s_gui_win_root * rootwin, const char * text);
void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
-void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
-void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+bool window_key_input(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
/* -------------------------------------------------------------------------- */
diff --git a/atari/toolbar.c b/atari/toolbar.c
index e57171c..a6cb548 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -81,7 +81,7 @@ struct s_tb_button
void (*cb_click)(struct s_toolbar *tb);
hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
struct s_toolbar *owner;
- short state;
+ enum e_toolbar_button_states state;
short index;
GRECT area;
};
@@ -92,6 +92,7 @@ extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
+extern EVMULT_OUT aes_event_out;
static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
@@ -186,6 +187,21 @@ static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
/**
+* Find a button for a specific resource ID
+*/
+static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
+{
+ int i = 0;
+ while (i < tb->btcnt) {
+ if (tb->buttons[i].rsc_id == rsc_id) {
+ return(&tb->buttons[i]);
+ }
+ i++;
+ }
+ return(NULL);
+}
+
+/**
* Callback for textarea redraw
*/
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
@@ -194,14 +210,16 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
GRECT area;
struct s_toolbar * tb = (struct s_toolbar *)data;
+ if (tb->attached == false) {
+ return;
+ }
+
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
area.g_x += x;
area.g_y += y;
area.g_w = w;
area.g_h = h;
-
- dbg_grect("toolbar redraw request", &area);
-
+ dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
return;
}
@@ -354,6 +372,7 @@ void toolbar_destroy(struct s_toolbar *tb)
static void toolbar_reflow(struct s_toolbar *tb)
{
+ int i;
// position toolbar areas:
aes_toolbar->ob_x = tb->area.g_x;
@@ -382,14 +401,27 @@ static void toolbar_reflow(struct s_toolbar *tb)
((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height
- throbber_form[tb->throbber.index].ob_height) >> 1);
-
+ // set button states:
+ for (i=0; i < tb->btcnt; i++ ) {
+ if (tb->buttons[i].state == button_off) {
+ aes_toolbar[tb->buttons[i].rsc_id].ob_state |= OS_DISABLED;
+ }
+ else if (tb->buttons[i].state == button_on) {
+ aes_toolbar[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
+ }
+ }
tb->reflow = false;
+ // TODO: iterate through all other toolbars and set reflow = true
}
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
{
GRECT area;
+ if (tb->attached == false) {
+ return;
+ }
+
if(tb->reflow == true)
toolbar_reflow(tb);
@@ -414,9 +446,6 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
r.x1 = r.x0 + area.g_w;
plot_set_dimensions(url_area.g_x, url_area.g_y, url_area.g_w,
url_area.g_h);
- textarea_set_dimensions(tb->url.textarea,
- aes_toolbar[TOOLBAR_URL_AREA].ob_width,
- 20);
textarea_redraw(tb->url.textarea, 0, 0, &r, &toolbar_rdrw_ctx);
}
}
@@ -426,12 +455,89 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
short button)
{
LOG((""));
+
+ struct s_tb_button * bt;
+ bool enable = false;
+ GRECT area;
+
+ assert(bw != NULL);
+
+ if (button == TOOLBAR_BT_BACK || button <= 0 ) {
+ bt = find_button(tb, TOOLBAR_BT_BACK);
+ enable = browser_window_back_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (button == TOOLBAR_BT_HOME || button <= 0 ){
+
+ }
+
+ if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
+ bt = find_button(tb, TOOLBAR_BT_FORWARD);
+ enable = browser_window_forward_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
+ bt = find_button(tb, TOOLBAR_BT_RELOAD);
+ enable = browser_window_reload_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (button == TOOLBAR_BT_STOP || button <= 0) {
+ bt = find_button(tb, TOOLBAR_BT_STOP);
+ enable = browser_window_stop_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (tb->attached) {
+ if (button > 0) {
+ toolbar_get_grect(tb, button, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ else {
+ toolbar_get_grect(tb, TOOLBAR_NAVIGATION_AREA, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ }
}
void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
{
- tb->area = *area;
+
+
+ if (area->g_w != tb->area.g_w || area->g_h != tb->area.g_h) {
+ tb->area = *area;
+ /* reflow now, just for url input calucation: */
+ toolbar_reflow(tb);
+ /* this will request an textarea redraw: */
+ textarea_set_dimensions(tb->url.textarea,
+ aes_toolbar[TOOLBAR_URL_AREA].ob_width,
+ 20);
+ }
+ else {
+ tb->area = *area;
+ }
+ /* reflow for next redraw: */
+ /* TODO: that's only required because we do not reset others toolbars reflow
+ state on reflow */
tb->reflow = true;
}
@@ -441,10 +547,14 @@ void toolbar_set_url(struct s_toolbar *tb, const char * text)
LOG((""));
textarea_set_text(tb->url.textarea, text);
- GRECT area;
- toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
-
- window_schedule_redraw_grect(tb->owner, &area);
+ if (tb->attached) {
+ GRECT area;
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ toolbar_update_buttons(tb, gw->browser->bw , 0);
+ }
}
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
@@ -463,6 +573,12 @@ void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
window_schedule_redraw_grect(tb->owner, &throbber_area);
}
+void toolbar_set_attached(struct s_toolbar *tb, bool attached)
+{
+ tb->attached = attached;
+
+}
+
void toolbar_throbber_progress(struct s_toolbar *tb)
{
GRECT throbber_area;
@@ -492,17 +608,145 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text)
bool toolbar_key_input(struct s_toolbar *tb, short nkc)
{
- bool handled = true;
- LOG((""));
+ assert(tb!=NULL);
+ GRECT work;
+ bool ret = false;
- return(handled);
+ struct gui_window *gw = window_get_active_gui_window(tb->owner);
+
+ assert( gw != NULL );
+
+ long ucs4;
+ long ik = nkc_to_input_key(nkc, &ucs4);
+
+ if (ik == 0) {
+ if ((nkc&0xFF) >= 9) {
+ ret = textarea_keypress(tb->url.textarea, ucs4);
+ }
+ }
+ else if (ik == KEY_CR || ik == KEY_NL) {
+ char tmp_url[PATH_MAX];
+ if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
+ window_set_focus(tb->owner, BROWSER, gw->browser);
+ browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
+ ret = true;
+ }
+ }
+ else if (ik == KEY_COPY_SELECTION) {
+ // copy whole text
+ char * text;
+ int len;
+ len = textarea_get_text( tb->url.textarea, NULL, 0 );
+ text = malloc( len+1 );
+ if (text){
+ textarea_get_text( tb->url.textarea, text, len+1 );
+ scrap_txt_write( &app, text );
+ free( text );
+ }
+ }
+ else if ( ik == KEY_PASTE) {
+ char * clip = scrap_txt_read( &app );
+ if ( clip != NULL ){
+ int clip_length = strlen( clip );
+ if ( clip_length > 0 ) {
+ char *utf8;
+ utf8_convert_ret res;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ res = utf8_from_local_encoding( clip, clip_length, &utf8 );
+ if ( res == UTF8_CONVERT_OK ) {
+ toolbar_set_url(tb, utf8);
+ free(utf8);
+ ret = true;
+ }
+ free( clip );
+ }
+ }
+ }
+ else if (ik == KEY_ESCAPE) {
+ textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
+ textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
+ }
+ else {
+ ret = textarea_keypress( tb->url.textarea, ik );
+ }
+
+ return( ret );
}
-void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my)
+void toolbar_mouse_input(struct s_toolbar *tb, short obj)
{
LOG((""));
+ GRECT work;
+ short mx, my, mb, kstat;
+ int old;
+
+ if (obj==TOOLBAR_URL_AREA){
+
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
+ mx -= work.g_x;
+ my -= work.g_y;
+
+ /* TODO: reset mouse state of browser window? */
+ /* select whole text when newly focused, otherwise set caret to
+ end of text */
+ if (!window_url_widget_has_focus(tb->owner)) {
+ window_set_focus(tb->owner, URL_WIDGET, (void*)&tb->url );
+ }
+ /* url widget has focus and mouse button is still pressed... */
+ else if (mb & 1) {
+
+ textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
+ mx, my );
+ short prev_x = mx;
+ short prev_y = my;
+ do {
+ if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_HOLDING_1, mx, my );
+ prev_x = mx;
+ prev_y = my;
+ window_schedule_redraw_grect(tb->owner, &work);
+ window_process_redraws(tb->owner);
+ }
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
+ my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
+ } while (mb & 1);
+
+ textarea_drag_end( tb->url.textarea, 0, mx, my );
+ }
+ else {
+ /* when execution reaches here, mouse input is a click or dclick */
+ /* TODO: recognize click + shitoolbar_update_buttonsft key */
+ int mstate = BROWSER_MOUSE_PRESS_1;
+ if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 ){
+ mstate = BROWSER_MOUSE_MOD_1;
+ }
+ if( aes_event_out.emo_mclicks == 2 ){
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
+ my);
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
+ window_schedule_redraw_grect(tb->owner, &work);
+ } else {
+ textarea_mouse_action(tb->url.textarea,
+ BROWSER_MOUSE_PRESS_1, mx, my );
+ }
+ }
+ } else {
+ struct s_tb_button *bt = find_button(tb, obj);
+ if (bt != NULL && bt->state != button_off) {
+ bt->cb_click(tb);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ toolbar_update_buttons(tb, gw->browser->bw,
+ 0);
+ }
+
+ }
}
@@ -540,43 +784,68 @@ struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
/* public event handler */
void toolbar_back_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
-
- struct browser_window *bw = input_window->browser->bw;
-
- if( history_back_available(bw->history) )
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ if( history_back_available(bw->history) )
history_back(bw, bw->history);
}
void toolbar_reload_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- browser_window_reload(input_window->browser->bw, true);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ browser_window_reload(bw, true);
}
void toolbar_forward_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- struct browser_window *bw = input_window->browser->bw;
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
}
void toolbar_home_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
struct browser_window * bw;
struct gui_window * gw;
gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
bw = gw->browser->bw;
+ assert(bw != NULL);
browser_window_go(bw, option_homepage_url, 0, true);
}
void toolbar_stop_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- browser_window_stop(input_window->browser->bw);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ browser_window_stop(bw);
}
diff --git a/atari/toolbar.h b/atari/toolbar.h
index 6a40cf3..d13b59c 100644
--- a/atari/toolbar.h
+++ b/atari/toolbar.h
@@ -39,7 +39,7 @@ struct s_toolbar
GRECT area;
/* size & location of buttons: */
struct s_tb_button * buttons;
- bool hidden;
+ bool attached;
int btcnt;
int style;
bool redraw;
@@ -55,13 +55,14 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
void toolbar_set_url(struct s_toolbar *tb, const char *text);
bool toolbar_text_input(struct s_toolbar *tb, char *text);
bool toolbar_key_input(struct s_toolbar *tb, short nkc);
-void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
+void toolbar_mouse_input(struct s_toolbar *tb, short obj);
void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
short idx);
void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *g);
struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
enum toolbar_textarea which);
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active);
+void toolbar_set_attached(struct s_toolbar *tb, bool attached);
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip);
void toolbar_throbber_progress(struct s_toolbar *tb);
/* public events handlers: */
diff --git a/atari/treeview.c b/atari/treeview.c
index 7144d21..52859e3 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -95,18 +95,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
- printf("Treeview keybd\n");
on_keybd_event(tv, ev_out, msg);
- // handle key
- }
- if( (ev_out->emo_events & MU_TIMER) != 0 ) {
- // handle_timer();
}
if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
LOG(("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y));
- printf("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
on_mbutton_event(tv, ev_out, msg);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/67d4da38ad994e34681...
commit 67d4da38ad994e3468119e3d6cc6f6041786144b
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed debug statements
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 8a29a53..e57171c 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -526,7 +526,7 @@ void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst)
dst->g_h = aes_toolbar[which].ob_height;
//printf("Toolbar get grect (%d): ", which);
- dbg_grect("", dst);
+ //dbg_grect("", dst);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/c374f7fcf02068622e2...
commit c374f7fcf02068622e20682599903a7f7743ca0d
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed debug statements
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 1c3a17c..8a29a53 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -192,7 +192,6 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
{
GRECT area;
- printf("data: %p\n", data);
struct s_toolbar * tb = (struct s_toolbar *)data;
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
@@ -526,7 +525,7 @@ void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst)
dst->g_w = aes_toolbar[which].ob_width;
dst->g_h = aes_toolbar[which].ob_height;
- printf("Toolbar get grect (%d): ", which);
+ //printf("Toolbar get grect (%d): ", which);
dbg_grect("", dst);
}
-----------------------------------------------------------------------
Summary of changes:
atari/browser.c | 6 +-
atari/gemtk/gemtk.h | 1 +
atari/gemtk/guiwin.c | 187 +++++++++---------
atari/global_evnt.c | 4 +-
atari/gui.c | 20 +-
atari/options.h | 9 -
atari/redrawslots.c | 47 +++--
atari/redrawslots.h | 7 +-
atari/rootwin.c | 551 ++++++++++++++++++++++++++++----------------------
atari/rootwin.h | 7 +-
atari/settings.c | 14 +--
atari/toolbar.c | 396 +++++++++++++++++++++++++++---------
atari/toolbar.h | 5 +-
atari/treeview.c | 7 -
14 files changed, 763 insertions(+), 498 deletions(-)
diff --git a/atari/browser.c b/atari/browser.c
index d0337f5..fb0e673 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -581,12 +581,12 @@ bool browser_redraw_required( struct gui_window * gw)
/* coords are relative to the framebuffer */
void browser_schedule_redraw_rect(struct gui_window * gw, short x, short y, short w, short h)
{
- if( x < 0 ){
+ if(x < 0){
w += x;
x = 0;
}
- if( y < 0 ) {
+ if(y < 0) {
h += y;
y = 0;
}
@@ -612,7 +612,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
if( y0 > work.g_h )
return;
- redraw_slot_schedule( &b->redraw, x0, y0, x1, y1 );
+ redraw_slot_schedule(&b->redraw, x0, y0, x1, y1, false);
return;
}
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index ddcad78..ad9253c 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -111,6 +111,7 @@ void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
bool guiwin_update_slider(GUIWIN *win, short mode);
+void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 4558363..54d043e 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -57,90 +57,6 @@ static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
wind_update(END_UPDATE);
}
-static void preproc_scroll(GUIWIN *gw, short orientation, int units,
- bool refresh)
-{
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw);
- int oldpos = 0, newpos = 0, vis_units=0, pix = 0;
- int abs_pix = 0;
- GRECT *redraw=NULL, g, g_ro;
-
- guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
- g_ro = g;
-
- if (orientation == GUIWIN_VSLIDER) {
- pix = units*slid->y_unit_px;
- abs_pix = abs(pix);
- oldpos = slid->y_pos;
- vis_units = g.g_h/slid->y_unit_px;
- newpos = slid->y_pos = MIN(slid->y_units-vis_units,
- MAX(0, slid->y_pos+units));
- if(oldpos == newpos)
- return;
- if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
- // send complete redraw
- redraw = &g_ro;
- } else {
- // only adjust ypos when scrolling down:
- if(pix < 0 ) {
- // blit screen area:
- g.g_h -= abs_pix;
- move_rect(gw, &g, 0, abs_pix);
- g.g_y = g_ro.g_y;
- g.g_h = abs_pix;
- redraw = &g;
- } else {
- // blit screen area:
- g.g_y += abs_pix;
- g.g_h -= abs_pix;
- move_rect(gw, &g, 0, -abs_pix);
- g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
- g.g_h = abs_pix;
- redraw = &g;
- }
- }
- } else {
- pix = units*slid->x_unit_px;
- abs_pix = abs(pix);
- oldpos = slid->x_pos;
- vis_units = g.g_w/slid->x_unit_px;
- newpos = slid->x_pos = MIN(slid->x_units-vis_units,
- MAX(0, slid->x_pos+units));
- if(oldpos == newpos)
- return;
- if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
- // send complete redraw
- redraw = &g_ro;
- } else {
- // only adjust ypos when scrolling down:
- if(pix < 0 ) {
- // blit screen area:
- g.g_w -= abs_pix;
- move_rect(gw, &g, abs_pix, 0);
- g.g_x = g_ro.g_x;
- g.g_w = abs_pix;
- redraw = &g;
- } else {
- // blit screen area:
- g.g_x += abs_pix;
- g.g_w -= abs_pix;
- move_rect(gw, &g, -abs_pix, 0);
- g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
- g.g_w = abs_pix;
- redraw = &g;
- }
- }
- }
-
- if (refresh) {
- guiwin_update_slider(gw, orientation);
- }
-
- if ((redraw != NULL) && (redraw->g_h > 0)) {
- guiwin_send_redraw(gw, redraw);
- }
-}
-
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, g2;
@@ -162,7 +78,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
else {
val = val-slid->x_pos;
}
- preproc_scroll(gw, GUIWIN_HSLIDER, val, false);
+ guiwin_scroll(gw, GUIWIN_HSLIDER, val, false);
}
break;
@@ -178,7 +94,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
else {
val = val -slid->y_pos;
}
- preproc_scroll(gw, GUIWIN_VSLIDER, val, false);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, val, false);
}
break;
@@ -193,47 +109,47 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WA_UPPAGE:
/* scroll page up */
- preproc_scroll(gw, GUIWIN_VSLIDER, -(g.g_h/slid->y_unit_px),
+ guiwin_scroll(gw, GUIWIN_VSLIDER, -(g.g_h/slid->y_unit_px),
true);
break;
case WA_UPLINE:
/* scroll line up */
- preproc_scroll(gw, GUIWIN_VSLIDER, -1, true);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, -1, true);
break;
case WA_DNPAGE:
/* scroll page down */
- preproc_scroll(gw, GUIWIN_VSLIDER, g.g_h/slid->y_unit_px,
+ guiwin_scroll(gw, GUIWIN_VSLIDER, g.g_h/slid->y_unit_px,
true);
break;
case WA_DNLINE:
/* scroll line down */
- preproc_scroll(gw, GUIWIN_VSLIDER, +1, true);
+ guiwin_scroll(gw, GUIWIN_VSLIDER, +1, true);
break;
case WA_LFPAGE:
/* scroll page left */
- preproc_scroll(gw, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ guiwin_scroll(gw, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
true);
break;
case WA_LFLINE:
/* scroll line left */
- preproc_scroll(gw, GUIWIN_HSLIDER, -1,
+ guiwin_scroll(gw, GUIWIN_HSLIDER, -1,
true);
break;
case WA_RTPAGE:
/* scroll page right */
- preproc_scroll(gw, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ guiwin_scroll(gw, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
true);
break;
case WA_RTLINE:
/* scroll line right */
- preproc_scroll(gw, GUIWIN_HSLIDER, 1,
+ guiwin_scroll(gw, GUIWIN_HSLIDER, 1,
true);
break;
@@ -538,6 +454,89 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
}
}
+void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
+{
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw);
+ int oldpos = 0, newpos = 0, vis_units=0, pix = 0;
+ int abs_pix = 0;
+ GRECT *redraw=NULL, g, g_ro;
+
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
+ g_ro = g;
+
+ if (orientation == GUIWIN_VSLIDER) {
+ pix = units*slid->y_unit_px;
+ abs_pix = abs(pix);
+ oldpos = slid->y_pos;
+ vis_units = g.g_h/slid->y_unit_px;
+ newpos = slid->y_pos = MIN(slid->y_units-vis_units,
+ MAX(0, slid->y_pos+units));
+ if(oldpos == newpos)
+ return;
+ if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
+ // send complete redraw
+ redraw = &g_ro;
+ } else {
+ // only adjust ypos when scrolling down:
+ if(pix < 0 ) {
+ // blit screen area:
+ g.g_h -= abs_pix;
+ move_rect(gw, &g, 0, abs_pix);
+ g.g_y = g_ro.g_y;
+ g.g_h = abs_pix;
+ redraw = &g;
+ } else {
+ // blit screen area:
+ g.g_y += abs_pix;
+ g.g_h -= abs_pix;
+ move_rect(gw, &g, 0, -abs_pix);
+ g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
+ g.g_h = abs_pix;
+ redraw = &g;
+ }
+ }
+ } else {
+ pix = units*slid->x_unit_px;
+ abs_pix = abs(pix);
+ oldpos = slid->x_pos;
+ vis_units = g.g_w/slid->x_unit_px;
+ newpos = slid->x_pos = MIN(slid->x_units-vis_units,
+ MAX(0, slid->x_pos+units));
+ if(oldpos == newpos)
+ return;
+ if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
+ // send complete redraw
+ redraw = &g_ro;
+ } else {
+ // only adjust ypos when scrolling down:
+ if(pix < 0 ) {
+ // blit screen area:
+ g.g_w -= abs_pix;
+ move_rect(gw, &g, abs_pix, 0);
+ g.g_x = g_ro.g_x;
+ g.g_w = abs_pix;
+ redraw = &g;
+ } else {
+ // blit screen area:
+ g.g_x += abs_pix;
+ g.g_w -= abs_pix;
+ move_rect(gw, &g, -abs_pix, 0);
+ g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
+ g.g_w = abs_pix;
+ redraw = &g;
+ }
+ }
+ }
+
+ if (refresh) {
+ guiwin_update_slider(gw, orientation);
+ }
+
+ if ((redraw != NULL) && (redraw->g_h > 0)) {
+ guiwin_send_redraw(gw, redraw);
+ }
+}
+
bool guiwin_update_slider(GUIWIN *win, short mode)
{
GRECT viewport;
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index dfee0dd..930b056 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -150,8 +150,8 @@ void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
}
}
}
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+ //if(!done)
+ // deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
diff --git a/atari/gui.c b/atari/gui.c
index 753dd08..b11777b 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -173,9 +173,7 @@ void gui_poll(bool active)
}
if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
- printf("key: %d, %d\n", aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta);
- nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
(short)aes_event_out.emo_kreturn);
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
aes_event_out.emo_kmeta, nkc);
@@ -215,7 +213,6 @@ gui_create_browser_window(struct browser_window *bw,
window_set_active_gui_window(gw->root, gw);
window_open(gw->root, pos );
/* Recalculate windows browser area now */
- toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -427,10 +424,14 @@ void gui_window_update_extent(struct gui_window *gw)
oldx = gw->browser->scroll.current.x;
oldy = gw->browser->scroll.current.y;
if( gw->browser->bw->current_content != NULL ) {
- browser_set_content_size( gw,
- content_get_width(gw->browser->bw->current_content),
- content_get_height(gw->browser->bw->current_content)
- );
+ // TODO: store content size!
+ if(window_get_active_gui_window(gw->root) == gw){
+ window_set_content_size( gw->root,
+ content_get_width(gw->browser->bw->current_content),
+ content_get_height(gw->browser->bw->current_content)
+ );
+ window_update_back_forward(gw->root);
+ }
}
}
@@ -586,9 +587,6 @@ void gui_window_stop_throbber(struct gui_window *w)
toolbar_set_throbber_state(w->root->toolbar, false);
- /* refresh toolbar buttons: */
- toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
-
rendering = false;
}
diff --git a/atari/options.h b/atari/options.h
index f48a0e8..f9bb3b4 100755
--- a/atari/options.h
+++ b/atari/options.h
@@ -29,9 +29,6 @@
int atari_font_monochrom; \
int atari_dither; \
int atari_transparency; \
- int atari_image_toolbar; \
- colour atari_toolbar_bg; \
- char *atari_image_toolbar_folder; \
char *atari_face_sans_serif; /* default sans face */ \
char *atari_face_sans_serif_bold; /* bold sans face */ \
char *atari_face_sans_serif_italic; /* bold sans face */ \
@@ -53,9 +50,6 @@
.atari_font_monochrom = 0, \
.atari_dither = 1, \
.atari_transparency = 1, \
- .atari_image_toolbar_folder = (char*)"default", \
- .atari_image_toolbar = 1, \
- .atari_toolbar_bg = 0xbbbbbb, \
.atari_face_sans_serif = NULL, \
.atari_face_sans_serif_bold = NULL, \
.atari_face_sans_serif_italic = NULL, \
@@ -75,12 +69,9 @@
#define NSOPTION_EXTRA_TABLE \
{ "atari_font_driver", OPTION_STRING, &nsoptions.atari_font_driver },\
{ "atari_font_monochrom", OPTION_INTEGER, &nsoptions.atari_font_monochrom },\
- { "atari_image_toolbar", OPTION_INTEGER, &nsoptions.atari_image_toolbar },\
- { "atari_toolbar_bg", OPTION_COLOUR, &nsoptions.atari_toolbar_bg },\
{ "atari_transparency", OPTION_INTEGER, &nsoptions.atari_transparency },\
{ "atari_dither", OPTION_INTEGER, &nsoptions.atari_dither },\
{ "atari_editor", OPTION_STRING, &nsoptions.atari_editor },\
- { "atari_image_toolbar_folder", OPTION_STRING, &nsoptions.atari_image_toolbar_folder },\
{ "font_face_sans_serif", OPTION_STRING, &nsoptions.atari_face_sans_serif },\
{ "font_face_sans_serif_bold", OPTION_STRING, &nsoptions.atari_face_sans_serif_bold },\
{ "font_face_sans_serif_italic", OPTION_STRING, &nsoptions.atari_face_sans_serif_italic },\
diff --git a/atari/redrawslots.c b/atari/redrawslots.c
index d2f74e4..fdc3555 100644
--- a/atari/redrawslots.c
+++ b/atari/redrawslots.c
@@ -52,45 +52,48 @@ static inline bool rect_intersect( struct rect * box1, struct rect * box2 )
}
-void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area)
+void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
+ bool force)
{
redraw_slot_schedule(slots, area->g_x, area->g_y,
- area->g_x + area->g_w, area->g_y + area->g_h);
+ area->g_x + area->g_w, area->g_y + area->g_h, force);
}
/*
schedule redraw coords.
*/
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
- short x1, short y1)
+ short x1, short y1, bool force)
{
- int i;
+ int i = 0;
struct rect area;
area.x0 = x0;
area.y0 = y0;
area.x1 = x1;
area.y1 = y1;
-
- for( i=0; i<slots->areas_used; i++) {
- if( slots->areas[i].x0 <= x0
- && slots->areas[i].x1 >= x1
- && slots->areas[i].y0 <= y0
- && slots->areas[i].y1 >= y1 ){
- /* the area is already queued for redraw */
- return;
- } else {
- if( rect_intersect(&slots->areas[i], &area ) ){
- slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
- slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
- slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
- slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
- return;
- }
- }
+
+ if (force == false) {
+ for (i=0; i<slots->areas_used; i++) {
+ if (slots->areas[i].x0 <= x0
+ && slots->areas[i].x1 >= x1
+ && slots->areas[i].y0 <= y0
+ && slots->areas[i].y1 >= y1) {
+ /* the area is already queued for redraw */
+ return;
+ } else {
+ if (rect_intersect(&slots->areas[i], &area )) {
+ slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
+ slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
+ slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
+ slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
+ return;
+ }
+ }
+ }
}
- if( slots->areas_used < slots->size ) {
+ if (slots->areas_used < slots->size) {
slots->areas[slots->areas_used].x0 = x0;
slots->areas[slots->areas_used].x1 = x1;
slots->areas[slots->areas_used].y0 = y0;
diff --git a/atari/redrawslots.h b/atari/redrawslots.h
index 8558b7e..2c932bb 100644
--- a/atari/redrawslots.h
+++ b/atari/redrawslots.h
@@ -40,13 +40,14 @@ struct s_redrw_slots
{
struct rect areas[MAX_REDRW_SLOTS];
short size;
- short areas_used;
+ short volatile areas_used;
};
void redraw_slots_init(struct s_redrw_slots * slots, short size);
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
- short x1, short y1);
-void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area);
+ short x1, short y1, bool force);
+void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
+ bool force);
void redraw_slots_remove_area(struct s_redrw_slots * slots, int i);
void redraw_slots_free(struct s_redrw_slots * slots);
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 11a4a42..121a228 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -67,11 +67,13 @@ struct rootwin_data_s {
};
/* -------------------------------------------------------------------------- */
-/* Static module methods: */
+/* Static module methods */
/* -------------------------------------------------------------------------- */
-static void redraw(GUIWIN *win, short msg[8]);
-static void resized(GUIWIN *win);
-static void file_dropped(GUIWIN *win, short msg[8]);
+static void redraw(ROOTWIN *rootwin, short msg[8]);
+static void resized(ROOTWIN *rootwin);
+static void file_dropped(ROOTWIN *rootwin, short msg[8]);
+static short key_input(ROOTWIN * rootwin, unsigned short kcode,
+ unsigned short kstate, unsigned short nkc);
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
@@ -79,14 +81,23 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data
#define FIND_NS_GUI_WINDOW(w) \
find_guiwin_by_aes_handle(guiwin_get_handle(w));
+static bool redraw_active = false;
+
+
+static const struct redraw_context rootwin_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+};
+
/* -------------------------------------------------------------------------- */
/* Module public functions: */
/* -------------------------------------------------------------------------- */
+
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
- struct gui_window * gw;
-
+ short retval = 0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
@@ -95,56 +106,60 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
switch (msg[0]) {
case WM_REDRAW:
- redraw(win, msg);
+ redraw(data->rootwin, msg);
+ break;
+
+ case WM_REPOSED:
+ case WM_SIZED:
+ case WM_MOVED:
+ case WM_FULLED:
+ resized(data->rootwin);
+ break;
+
+ case WM_ICONIFY:
+
+ if( input_window->root == data->rootwin) {
+ input_window = NULL;
+ }
+ break;
+
+ case WM_TOPPED:
+ case WM_NEWTOP:
+ case WM_UNICONIFY:
+ input_window = data->rootwin->active_gui_window;
+ break;
+
+ case WM_CLOSED:
+ // TODO: this needs to iterate through all gui windows and
+ // check if the rootwin is this window...
+ if (data->rootwin->active_gui_window != NULL) {
+ browser_window_destroy(
+ data->rootwin->active_gui_window->browser->bw);
+ }
break;
- case WM_REPOSED:
- case WM_SIZED:
- case WM_MOVED:
- case WM_FULLED:
- resized(win);
- break;
-
- case WM_ICONIFY:
- data = guiwin_get_user_data(win);
- if( input_window->root == data->rootwin) {
- input_window = NULL;
- }
- break;
-
- case WM_TOPPED:
- case WM_NEWTOP:
- case WM_UNICONIFY:
- data = guiwin_get_user_data(win);
- input_window = data->rootwin->active_gui_window;
- break;
-
- case WM_CLOSED:
- // TODO: this needs to iterate through all gui windows and
- // check if the rootwin is this window...
- data = guiwin_get_user_data(win);
- gw = data->rootwin->active_gui_window;
- if( gw != NULL ) {
- browser_window_destroy(gw->browser->bw);
- }
- break;
-
- case AP_DRAGDROP:
- file_dropped(win, msg);
- break;
-
- case WM_TOOLBAR:
- printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, msg[4]);
- break;
+ case AP_DRAGDROP:
+ file_dropped(data->rootwin, msg);
+ break;
+
+ case WM_TOOLBAR:
+ printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, msg[4]);
+ toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
+ break;
default:
break;
}
}
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
- printf("root win keybd\n");
+
// handle key
+ uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
+ (short)ev_out->emo_kreturn);
+ retval = key_input(data->rootwin, ev_out->emo_kreturn,
+ ev_out->emo_kmeta, nkc);
+
}
if( (ev_out->emo_events & MU_TIMER) != 0 ) {
// handle_timer();
@@ -157,13 +172,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
//handle_mbutton(gw, ev_out);
}
- return(0);
+ return(retval);
}
int window_create(struct gui_window * gw,
- struct browser_window * bw,
- unsigned long inflags)
+ struct browser_window * bw,
+ unsigned long inflags)
{
int err = 0;
bool tb, sb;
@@ -184,10 +199,10 @@ int window_create(struct gui_window * gw,
flags |= ( INFO );
}
- gw->root = malloc( sizeof(struct s_gui_win_root) );
- if( gw->root == NULL )
- return( -1 );
- memset( gw->root, 0, sizeof(struct s_gui_win_root) );
+ gw->root = malloc(sizeof(struct s_gui_win_root));
+ if (gw->root == NULL)
+ return(-1);
+ memset(gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
redraw_slots_init(&gw->root->redraw_slots, 8);
@@ -200,11 +215,14 @@ int window_create(struct gui_window * gw,
return( -1 );
}
gw->root->win = guiwin_add(aes_handle,
- GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
- struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
+ struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
data->rootwin = gw->root;
- guiwin_set_user_data(gw->root->win, (void*)data);
+ guiwin_set_user_data(gw->root->win, (void*)data);
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw->root->win);
+ slid->y_unit_px = 16;
+ slid->x_unit_px = 16;
/* create toolbar component: */
guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
@@ -254,7 +272,7 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
}
w = w->next;
}
- if(input_window == NULL){
+ if(input_window == NULL) {
// the last gui window for this rootwin was removed:
redraw_slots_free(&rootwin->redraw_slots);
window_destroy(rootwin);
@@ -283,7 +301,7 @@ int window_destroy(ROOTWIN *rootwin)
w = w->next;
}
- if (rootwin->toolbar)
+ if (rootwin->toolbar)
toolbar_destroy(rootwin->toolbar);
if(rootwin->statusbar)
@@ -303,6 +321,8 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
{
GRECT br, g;
+ assert(rootwin->active_gui_window != NULL);
+
short aes_handle = guiwin_get_handle(rootwin->win);
wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
wind_set_str(aes_handle, WF_NAME, (char *)"");
@@ -312,7 +332,9 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
sb_attach(rootwin->statusbar, rootwin->active_gui_window);
}
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
+ toolbar_set_attached(rootwin->toolbar, true);
toolbar_set_dimensions(rootwin->toolbar, &g);
+ window_update_back_forward(rootwin);
/*TBD: get already present content and set size? */
input_window = rootwin->active_gui_window;
window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
@@ -347,6 +369,17 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
+void window_set_content_size(ROOTWIN *rootwin, int width, int height)
+{
+ GRECT area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(rootwin->win);
+
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
+ slid->x_units = (width/slid->x_unit_px);
+ slid->y_units = (height/slid->y_unit_px);
+ guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
+}
+
/* set focus to an arbitary element */
void window_set_focus(struct s_gui_win_root *rootwin,
enum focus_element_type type, void * element)
@@ -381,6 +414,7 @@ void window_set_focus(struct s_gui_win_root *rootwin,
bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
{
assert(rootwin != NULL);
+
if (rootwin->focus.type == URL_WIDGET) {
return true;
}
@@ -414,11 +448,12 @@ void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
{
if (rootwin->active_gui_window != NULL) {
- if(rootwin->active_gui_window == gw){
+ if(rootwin->active_gui_window == gw) {
return;
}
}
rootwin->active_gui_window = gw;
+
window_set_icon(rootwin, gw->icon);
window_set_stauts(rootwin, gw->status);
window_set_title(rootwin, gw->title);
@@ -427,8 +462,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
// window_restore_browser(gw->browser);
}
-struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
-{
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
return(rootwin->active_gui_window);
}
@@ -448,7 +482,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
if (clip == NULL) {
clip = &work;
} else {
- if(!rc_intersect(&work, clip)){
+ if(!rc_intersect(&work, clip)) {
return;
}
}
@@ -474,34 +508,92 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
}
}
+/***
+* Schedule an redraw area, redraw requests during redraw are
+* not optimized (merged) into other areas, so that the redraw
+* functions can spot the change.
+*
+*/
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
{
GRECT work;
+
+ //dbg_grect("window_schedule_redraw_grect input ", area);
+
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
rc_intersect(area, &work);
- redraw_slot_schedule_grect(&rootwin->redraw_slots, &work);
+
+ dbg_grect("window_schedule_redraw_grect intersection ", &work);
+
+ redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
}
-/*
-bool window_requires_redraw(ROOTWIN * rootwin)
+static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
+ GRECT *clip,
+ struct guiwin_scroll_info_s * slid,
+ struct browser_window *bw)
{
- if (rootwin->redraw_slots.areas_used > 0)
- return(true);
- return(false);
+ struct rect redraw_area;
+ GRECT content_area_rel;
+
+ if(bw->window->browser->reformat_pending) {
+ browser_window_reformat(bw, true, content_area->g_w,
+ content_area->g_h);
+ bw->window->browser->reformat_pending = false;
+ //return;
+ }
+
+ //dbg_grect("browser redraw, content area", content_area);
+ //dbg_grect("browser redraw, content clip", clip);
+
+ plot_set_dimensions(content_area->g_x, content_area->g_y,
+ content_area->g_w, content_area->g_h);
+
+
+ /* first, we make the coords relative to the content area: */
+ content_area_rel.g_x = clip->g_x - content_area->g_x;
+ content_area_rel.g_y = clip->g_y - content_area->g_y;
+ content_area_rel.g_w = clip->g_w;
+ content_area_rel.g_h = clip->g_h;
+
+ if (content_area_rel.g_x < 0) {
+ content_area_rel.g_w += content_area_rel.g_x;
+ content_area_rel.g_x = 0;
+ }
+
+ if (content_area_rel.g_y < 0) {
+ content_area_rel.g_h += content_area_rel.g_y;
+ content_area_rel.g_y = 0;
+ }
+
+ dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
+
+ redraw_area.x0 = content_area_rel.g_x;
+ redraw_area.y0 = content_area_rel.g_y;
+ redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w;
+ redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h;
+
+ plot_clip(&redraw_area);
+
+ browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
+ -(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
}
-*/
void window_process_redraws(ROOTWIN * rootwin)
{
- GRECT work, visible_ro, tb_area = {0,0,0,0};
+ GRECT work, visible_ro, tb_area, content_area;
short aes_handle, i;
bool toolbar_rdrw_required;
+ struct guiwin_scroll_info_s *slid =NULL;
+
+ redraw_active = true;
aes_handle = guiwin_get_handle(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
while(plot_lock() == false);
@@ -511,26 +603,36 @@ void window_process_redraws(ROOTWIN * rootwin)
// TODO: optimze the rectangle list -
// remove rectangles which were completly inside the visible area.
// that way we don't have to loop over again...
- for(i=0; i<rootwin->redraw_slots.areas_used; i++){
-
- GRECT rdrw_area = {
- rootwin->redraw_slots.areas[i].x0,
- rootwin->redraw_slots.areas[i].y0,
- rootwin->redraw_slots.areas[i].x1 +
- rootwin->redraw_slots.areas[i].x0,
- rootwin->redraw_slots.areas[i].y1 +
- rootwin->redraw_slots.areas[i].y0
+ for(i=0; i<rootwin->redraw_slots.areas_used; i++) {
+
+ GRECT rdrw_area_ro = {
+ rootwin->redraw_slots.areas[i].x0,
+ rootwin->redraw_slots.areas[i].y0,
+ rootwin->redraw_slots.areas[i].x1 -
+ rootwin->redraw_slots.areas[i].x0,
+ rootwin->redraw_slots.areas[i].y1 -
+ rootwin->redraw_slots.areas[i].y0
};
- GRECT visible = visible_ro;
+ rc_intersect(&visible_ro, &rdrw_area_ro);
+ GRECT rdrw_area = rdrw_area_ro;
+
+ if (rc_intersect(&tb_area, &rdrw_area)) {
+ toolbar_redraw(rootwin->toolbar, &rdrw_area);
+ }
- rc_intersect(&rdrw_area, &visible);
- if (rc_intersect(&tb_area, &visible)) {
- toolbar_redraw(rootwin->toolbar, &visible);
+ rdrw_area = rdrw_area_ro;
+ if (rc_intersect(&content_area, &rdrw_area)) {
+ if(slid == NULL)
+ slid = guiwin_get_scroll_info(rootwin->win);
+ window_redraw_content(rootwin, &content_area, &rdrw_area, slid,
+ rootwin->active_gui_window->browser->bw);
}
+
}
wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro);
}
rootwin->redraw_slots.areas_used = 0;
+ redraw_active = false;
plot_unlock();
}
@@ -569,101 +671,122 @@ static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
browser_scroll( gw, buff[4], value, abs );
}
-//
-//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
-//{
-// struct gui_window * gw = (struct gui_window *)data;
-// char file[DD_NAMEMAX];
-// char name[DD_NAMEMAX];
-// char *buff=NULL;
-// int dd_hdl;
-// int dd_msg; /* pipe-handle */
-// long size;
-// char ext[32];
-// short mx,my,bmstat,mkstat;
-// graf_mkstate(&mx, &my, &bmstat, &mkstat);
-//
-// if( gw == NULL )
-// return;
-// if( (win->status & WS_ICONIFY))
-// return;
-//
-// dd_hdl = ddopen( wbuff[7], DD_OK);
-// if( dd_hdl<0)
-// return; /* pipe not open */
-// memset( ext, 0, 32);
-// strcpy( ext, "ARGS");
-// dd_msg = ddsexts( dd_hdl, ext);
-// if( dd_msg<0)
-// goto error;
-// dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
-// if( size+1 >= PATH_MAX )
-// goto error;
-// if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
-// ddreply(dd_hdl, DD_OK);
-// buff = (char*)malloc(sizeof(char)*(size+1));
-// if (buff != NULL) {
-// if (Fread(dd_hdl, size, buff ) == size)
-// buff[size] = 0;
-// LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
-// (char*)buff, (char*)&ext,
-// size, mx, my
-// ));
-// {
-// LGRECT bwrect;
-// struct browser_window * bw = gw->browser->bw;
-// browser_get_rect( gw, BR_CONTENT, &bwrect );
-// mx = mx - bwrect.g_x;
-// my = my - bwrect.g_y;
-// if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
-// return;
-//
-// utf8_convert_ret ret;
-// char *utf8_fn;
-//
-// ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
-// if (ret != UTF8_CONVERT_OK) {
-// free(buff);
-// /* A bad encoding should never happen */
-// LOG(("utf8_from_local_encoding failed"));
-// assert(ret != UTF8_CONVERT_BADENC);
-// /* no memory */
-// return;
-// }
-// browser_window_drop_file_at_point( gw->browser->bw,
-// mx+gw->browser->scroll.current.x,
-// my+gw->browser->scroll.current.y,
-// utf8_fn );
-// free(utf8_fn);
-// free(buff);
-// }
-// }
-// }
-//error:
-// ddclose( dd_hdl);
-//}
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
+/*
+ Report keypress to browser component.
+ The browser component doesn't listen for keyinput by itself.
+ parameter:
+ - gui_window ( compocnent owner ).
+ - unsigned short nkc ( CFLIB normalised key code )
+*/
+static bool content_input(struct browser_window *bw, unsigned short nkc)
+{
+ bool r = false;
+ unsigned char ascii = (nkc & 0xFF);
+ long ucs4;
+ long ik = nkc_to_input_key( nkc, &ucs4 );
+
+ // pass event to specific control?
+
+ if (ik == 0){
+ if (ascii >= 9) {
+ r = browser_window_key_press(bw, ucs4);
+ }
+ } else {
+ r = browser_window_key_press(bw, ik);
+ if (r == false){
+
+ GRECT g;
+ GUIWIN * w = bw->window->root->win;
+ guiwin_get_grect(w, GUIWIN_AREA_CONTENT, &g);
+
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w);
+
+ switch( ik ){
+ case KEY_LINE_START:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_LINE_END:
+ guiwin_scroll(w, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_PAGE_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, (g.g_h/slid->y_unit_px),
+ false);
+ break;
+
+ case KEY_RIGHT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, -1, false);
+ break;
+
+ case KEY_LEFT:
+ guiwin_scroll(w, GUIWIN_HSLIDER, 1, false);
+ break;
+
+ case KEY_UP:
+ guiwin_scroll(w, GUIWIN_VSLIDER, -1, false);
+ break;
+
+ case KEY_DOWN:
+ guiwin_scroll(w, GUIWIN_VSLIDER, 1, false);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return( r );
+}
+
+static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
{
- LOG(("%s\n", __FUNCTION__ ));
+ bool done = false;
+ struct gui_window * gw = window_get_active_gui_window(rootwin);
+ struct gui_window * gw_tmp;
+
+ if( gw == NULL )
+ return(false);
+
+ if( kstate & (K_LSHIFT|K_RSHIFT))
+ kstate |= K_LSHIFT|K_RSHIFT;
+
+ if(window_url_widget_has_focus((void*)gw->root)) {
+ /* make sure we report for the root window and report...: */
+ done = toolbar_key_input(gw->root->toolbar, nkc);
+ } else {
+ gw_tmp = window_list;
+ /* search for active browser component: */
+ while( gw_tmp != NULL && done == false ) {
+ /* todo: only handle when input_window == ontop */
+ if( window_widget_has_focus(input_window->root, BROWSER,
+ (void*)gw_tmp->browser)) {
+ done = content_input(gw_tmp->browser->bw, nkc);
+ break;
+ } else {
+ gw_tmp = gw_tmp->next;
+ }
+ }
+ }
+ return((done==true) ? 1 : 0);
}
-//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
-//{
-// struct gui_window * gw = (struct gui_window *) data ;
-// if( gw != NULL ) {
-// browser_window_destroy( gw->browser->bw );
-// }
-//}
+static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+}
-//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
-//{
-// input_window = (struct gui_window *) data;
-// window_set_focus( input_window, BROWSER, input_window->browser );
-// LOG(("newtop gui window: %p, WINDOW: %p", input_window, win ));
-// assert( input_window != NULL );
-//}
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
{
@@ -691,46 +814,35 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
}
-static void redraw(GUIWIN *win, short msg[8])
+static void redraw(ROOTWIN *rootwin, short msg[8])
{
- short handle;
- struct rootwin_data_s *data = guiwin_get_user_data(win);
- ROOTWIN *rootwin = data->rootwin;
+ short handle;
+
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
- if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
+ if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(rootwin, &clip);
} else {
- window_schedule_redraw_grect(rootwin, &clip);
-
- // TODO: remove this call when browser redraw is implemented:
- guiwin_clear(win);
+ window_schedule_redraw_grect(rootwin, &clip);
}
}
-static void resized(GUIWIN *win)
+static void resized(ROOTWIN *rootwin)
{
GRECT g;
short handle;
struct gui_window *gw;
- struct rootwin_data_s *data = guiwin_get_user_data(win);
- ROOTWIN *rootwin = data->rootwin;
- printf("resized win: %p\n", win);
+ handle = guiwin_get_handle(rootwin->win);
+ gw = window_get_active_gui_window(rootwin);
- handle = guiwin_get_handle(win);
-
- printf("resized handle: %d\n", handle);
- gw = data->rootwin->active_gui_window;
+ //printf("resized...\n");
assert(gw != NULL);
- printf("resized gw: %p\n", gw);
-
if(gw == NULL)
return;
- //assert( gw != NULL );
wind_get_grect(handle, WF_CURRXYWH, &g);
@@ -739,6 +851,7 @@ static void resized(GUIWIN *win)
/* Reformat will happen when redraw is processed: */
// TODO: call reformat directly, this was introduced because
// of bad AES knowledge, it's ok to call it directly here...
+ //printf("reformat......\n");
rootwin->active_gui_window->browser->reformat_pending = true;
}
}
@@ -747,11 +860,11 @@ static void resized(GUIWIN *win)
// }
rootwin->loc = g;
- guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &g);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
toolbar_set_dimensions(rootwin->toolbar, &g);
}
-static void __CDECL file_dropped(GUIWIN *win, short msg[8])
+static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
{
char file[DD_NAMEMAX];
char name[DD_NAMEMAX];
@@ -761,17 +874,17 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
long size;
char ext[32];
short mx,my,bmstat,mkstat;
- struct gui_window *gw;
+ struct gui_window *gw;
graf_mkstate(&mx, &my, &bmstat, &mkstat);
- gw = FIND_NS_GUI_WINDOW(win);
+ gw = window_get_active_gui_window(rootwin);
if( gw == NULL )
return;
- if(guiwin_get_state(win) & GW_STATUS_ICONIFIED)
- return;
+ if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED)
+ return;
dd_hdl = ddopen( msg[7], DD_OK);
if( dd_hdl<0)
@@ -797,7 +910,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
{
GRECT bwrect;
struct browser_window * bw = gw->browser->bw;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
+ browser_get_rect(gw, BR_CONTENT, &bwrect);
mx = mx - bwrect.g_x;
my = my - bwrect.g_y;
if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
@@ -828,41 +941,3 @@ error:
ddclose( dd_hdl);
}
-///* perform the actual resize */
-//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data )
-//{
-// short x,y,w,h;
-// struct gui_window * gw;
-//
-// wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
-// gw = (struct gui_window *)data;
-//
-// assert( gw != NULL );
-//
-// if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
-// /* report resize to component interface: */
-// browser_update_rects( gw );
-// tb_adjust_size( gw );
-// if( gw->browser->bw->current_content != NULL ){
-// /* Reformat will happen when next redraw message arrives: */
-// gw->browser->reformat_pending = true;
-// if( sys_XAAES() ){
-// if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){
-// ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
-// gw->root->loc.g_x, gw->root->loc.g_y,
-// gw->root->loc.g_w, gw->root->loc.g_h );
-// }
-// }
-// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH,
-// (GRECT*)&gw->root->loc);
-// }
-// else {
-// WindClear( gw->root->handle );
-// }
-// } else {
-// if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
-// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
-// browser_update_rects( gw );
-// }
-// }
-//}
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 2fa3ec5..85aeff9 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -65,14 +65,17 @@ bool window_widget_has_focus(struct s_gui_win_root * rootwin,
bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
void window_set_url(struct s_gui_win_root * rootwin, const char * text);
void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
-void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
-void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+bool window_key_input(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
/* -------------------------------------------------------------------------- */
diff --git a/atari/settings.c b/atari/settings.c
index ff39903..0aa78cc 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -392,7 +392,7 @@ static char * toolbar_iconset_popup( int x, int y )
/* Get current set (for pre-selection): */
memset( avail, 0, MAX_SETS );
- current = nsoption_charp(atari_image_toolbar_folder);
+ current = "";
/* locate the toolbar folder: */
atari_find_resource( toolbar_folder, fullpath, fullpath );
@@ -846,14 +846,6 @@ static void display_settings( void )
snprintf( spare, 255, "%3d", nsoption_int(font_size) );
set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 );
- set_text(CHOICES_BT_TOOLBAR_ICONSET,
- nsoption_charp(atari_image_toolbar_folder), LABEL_ICONSET_MAX_LEN);
-
- tmp_option_atari_toolbar_bg = nsoption_int(atari_toolbar_bg);
- snprintf( spare, 255, "%06x", tmp_option_atari_toolbar_bg);
- set_text(CHOICES_INPUT_TOOLBAR_BGCOLOR, spare,
- INPUT_TOOLBAR_COLOR_MAX_LEN );
-
/* Only first tab is refreshed: */
ObjcDraw( OC_FORM, dlgwin, CHOICES_TAB_BROWSER, 4 );
@@ -892,10 +884,6 @@ static void apply_settings( void )
/* "Style" tab: */
nsoption_set_int(font_min_size, tmp_option_font_min_size);
nsoption_set_int(font_size, tmp_option_font_size);
- nsoption_set_colour(atari_toolbar_bg, tmp_option_atari_toolbar_bg);
- nsoption_set_charp(atari_image_toolbar_folder,
- ObjcString( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, NULL)
- );
/* "Rendering" tab: */
nsoption_set_charp(atari_font_driver,
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 1c3a17c..4b04911 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -81,7 +81,7 @@ struct s_tb_button
void (*cb_click)(struct s_toolbar *tb);
hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
struct s_toolbar *owner;
- short state;
+ enum e_toolbar_button_states state;
short index;
GRECT area;
};
@@ -92,10 +92,10 @@ extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
+extern EVMULT_OUT aes_event_out;
static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
-static bool img_toolbar = false;
static char * toolbar_image_folder = (char *)"default";
static uint32_t toolbar_bg_color = 0xFFFFFF;
static hlcache_handle * toolbar_image;
@@ -186,49 +186,43 @@ static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
/**
+* Find a button for a specific resource ID
+*/
+static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
+{
+ int i = 0;
+ while (i < tb->btcnt) {
+ if (tb->buttons[i].rsc_id == rsc_id) {
+ return(&tb->buttons[i]);
+ }
+ i++;
+ }
+ return(NULL);
+}
+
+/**
* Callback for textarea redraw
*/
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
{
GRECT area;
- printf("data: %p\n", data);
struct s_toolbar * tb = (struct s_toolbar *)data;
+ if (tb->attached == false) {
+ return;
+ }
+
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
area.g_x += x;
area.g_y += y;
area.g_w = w;
area.g_h = h;
-
- dbg_grect("toolbar redraw request", &area);
-
+ dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
return;
}
-/**
- * Callback for load_icon(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror toolbar_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
-{
- if( event->type == CONTENT_MSG_READY ){
- if( handle == toolbar_image ){
- toolbar_image_ready = true;
- if(input_window != NULL )
- toolbar_update_buttons(input_window->root->toolbar,
- input_window->browser->bw, 0);
- }
- else if(handle == throbber_image ){
- throbber_image_ready = true;
- }
- }
-
- return NSERROR_OK;
-}
-
static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
struct s_tb_button * instance)
{
@@ -248,35 +242,8 @@ void toolbar_init( void )
short vdicolor[3];
uint32_t rgbcolor;
- toolbar_image_folder = nsoption_charp(atari_image_toolbar_folder);
- toolbar_bg_color = (nsoption_colour(atari_toolbar_bg));
- img_toolbar = (nsoption_int(atari_image_toolbar) > 0 ) ? true : false;
- if( img_toolbar ){
-
- char imgfile[PATH_MAX];
- const char * imgfiletmpl = "toolbar/%s/%s";
-
- while( tb_buttons[i].rsc_id != 0){
- tb_buttons[i].index = i;
- i++;
- }
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "main.png" );
- toolbar_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "throbber.png" );
- throbber_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
-
- } else {
- aes_toolbar = get_tree(TOOLBAR);
- throbber_form = get_tree(THROBBER);
- }
- n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
- for (i=0; i<n; i++) {
- toolbar_styles[i].icon_bgcolor = ABGR_TO_RGB(toolbar_bg_color);
- }
+ aes_toolbar = get_tree(TOOLBAR);
+ throbber_form = get_tree(THROBBER);
}
@@ -330,14 +297,8 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
t->throbber.area.g_h = toolbar_styles[t->style].height;
t->throbber.area.g_w = toolbar_styles[t->style].icon_width + \
(2*toolbar_styles[t->style].button_vmargin );
- if( img_toolbar == true ){
- t->throbber.index = 0;
- t->throbber.max_index = 8;
- } else {
- t->throbber.running = false;
- t->throbber.index = THROBBER_INACTIVE_INDEX;
- t->throbber.max_index = THROBBER_MAX_INDEX;
- }
+ t->throbber.index = THROBBER_INACTIVE_INDEX;
+ t->throbber.max_index = THROBBER_MAX_INDEX;
t->throbber.running = false;
LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
@@ -355,6 +316,7 @@ void toolbar_destroy(struct s_toolbar *tb)
static void toolbar_reflow(struct s_toolbar *tb)
{
+ int i;
// position toolbar areas:
aes_toolbar->ob_x = tb->area.g_x;
@@ -383,14 +345,27 @@ static void toolbar_reflow(struct s_toolbar *tb)
((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height
- throbber_form[tb->throbber.index].ob_height) >> 1);
-
+ // set button states:
+ for (i=0; i < tb->btcnt; i++ ) {
+ if (tb->buttons[i].state == button_off) {
+ aes_toolbar[tb->buttons[i].rsc_id].ob_state |= OS_DISABLED;
+ }
+ else if (tb->buttons[i].state == button_on) {
+ aes_toolbar[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
+ }
+ }
tb->reflow = false;
+ // TODO: iterate through all other toolbars and set reflow = true
}
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
{
GRECT area;
+ if (tb->attached == false) {
+ return;
+ }
+
if(tb->reflow == true)
toolbar_reflow(tb);
@@ -415,9 +390,6 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
r.x1 = r.x0 + area.g_w;
plot_set_dimensions(url_area.g_x, url_area.g_y, url_area.g_w,
url_area.g_h);
- textarea_set_dimensions(tb->url.textarea,
- aes_toolbar[TOOLBAR_URL_AREA].ob_width,
- 20);
textarea_redraw(tb->url.textarea, 0, 0, &r, &toolbar_rdrw_ctx);
}
}
@@ -427,12 +399,89 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
short button)
{
LOG((""));
+
+ struct s_tb_button * bt;
+ bool enable = false;
+ GRECT area;
+
+ assert(bw != NULL);
+
+ if (button == TOOLBAR_BT_BACK || button <= 0 ) {
+ bt = find_button(tb, TOOLBAR_BT_BACK);
+ enable = browser_window_back_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (button == TOOLBAR_BT_HOME || button <= 0 ){
+
+ }
+
+ if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
+ bt = find_button(tb, TOOLBAR_BT_FORWARD);
+ enable = browser_window_forward_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
+ bt = find_button(tb, TOOLBAR_BT_RELOAD);
+ enable = browser_window_reload_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (button == TOOLBAR_BT_STOP || button <= 0) {
+ bt = find_button(tb, TOOLBAR_BT_STOP);
+ enable = browser_window_stop_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
+
+ if (tb->attached) {
+ if (button > 0) {
+ toolbar_get_grect(tb, button, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ else {
+ toolbar_get_grect(tb, TOOLBAR_NAVIGATION_AREA, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ }
}
void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
{
- tb->area = *area;
+
+
+ if (area->g_w != tb->area.g_w || area->g_h != tb->area.g_h) {
+ tb->area = *area;
+ /* reflow now, just for url input calucation: */
+ toolbar_reflow(tb);
+ /* this will request an textarea redraw: */
+ textarea_set_dimensions(tb->url.textarea,
+ aes_toolbar[TOOLBAR_URL_AREA].ob_width,
+ 20);
+ }
+ else {
+ tb->area = *area;
+ }
+ /* reflow for next redraw: */
+ /* TODO: that's only required because we do not reset others toolbars reflow
+ state on reflow */
tb->reflow = true;
}
@@ -442,10 +491,14 @@ void toolbar_set_url(struct s_toolbar *tb, const char * text)
LOG((""));
textarea_set_text(tb->url.textarea, text);
- GRECT area;
- toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
-
- window_schedule_redraw_grect(tb->owner, &area);
+ if (tb->attached) {
+ GRECT area;
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ toolbar_update_buttons(tb, gw->browser->bw , 0);
+ }
}
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
@@ -464,6 +517,12 @@ void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
window_schedule_redraw_grect(tb->owner, &throbber_area);
}
+void toolbar_set_attached(struct s_toolbar *tb, bool attached)
+{
+ tb->attached = attached;
+
+}
+
void toolbar_throbber_progress(struct s_toolbar *tb)
{
GRECT throbber_area;
@@ -493,17 +552,145 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text)
bool toolbar_key_input(struct s_toolbar *tb, short nkc)
{
- bool handled = true;
- LOG((""));
+ assert(tb!=NULL);
+ GRECT work;
+ bool ret = false;
- return(handled);
+ struct gui_window *gw = window_get_active_gui_window(tb->owner);
+
+ assert( gw != NULL );
+
+ long ucs4;
+ long ik = nkc_to_input_key(nkc, &ucs4);
+
+ if (ik == 0) {
+ if ((nkc&0xFF) >= 9) {
+ ret = textarea_keypress(tb->url.textarea, ucs4);
+ }
+ }
+ else if (ik == KEY_CR || ik == KEY_NL) {
+ char tmp_url[PATH_MAX];
+ if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
+ window_set_focus(tb->owner, BROWSER, gw->browser);
+ browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
+ ret = true;
+ }
+ }
+ else if (ik == KEY_COPY_SELECTION) {
+ // copy whole text
+ char * text;
+ int len;
+ len = textarea_get_text( tb->url.textarea, NULL, 0 );
+ text = malloc( len+1 );
+ if (text){
+ textarea_get_text( tb->url.textarea, text, len+1 );
+ scrap_txt_write( &app, text );
+ free( text );
+ }
+ }
+ else if ( ik == KEY_PASTE) {
+ char * clip = scrap_txt_read( &app );
+ if ( clip != NULL ){
+ int clip_length = strlen( clip );
+ if ( clip_length > 0 ) {
+ char *utf8;
+ utf8_convert_ret res;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ res = utf8_from_local_encoding( clip, clip_length, &utf8 );
+ if ( res == UTF8_CONVERT_OK ) {
+ toolbar_set_url(tb, utf8);
+ free(utf8);
+ ret = true;
+ }
+ free( clip );
+ }
+ }
+ }
+ else if (ik == KEY_ESCAPE) {
+ textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
+ textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
+ }
+ else {
+ ret = textarea_keypress( tb->url.textarea, ik );
+ }
+
+ return( ret );
}
-void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my)
+void toolbar_mouse_input(struct s_toolbar *tb, short obj)
{
LOG((""));
+ GRECT work;
+ short mx, my, mb, kstat;
+ int old;
+
+ if (obj==TOOLBAR_URL_AREA){
+
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
+ mx -= work.g_x;
+ my -= work.g_y;
+
+ /* TODO: reset mouse state of browser window? */
+ /* select whole text when newly focused, otherwise set caret to
+ end of text */
+ if (!window_url_widget_has_focus(tb->owner)) {
+ window_set_focus(tb->owner, URL_WIDGET, (void*)&tb->url );
+ }
+ /* url widget has focus and mouse button is still pressed... */
+ else if (mb & 1) {
+
+ textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
+ mx, my );
+ short prev_x = mx;
+ short prev_y = my;
+ do {
+ if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_HOLDING_1, mx, my );
+ prev_x = mx;
+ prev_y = my;
+ window_schedule_redraw_grect(tb->owner, &work);
+ window_process_redraws(tb->owner);
+ }
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
+ my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
+ } while (mb & 1);
+
+ textarea_drag_end( tb->url.textarea, 0, mx, my );
+ }
+ else {
+ /* when execution reaches here, mouse input is a click or dclick */
+ /* TODO: recognize click + shitoolbar_update_buttonsft key */
+ int mstate = BROWSER_MOUSE_PRESS_1;
+ if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 ){
+ mstate = BROWSER_MOUSE_MOD_1;
+ }
+ if( aes_event_out.emo_mclicks == 2 ){
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
+ my);
+ toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
+ window_schedule_redraw_grect(tb->owner, &work);
+ } else {
+ textarea_mouse_action(tb->url.textarea,
+ BROWSER_MOUSE_PRESS_1, mx, my );
+ }
+ }
+ } else {
+ struct s_tb_button *bt = find_button(tb, obj);
+ if (bt != NULL && bt->state != button_off) {
+ bt->cb_click(tb);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ toolbar_update_buttons(tb, gw->browser->bw,
+ 0);
+ }
+
+ }
}
@@ -526,8 +713,8 @@ void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst)
dst->g_w = aes_toolbar[which].ob_width;
dst->g_h = aes_toolbar[which].ob_height;
- printf("Toolbar get grect (%d): ", which);
- dbg_grect("", dst);
+ //printf("Toolbar get grect (%d): ", which);
+ //dbg_grect("", dst);
}
@@ -541,43 +728,68 @@ struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
/* public event handler */
void toolbar_back_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
-
- struct browser_window *bw = input_window->browser->bw;
-
- if( history_back_available(bw->history) )
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ if( history_back_available(bw->history) )
history_back(bw, bw->history);
}
void toolbar_reload_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- browser_window_reload(input_window->browser->bw, true);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ browser_window_reload(bw, true);
}
void toolbar_forward_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- struct browser_window *bw = input_window->browser->bw;
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
}
void toolbar_home_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
struct browser_window * bw;
struct gui_window * gw;
gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
bw = gw->browser->bw;
+ assert(bw != NULL);
browser_window_go(bw, option_homepage_url, 0, true);
}
void toolbar_stop_click(struct s_toolbar *tb)
{
- assert(input_window != NULL);
- browser_window_stop(input_window->browser->bw);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ browser_window_stop(bw);
}
diff --git a/atari/toolbar.h b/atari/toolbar.h
index 6a40cf3..d13b59c 100644
--- a/atari/toolbar.h
+++ b/atari/toolbar.h
@@ -39,7 +39,7 @@ struct s_toolbar
GRECT area;
/* size & location of buttons: */
struct s_tb_button * buttons;
- bool hidden;
+ bool attached;
int btcnt;
int style;
bool redraw;
@@ -55,13 +55,14 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
void toolbar_set_url(struct s_toolbar *tb, const char *text);
bool toolbar_text_input(struct s_toolbar *tb, char *text);
bool toolbar_key_input(struct s_toolbar *tb, short nkc);
-void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
+void toolbar_mouse_input(struct s_toolbar *tb, short obj);
void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
short idx);
void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *g);
struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
enum toolbar_textarea which);
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active);
+void toolbar_set_attached(struct s_toolbar *tb, bool attached);
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip);
void toolbar_throbber_progress(struct s_toolbar *tb);
/* public events handlers: */
diff --git a/atari/treeview.c b/atari/treeview.c
index 7144d21..52859e3 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -95,18 +95,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
- printf("Treeview keybd\n");
on_keybd_event(tv, ev_out, msg);
- // handle key
- }
- if( (ev_out->emo_events & MU_TIMER) != 0 ) {
- // handle_timer();
}
if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
LOG(("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_y));
- printf("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
on_mbutton_event(tv, ev_out, msg);
}
--
NetSurf Browser
10 years, 2 months
netsurf: branch master updated. 1e2cc766cdb16f1a5ef3201df5601ffbc22a8bc8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/1e2cc766cdb16f1a5ef32...
...commit http://git.netsurf-browser.org/netsurf.git/commit/1e2cc766cdb16f1a5ef3201...
...tree http://git.netsurf-browser.org/netsurf.git/tree/1e2cc766cdb16f1a5ef3201df...
The branch, master has been updated
via 1e2cc766cdb16f1a5ef3201df5601ffbc22a8bc8 (commit)
via ffcb07b8b2a4d5096d8bd794b1b34c5ffdfd5b17 (commit)
from 31c9ffb4b51b79394f882e5efed629c2df0600d9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/1e2cc766cdb16f1a5ef...
commit 1e2cc766cdb16f1a5ef3201df5601ffbc22a8bc8
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Update documentation
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index b39ea3d..f1536a2 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -182,9 +182,8 @@ links clicked within NetSurf.
Items from the hotlist can be added to the Hotlist menu as follows:
Select Hotlist => Show hotlist...
-Add a folder called Menu. This must not be placed within any other folder.
-Items in this folder node up to a maximum (currently) of 40 items will be added to the Hotlist menu, within the limits of the Intuition menu system.
+Items in the "Hotlist menu" folder node, up to a maximum (currently) of 40 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
Items in folders within the Menu folder node will be converted to subitems in the menu.
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ffcb07b8b2a4d5096d8...
commit ffcb07b8b2a4d5096d8bd794b1b34c5ffdfd5b17
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Make hotlist toolbar actually work
diff --git a/amiga/gui.c b/amiga/gui.c
index 7482b4b..92ad354 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1601,16 +1601,6 @@ void ami_handle_msg(void)
browser_window_go(gwin->bw,(char *)storage, NULL, true);
break;
- case GID_HOTLIST:
- GetAttr(SPEEDBAR_SelectedNode,
- (Object *)gwin->objects[GID_HOTLIST],
- (ULONG *)&tabnode);
- printf("%lx %d\n", tabnode, code);
- GetSpeedButtonNodeAttrs(tabnode, SBNA_UserData, (ULONG *)&url, TAG_DONE);
- printf("%s\n", url);
- browser_window_go(gwin->bw, url, NULL, true);
- break;
-
case GID_HOME:
browser_window_go(gwin->bw,nsoption_charp(homepage_url),NULL,true);
break;
@@ -1644,6 +1634,7 @@ void ami_handle_msg(void)
ami_gui_history(gwin, false);
break;
+ case GID_HOTLIST:
default:
// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
break;
@@ -2506,6 +2497,7 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
SpeedBarObject,
GA_ID, GID_HOTLIST,
GA_RelVerify, TRUE,
+ ICA_TARGET, ICTARGET_IDCMP,
SPEEDBAR_BevelStyle, BVS_NONE,
SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
SpeedBarEnd;
@@ -4283,6 +4275,8 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
struct gui_window_2 *gwin = hook->h_Data;
struct IntuiWheelData *wheel;
Object *reqrefresh = NULL;
+ struct Node *node = NULL;
+ char *url;
switch(msg->Class)
{
@@ -4299,6 +4293,13 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
gwin->redraw_required = true;
break;
+
+ case GID_HOTLIST:
+ if(node = GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
+ GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
+ browser_window_go(gwin->bw, url, NULL, true);
+ }
+ break;
}
break;
-----------------------------------------------------------------------
Summary of changes:
amiga/dist/NetSurf.guide | 3 +--
amiga/gui.c | 21 +++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index b39ea3d..f1536a2 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -182,9 +182,8 @@ links clicked within NetSurf.
Items from the hotlist can be added to the Hotlist menu as follows:
Select Hotlist => Show hotlist...
-Add a folder called Menu. This must not be placed within any other folder.
-Items in this folder node up to a maximum (currently) of 40 items will be added to the Hotlist menu, within the limits of the Intuition menu system.
+Items in the "Hotlist menu" folder node, up to a maximum (currently) of 40 items, will be added to the Hotlist menu, within the limits of the Intuition menu system.
Items in folders within the Menu folder node will be converted to subitems in the menu.
diff --git a/amiga/gui.c b/amiga/gui.c
index 7482b4b..92ad354 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1601,16 +1601,6 @@ void ami_handle_msg(void)
browser_window_go(gwin->bw,(char *)storage, NULL, true);
break;
- case GID_HOTLIST:
- GetAttr(SPEEDBAR_SelectedNode,
- (Object *)gwin->objects[GID_HOTLIST],
- (ULONG *)&tabnode);
- printf("%lx %d\n", tabnode, code);
- GetSpeedButtonNodeAttrs(tabnode, SBNA_UserData, (ULONG *)&url, TAG_DONE);
- printf("%s\n", url);
- browser_window_go(gwin->bw, url, NULL, true);
- break;
-
case GID_HOME:
browser_window_go(gwin->bw,nsoption_charp(homepage_url),NULL,true);
break;
@@ -1644,6 +1634,7 @@ void ami_handle_msg(void)
ami_gui_history(gwin, false);
break;
+ case GID_HOTLIST:
default:
// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
break;
@@ -2506,6 +2497,7 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
SpeedBarObject,
GA_ID, GID_HOTLIST,
GA_RelVerify, TRUE,
+ ICA_TARGET, ICTARGET_IDCMP,
SPEEDBAR_BevelStyle, BVS_NONE,
SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
SpeedBarEnd;
@@ -4283,6 +4275,8 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
struct gui_window_2 *gwin = hook->h_Data;
struct IntuiWheelData *wheel;
Object *reqrefresh = NULL;
+ struct Node *node = NULL;
+ char *url;
switch(msg->Class)
{
@@ -4299,6 +4293,13 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
gwin->redraw_required = true;
break;
+
+ case GID_HOTLIST:
+ if(node = GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress)) {
+ GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
+ browser_window_go(gwin->bw, url, NULL, true);
+ }
+ break;
}
break;
--
NetSurf Browser
10 years, 2 months