nsgenjsbind: branch master updated. 24d68eb4e19e48c80a44af324499e1e16863e768
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/24d68eb4e19e48c80...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/24d68eb4e19e48c80a4...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/24d68eb4e19e48c80a44a...
The branch, master has been updated
via 24d68eb4e19e48c80a44af324499e1e16863e768 (commit)
from bb6e9d7f5f71677aa4fc79fed01919ea0bbb20c4 (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/nsgenjsbind.git/commitdiff/24d68eb4e19e48c...
commit 24d68eb4e19e48c80a44af324499e1e16863e768
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
ensure newly created objects survive teh garbage collector long enough to be constructed.
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0711e75..476c99e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -357,7 +357,16 @@ output_class_new(struct binding *binding)
"\tif (newobject == NULL) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
- "\t}\n"
+ "\t}\n\n");
+
+ /* root object to stop it being garbage collected */
+ fprintf(binding->outfile,
+ "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
"\n"
"\t/* attach private pointer */\n"
"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
@@ -365,6 +374,7 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n\n");
+
/* attach operations and attributes (functions and properties) */
fprintf(binding->outfile,
"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -383,6 +393,12 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n");
+ /* root object to stop it being garbage collected */
+ fprintf(binding->outfile,
+ "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
/* attach operations and attributes (functions and properties) */
fprintf(binding->outfile,
"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -395,8 +411,9 @@ output_class_new(struct binding *binding)
"\t}\n\n");
}
-
+ /* unroot object and return it */
fprintf(binding->outfile,
+ "\tJS_RemoveRoot(cx, &newobject);\n"
"\n"
"\treturn newobject;\n"
"}\n");
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0711e75..476c99e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -357,7 +357,16 @@ output_class_new(struct binding *binding)
"\tif (newobject == NULL) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
- "\t}\n"
+ "\t}\n\n");
+
+ /* root object to stop it being garbage collected */
+ fprintf(binding->outfile,
+ "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
"\n"
"\t/* attach private pointer */\n"
"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
@@ -365,6 +374,7 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n\n");
+
/* attach operations and attributes (functions and properties) */
fprintf(binding->outfile,
"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -383,6 +393,12 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n");
+ /* root object to stop it being garbage collected */
+ fprintf(binding->outfile,
+ "\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
/* attach operations and attributes (functions and properties) */
fprintf(binding->outfile,
"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -395,8 +411,9 @@ output_class_new(struct binding *binding)
"\t}\n\n");
}
-
+ /* unroot object and return it */
fprintf(binding->outfile,
+ "\tJS_RemoveRoot(cx, &newobject);\n"
"\n"
"\treturn newobject;\n"
"}\n");
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch master updated. e36b8f657997ffca3d1cc1fe1a7130854d247262
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e36b8f657997ffca3d1cc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e36b8f657997ffca3d1cc1f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e36b8f657997ffca3d1cc1fe1...
The branch, master has been updated
via e36b8f657997ffca3d1cc1fe1a7130854d247262 (commit)
from c5fb16d56df03580d99fae44d9fea44868f33cc5 (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/e36b8f657997ffca3d1...
commit e36b8f657997ffca3d1cc1fe1a7130854d247262
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
safely deal with NULL strings
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 80a30bb..7ca4948 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -181,19 +181,22 @@ operation createTextNode %{
dom_exception exc;
dom_text *text;
- JSLOG("Creating text node for string \"%s\"", data);
- exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (data != NULL) {
- exc = dom_document_create_text_node(private->node, data_dom, &text);
- dom_string_unref(data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ JSLOG("Creating text node for string \"%s\"", data);
+ exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ exc = dom_document_create_text_node(private->node, data_dom, &text);
+ dom_string_unref(data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
@@ -205,19 +208,21 @@ operation createElement %{
dom_exception exc;
dom_element *element;
- JSLOG("Creating text node for string \"%s\"", localName);
- exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (localName != NULL) {
+ JSLOG("Creating text node for string \"%s\"", localName);
+ exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- exc = dom_document_create_element(private->node, localName_dom, &element);
- dom_string_unref(localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ exc = dom_document_create_element(private->node, localName_dom, &element);
+ dom_string_unref(localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-node-enumerate.html
index 6cbff24..261d680 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-node-enumerate.html
@@ -16,6 +16,12 @@ function output(x,y) {
for(var key in Node){
output(key, Node[key]);
}
+
+ document.body.appendChild(document.createElement('hr'));
+
+for(var key in document.body){
+output(key, document.body[key]);
+}
</script>
</body>
</html>
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/htmldocument.bnd | 49 ++++++++++++++++++++----------------
test/js/dom-node-enumerate.html | 6 ++++
2 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 80a30bb..7ca4948 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -181,19 +181,22 @@ operation createTextNode %{
dom_exception exc;
dom_text *text;
- JSLOG("Creating text node for string \"%s\"", data);
- exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (data != NULL) {
- exc = dom_document_create_text_node(private->node, data_dom, &text);
- dom_string_unref(data_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ JSLOG("Creating text node for string \"%s\"", data);
+ exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ exc = dom_document_create_text_node(private->node, data_dom, &text);
+ dom_string_unref(data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
@@ -205,19 +208,21 @@ operation createElement %{
dom_exception exc;
dom_element *element;
- JSLOG("Creating text node for string \"%s\"", localName);
- exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (localName != NULL) {
+ JSLOG("Creating text node for string \"%s\"", localName);
+ exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- exc = dom_document_create_element(private->node, localName_dom, &element);
- dom_string_unref(localName_dom);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ exc = dom_document_create_element(private->node, localName_dom, &element);
+ dom_string_unref(localName_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
- jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ }
JSLOG("returning jsobject %p",jsret);
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-node-enumerate.html
index 6cbff24..261d680 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-node-enumerate.html
@@ -16,6 +16,12 @@ function output(x,y) {
for(var key in Node){
output(key, Node[key]);
}
+
+ document.body.appendChild(document.createElement('hr'));
+
+for(var key in document.body){
+output(key, document.body[key]);
+}
</script>
</body>
</html>
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. bb6e9d7f5f71677aa4fc79fed01919ea0bbb20c4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/bb6e9d7f5f71677aa...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/bb6e9d7f5f71677aa4f...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/bb6e9d7f5f71677aa4fc7...
The branch, master has been updated
via bb6e9d7f5f71677aa4fc79fed01919ea0bbb20c4 (commit)
from 52a0b403fca3b37434c7ed5343d25dcae8734e0b (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/nsgenjsbind.git/commitdiff/bb6e9d7f5f71677...
commit bb6e9d7f5f71677aa4fc79fed01919ea0bbb20c4
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
correctly deal with missing strings in parameters
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index c3084f7..2aaf114 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -33,7 +33,7 @@ static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
*/
} else {
fprintf(binding->outfile,
- "\tJSAPI_FS(%s, 0, 0 /* JSPROP_ENUMERATE */),\n",
+ "\tJSAPI_FS(%s, 0, JSPROP_ENUMERATE ),\n",
webidl_node_gettext(ident_node));
/* @todo number of args to that FN_FS() call should be correct */
}
@@ -642,15 +642,13 @@ output_operation_input(struct binding *binding,
/* JSString * */
fprintf(binding->outfile,
"\tif (argc > %d) {\n"
- "\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
- "\tif (%s_jsstr == NULL) {\n"
- "\t\treturn JS_FALSE;\n"
- "\t}\n\n"
- "\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
"\t} else {\n"
- "\t\t%s = NULL;"
- "\t\t%s_len = 0;"
- "\t}\n",
+ "\t\t%s_jsstr = JS_ValueToString(cx, JSVAL_VOID);\n"
+ "\t}\n"
+ "\tif (%s_jsstr != NULL) {\n"
+ "\t\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t}\n\n",
arg_cur,
webidl_node_gettext(arg_ident),
arg_cur,
@@ -658,7 +656,6 @@ output_operation_input(struct binding *binding,
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
- webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident));
break;
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-operator.c | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index c3084f7..2aaf114 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -33,7 +33,7 @@ static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
*/
} else {
fprintf(binding->outfile,
- "\tJSAPI_FS(%s, 0, 0 /* JSPROP_ENUMERATE */),\n",
+ "\tJSAPI_FS(%s, 0, JSPROP_ENUMERATE ),\n",
webidl_node_gettext(ident_node));
/* @todo number of args to that FN_FS() call should be correct */
}
@@ -642,15 +642,13 @@ output_operation_input(struct binding *binding,
/* JSString * */
fprintf(binding->outfile,
"\tif (argc > %d) {\n"
- "\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
- "\tif (%s_jsstr == NULL) {\n"
- "\t\treturn JS_FALSE;\n"
- "\t}\n\n"
- "\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
"\t} else {\n"
- "\t\t%s = NULL;"
- "\t\t%s_len = 0;"
- "\t}\n",
+ "\t\t%s_jsstr = JS_ValueToString(cx, JSVAL_VOID);\n"
+ "\t}\n"
+ "\tif (%s_jsstr != NULL) {\n"
+ "\t\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t}\n\n",
arg_cur,
webidl_node_gettext(arg_ident),
arg_cur,
@@ -658,7 +656,6 @@ output_operation_input(struct binding *binding,
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
- webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident));
break;
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
nsgenjsbind: branch master updated. 52a0b403fca3b37434c7ed5343d25dcae8734e0b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/52a0b403fca3b3743...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/52a0b403fca3b37434c...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/52a0b403fca3b37434c7e...
The branch, master has been updated
via 52a0b403fca3b37434c7ed5343d25dcae8734e0b (commit)
from 257f535bd18de9a6fc4e9d90303939706a783732 (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/nsgenjsbind.git/commitdiff/52a0b403fca3b37...
commit 52a0b403fca3b37434c7ed5343d25dcae8734e0b
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
correctly construct properties and functions so enumeration is correct. Seems to be an issue setting functions to be enumerable so left disabled for now
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 2bb64d4..c3084f7 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -33,8 +33,9 @@ static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
*/
} else {
fprintf(binding->outfile,
- "\tJSAPI_FS(%s, 0, 0),\n",
+ "\tJSAPI_FS(%s, 0, 0 /* JSPROP_ENUMERATE */),\n",
webidl_node_gettext(ident_node));
+ /* @todo number of args to that FN_FS() call should be correct */
}
return 0;
}
@@ -640,16 +641,24 @@ output_operation_input(struct binding *binding,
case WEBIDL_TYPE_STRING:
/* JSString * */
fprintf(binding->outfile,
+ "\tif (argc > %d) {\n"
"\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
"\tif (%s_jsstr == NULL) {\n"
"\t\treturn JS_FALSE;\n"
"\t}\n\n"
- "\tJSString_to_char(%s_jsstr, %s, %s_len);\n",
+ "\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t} else {\n"
+ "\t\t%s = NULL;"
+ "\t\t%s_len = 0;"
+ "\t}\n",
+ arg_cur,
webidl_node_gettext(arg_ident),
arg_cur,
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
+ webidl_node_gettext(arg_ident),
+ webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident));
break;
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 187d511..0711e75 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -272,8 +272,8 @@ output_class_init(struct binding *binding)
"\t\t&JSClass_%s,\n"
"\t\tNULL,\n"
"\t\t0,\n"
- "\t\tjsclass_properties,\n"
- "\t\tjsclass_functions, \n"
+ "\t\tNULL,\n"
+ "\t\tNULL, \n"
"\t\tNULL, \n"
"\t\tNULL);\n",
binding->interface);
@@ -322,6 +322,7 @@ output_class_new(struct binding *binding)
"{\n"
"\tJSObject *newobject;\n");
+ /* create private data */
if (binding->has_private) {
fprintf(binding->outfile,
"\tstruct jsclass_private *private;\n"
@@ -362,8 +363,38 @@ output_class_new(struct binding *binding)
"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ /* attach operations and attributes (functions and properties) */
+ fprintf(binding->outfile,
+ "\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+ } else {
+ fprintf(binding->outfile,
+ "\tif (newobject == NULL) {\n"
+ "\t\treturn NULL;\n"
"\t}\n");
+
+ /* attach operations and attributes (functions and properties) */
+ fprintf(binding->outfile,
+ "\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
}
+
fprintf(binding->outfile,
"\n"
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-operator.c | 13 +++++++++++--
src/jsapi-libdom.c | 35 +++++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 2bb64d4..c3084f7 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -33,8 +33,9 @@ static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
*/
} else {
fprintf(binding->outfile,
- "\tJSAPI_FS(%s, 0, 0),\n",
+ "\tJSAPI_FS(%s, 0, 0 /* JSPROP_ENUMERATE */),\n",
webidl_node_gettext(ident_node));
+ /* @todo number of args to that FN_FS() call should be correct */
}
return 0;
}
@@ -640,16 +641,24 @@ output_operation_input(struct binding *binding,
case WEBIDL_TYPE_STRING:
/* JSString * */
fprintf(binding->outfile,
+ "\tif (argc > %d) {\n"
"\t%s_jsstr = JS_ValueToString(cx, argv[%d]);\n"
"\tif (%s_jsstr == NULL) {\n"
"\t\treturn JS_FALSE;\n"
"\t}\n\n"
- "\tJSString_to_char(%s_jsstr, %s, %s_len);\n",
+ "\tJSString_to_char(%s_jsstr, %s, %s_len);\n"
+ "\t} else {\n"
+ "\t\t%s = NULL;"
+ "\t\t%s_len = 0;"
+ "\t}\n",
+ arg_cur,
webidl_node_gettext(arg_ident),
arg_cur,
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident),
+ webidl_node_gettext(arg_ident),
+ webidl_node_gettext(arg_ident),
webidl_node_gettext(arg_ident));
break;
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 187d511..0711e75 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -272,8 +272,8 @@ output_class_init(struct binding *binding)
"\t\t&JSClass_%s,\n"
"\t\tNULL,\n"
"\t\t0,\n"
- "\t\tjsclass_properties,\n"
- "\t\tjsclass_functions, \n"
+ "\t\tNULL,\n"
+ "\t\tNULL, \n"
"\t\tNULL, \n"
"\t\tNULL);\n",
binding->interface);
@@ -322,6 +322,7 @@ output_class_new(struct binding *binding)
"{\n"
"\tJSObject *newobject;\n");
+ /* create private data */
if (binding->has_private) {
fprintf(binding->outfile,
"\tstruct jsclass_private *private;\n"
@@ -362,8 +363,38 @@ output_class_new(struct binding *binding)
"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ /* attach operations and attributes (functions and properties) */
+ fprintf(binding->outfile,
+ "\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+ } else {
+ fprintf(binding->outfile,
+ "\tif (newobject == NULL) {\n"
+ "\t\treturn NULL;\n"
"\t}\n");
+
+ /* attach operations and attributes (functions and properties) */
+ fprintf(binding->outfile,
+ "\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
}
+
fprintf(binding->outfile,
"\n"
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch chris/frame-scroll updated. 78e460e4bdfdfb1daed9a9549381f3e742ba4786
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/78e460e4bdfdfb1daed9a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/78e460e4bdfdfb1daed9a95...
...tree http://git.netsurf-browser.org/netsurf.git/tree/78e460e4bdfdfb1daed9a9549...
The branch, chris/frame-scroll has been updated
via 78e460e4bdfdfb1daed9a9549381f3e742ba4786 (commit)
via 056282aaeb7c05ca515611d674f496e258cb6cf6 (commit)
from fe9252bd5eaa70c0b98203049d9bf38b20f93ca6 (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/78e460e4bdfdfb1daed...
commit 78e460e4bdfdfb1daed9a9549381f3e742ba4786
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Redraw newly revealed horizontal and vertical portions separately, avoiding double redraw of any intersection
diff --git a/amiga/gui.c b/amiga/gui.c
index d072993..185049d 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3611,6 +3611,8 @@ printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y
if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+ if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
+
BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
BLITA_Source, gwin->win->RPort,
BLITA_SrcX, src_x,
diff --git a/desktop/frames.c b/desktop/frames.c
index 0163e3d..6dd0d09 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -63,27 +63,39 @@ void browser_window_scroll_callback(void *client_data,
if (bw->browser_window_type == BROWSER_WINDOW_IFRAME) {
html_redraw_a_box(bw->parent->current_content, bw->box);
} else {
- struct rect rect;
+ struct rect rect_x;
+ struct rect rect_y;
struct rect copyrect;
int dest_x = 0;
int dest_y = 0;
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
+ rect_y.x0 = 0;
+ rect_y.x1 = bw->width;
+ rect_x.y0 = 0;
+ rect_x.y1 = bw->height;
+
if(cur_y > bw->prev_scroll_y) {
copyrect.y0 = cur_y - bw->prev_scroll_y;
copyrect.y1 = bw->height;
dest_y = 0;
- rect.y0 = bw->height - copyrect.y0;
- rect.y1 = bw->height;
+ rect_y.y0 = bw->height - copyrect.y0;
+ rect_y.y1 = bw->height;
+
+ rect_x.y0 = 0;
+ rect_x.y1 = rect_y.y0;
} else {
copyrect.y0 = 0;
copyrect.y1 = bw->height - (cur_y - bw->prev_scroll_y);
dest_y = cur_y - bw->prev_scroll_y;
- rect.y0 = 0;
- rect.y1 = cur_y - bw->prev_scroll_y;
+ rect_y.y0 = 0;
+ rect_y.y1 = cur_y - bw->prev_scroll_y;
+
+ rect_x.y0 = rect_y.y1;
+ rect_x.y1 = bw->height;
}
if(cur_x > bw->prev_scroll_x) {
@@ -91,19 +103,20 @@ void browser_window_scroll_callback(void *client_data,
copyrect.x1 = bw->width;
dest_x = 0;
- rect.x0 = bw->height - copyrect.x0;
- rect.x1 = bw->height;
+ rect_x.x0 = bw->height - copyrect.x0;
+ rect_x.x1 = bw->height;
} else {
copyrect.x0 = 0;
copyrect.x1 = bw->width - (cur_x - bw->prev_scroll_x);
dest_x = cur_x - bw->prev_scroll_x;
- rect.x0 = 0;
- rect.x1 = cur_x - bw->prev_scroll_x;
+ rect_x.x0 = 0;
+ rect_x.x1 = cur_x - bw->prev_scroll_x;
}
browser_window_copy_box(bw, ©rect, dest_x, dest_y);
- browser_window_update_box(bw, &rect);
+ browser_window_update_box(bw, &rect_y);
+ browser_window_update_box(bw, &rect_x);
bw->prev_scroll_x = scrollbar_get_offset(bw->scroll_x);
bw->prev_scroll_y = scrollbar_get_offset(bw->scroll_y);
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/056282aaeb7c05ca515...
commit 056282aaeb7c05ca515611d674f496e258cb6cf6
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
More correct values for copyrect
diff --git a/desktop/frames.c b/desktop/frames.c
index 4de33cb..0163e3d 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -70,38 +70,38 @@ void browser_window_scroll_callback(void *client_data,
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
- if(cur_x > bw->prev_scroll_x) {
- copyrect.x0 = cur_x;
- copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
- dest_x = bw->prev_scroll_x;
-
- rect.x0 = copyrect.x0;
- rect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
- } else {
- copyrect.x0 = bw->prev_scroll_x;
- copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
- dest_x = cur_x;
+ if(cur_y > bw->prev_scroll_y) {
+ copyrect.y0 = cur_y - bw->prev_scroll_y;
+ copyrect.y1 = bw->height;
+ dest_y = 0;
- rect.x0 = cur_x;
- rect.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
+ rect.y0 = bw->height - copyrect.y0;
+ rect.y1 = bw->height;
+ } else {
+ copyrect.y0 = 0;
+ copyrect.y1 = bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = cur_y - bw->prev_scroll_y;
+
+ rect.y0 = 0;
+ rect.y1 = cur_y - bw->prev_scroll_y;
}
- if(cur_y > bw->prev_scroll_y) {
- copyrect.y0 = cur_y;
- copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
- dest_y = bw->prev_scroll_y;
+ if(cur_x > bw->prev_scroll_x) {
+ copyrect.x0 = cur_x - bw->prev_scroll_x;
+ copyrect.x1 = bw->width;
+ dest_x = 0;
- rect.y0 = copyrect.y0;
- rect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ rect.x0 = bw->height - copyrect.x0;
+ rect.x1 = bw->height;
} else {
- copyrect.y0 = bw->prev_scroll_y;
- copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
- dest_y = cur_y;
+ copyrect.x0 = 0;
+ copyrect.x1 = bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = cur_x - bw->prev_scroll_x;
- rect.y0 = cur_y;
- rect.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
+ rect.x0 = 0;
+ rect.x1 = cur_x - bw->prev_scroll_x;
}
-
+
browser_window_copy_box(bw, ©rect, dest_x, dest_y);
browser_window_update_box(bw, &rect);
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 2 +
desktop/frames.c | 65 ++++++++++++++++++++++++++++++++---------------------
2 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index d072993..185049d 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3611,6 +3611,8 @@ printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y
if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+ if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
+
BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
BLITA_Source, gwin->win->RPort,
BLITA_SrcX, src_x,
diff --git a/desktop/frames.c b/desktop/frames.c
index 4de33cb..6dd0d09 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -63,47 +63,60 @@ void browser_window_scroll_callback(void *client_data,
if (bw->browser_window_type == BROWSER_WINDOW_IFRAME) {
html_redraw_a_box(bw->parent->current_content, bw->box);
} else {
- struct rect rect;
+ struct rect rect_x;
+ struct rect rect_y;
struct rect copyrect;
int dest_x = 0;
int dest_y = 0;
int cur_x = scrollbar_get_offset(bw->scroll_x);
int cur_y = scrollbar_get_offset(bw->scroll_y);
- if(cur_x > bw->prev_scroll_x) {
- copyrect.x0 = cur_x;
- copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
- dest_x = bw->prev_scroll_x;
-
- rect.x0 = copyrect.x0;
- rect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ rect_y.x0 = 0;
+ rect_y.x1 = bw->width;
+ rect_x.y0 = 0;
+ rect_x.y1 = bw->height;
+
+ if(cur_y > bw->prev_scroll_y) {
+ copyrect.y0 = cur_y - bw->prev_scroll_y;
+ copyrect.y1 = bw->height;
+ dest_y = 0;
+
+ rect_y.y0 = bw->height - copyrect.y0;
+ rect_y.y1 = bw->height;
+
+ rect_x.y0 = 0;
+ rect_x.y1 = rect_y.y0;
} else {
- copyrect.x0 = bw->prev_scroll_x;
- copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
- dest_x = cur_x;
+ copyrect.y0 = 0;
+ copyrect.y1 = bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = cur_y - bw->prev_scroll_y;
+
+ rect_y.y0 = 0;
+ rect_y.y1 = cur_y - bw->prev_scroll_y;
- rect.x0 = cur_x;
- rect.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
+ rect_x.y0 = rect_y.y1;
+ rect_x.y1 = bw->height;
}
- if(cur_y > bw->prev_scroll_y) {
- copyrect.y0 = cur_y;
- copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
- dest_y = bw->prev_scroll_y;
+ if(cur_x > bw->prev_scroll_x) {
+ copyrect.x0 = cur_x - bw->prev_scroll_x;
+ copyrect.x1 = bw->width;
+ dest_x = 0;
- rect.y0 = copyrect.y0;
- rect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ rect_x.x0 = bw->height - copyrect.x0;
+ rect_x.x1 = bw->height;
} else {
- copyrect.y0 = bw->prev_scroll_y;
- copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
- dest_y = cur_y;
+ copyrect.x0 = 0;
+ copyrect.x1 = bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = cur_x - bw->prev_scroll_x;
- rect.y0 = cur_y;
- rect.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
+ rect_x.x0 = 0;
+ rect_x.x1 = cur_x - bw->prev_scroll_x;
}
-
+
browser_window_copy_box(bw, ©rect, dest_x, dest_y);
- browser_window_update_box(bw, &rect);
+ browser_window_update_box(bw, &rect_y);
+ browser_window_update_box(bw, &rect_x);
bw->prev_scroll_x = scrollbar_get_offset(bw->scroll_x);
bw->prev_scroll_y = scrollbar_get_offset(bw->scroll_y);
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. c5fb16d56df03580d99fae44d9fea44868f33cc5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c5fb16d56df03580d99fa...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c5fb16d56df03580d99fae4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c5fb16d56df03580d99fae44d...
The branch, master has been updated
via c5fb16d56df03580d99fae44d9fea44868f33cc5 (commit)
from d1a5c738e62a9f0cb85658b435eefa8749006edc (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/c5fb16d56df03580d99...
commit c5fb16d56df03580d99fae44d9fea44868f33cc5
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Added missing Makefile changes for recent deskmenu commit.
diff --git a/atari/Makefile.target b/atari/Makefile.target
index ad90807..f7e1a63 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c
+ ctxmenu.c settings.c msgbox.c deskmenu.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
-----------------------------------------------------------------------
Summary of changes:
atari/Makefile.target | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/atari/Makefile.target b/atari/Makefile.target
index ad90807..f7e1a63 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c
+ ctxmenu.c settings.c msgbox.c deskmenu.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. d1a5c738e62a9f0cb85658b435eefa8749006edc
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d1a5c738e62a9f0cb8565...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d1a5c738e62a9f0cb85658b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d1a5c738e62a9f0cb85658b43...
The branch, master has been updated
via d1a5c738e62a9f0cb85658b435eefa8749006edc (commit)
from 2bea506f837c9a1e9c12c448eb206e067770819c (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/d1a5c738e62a9f0cb85...
commit d1a5c738e62a9f0cb85658b435eefa8749006edc
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Refactored menu event handling and got rid of several windom calls.
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
new file mode 100644
index 0000000..38e3539
--- /dev/null
+++ b/atari/deskmenu.c
@@ -0,0 +1,660 @@
+#include <stdlib.h>
+#include <windom.h>
+
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/deskmenu.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/toolbar.h"
+#include "atari/settings.h"
+#include "atari/search.h"
+#include "atari/misc.h"
+#include "atari/gui.h"
+#include "atari/findfile.h"
+#include "atari/browser.h"
+#include "atari/browser_win.h"
+
+typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
+
+static void register_menu_str(struct s_menu_item_evnt * mi);
+static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
+
+extern void *h_gem_rsrc;
+extern bool html_redraw_debug;
+extern struct gui_window * input_window;
+extern char options[PATH_MAX];
+extern const char * option_homepage_url;
+extern int option_window_width;
+extern int option_window_height;
+extern int option_window_x;
+extern int option_window_y;
+
+static OBJECT * h_gem_menu;
+
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
+#define NUM_MENU_TITLES 7
+
+
+static void __CDECL menu_about(short item, short title, void *data);
+static void __CDECL menu_new_win(short item, short title, void *data);
+static void __CDECL menu_open_url(short item, short title, void *data);
+static void __CDECL menu_open_file(short item, short title, void *data);
+static void __CDECL menu_close_win(short item, short title, void *data);
+static void __CDECL menu_save_page(short item, short title, void *data);
+static void __CDECL menu_quit(short item, short title, void *data);
+static void __CDECL menu_cut(short item, short title, void *data);
+static void __CDECL menu_copy(short item, short title, void *data);
+static void __CDECL menu_paste(short item, short title, void *data);
+static void __CDECL menu_find(short item, short title, void *data);
+static void __CDECL menu_choices(short item, short title, void *data);
+static void __CDECL menu_stop(short item, short title, void *data);
+static void __CDECL menu_reload(short item, short title, void *data);
+static void __CDECL menu_toolbars(short item, short title, void *data);
+static void __CDECL menu_savewin(short item, short title, void *data);
+static void __CDECL menu_debug_render(short item, short title, void *data);
+static void __CDECL menu_fg_images(short item, short title, void *data);
+static void __CDECL menu_bg_images(short item, short title, void *data);
+static void __CDECL menu_back(short item, short title, void *data);
+static void __CDECL menu_forward(short item, short title, void *data);
+static void __CDECL menu_home(short item, short title, void *data);
+static void __CDECL menu_lhistory(short item, short title, void *data);
+static void __CDECL menu_ghistory(short item, short title, void *data);
+static void __CDECL menu_add_bookmark(short item, short title, void *data);
+static void __CDECL menu_bookmarks(short item, short title, void *data);
+static void __CDECL menu_vlog(short item, short title, void *data);
+static void __CDECL menu_help_content(short item, short title, void *data);
+
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
+};
+
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ OBJECT *gem_menu = deskmenu_get_obj_tree();
+
+ assert(gem_menu != NULL);
+
+ char * str = ObjcString( gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+ while (i > 2) {
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+
+ deskmenu_dispatch_item(buff[3], buff[4]);
+}
+
+/*
+ Menu item event handlers:
+*/
+
+static void __CDECL menu_about(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ char buf[PATH_MAX];
+ strcpy((char*)&buf, "file://");
+ strncat((char*)&buf, (char*)"./doc/README.TXT",
+ PATH_MAX - (strlen("file://")+1) );
+ browser_window_create((char*)&buf, 0, 0, true, false);
+}
+
+static void __CDECL menu_new_win(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+}
+
+static void __CDECL menu_open_url(short item, short title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+ LOG(("%s", __FUNCTION__));
+
+ gw = input_window;
+ if( gw == NULL ) {
+ bw = browser_window_create("", 0, 0, true, false);
+ gw = bw->window;
+
+ }
+ /* Loose focus: */
+ window_set_focus( gw, WIDGET_NONE, NULL );
+
+ /* trigger on-focus event (select all text): */
+ window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+
+ /* delete selection: */
+ tb_url_input( gw, NK_DEL );
+}
+
+static void __CDECL menu_open_file(short item, short title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+
+ LOG(("%s", __FUNCTION__));
+
+ const char * filename = file_select( messages_get("OpenFile"), "" );
+ if( filename != NULL ){
+ char * url = local_file_to_url( filename );
+ if( url ){
+ bw = browser_window_create(url, NULL, NULL, true, false);
+ free( url );
+ }
+ }
+}
+
+static void __CDECL menu_close_win(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ static bool init = true;
+ bool is_folder=false;
+ const char * path;
+
+ if( !input_window )
+ return;
+
+ if( init ){
+ init = false;
+ save_complete_init();
+ }
+
+ do {
+ // TODO: localize string
+ path = file_select("Select folder", "");
+ if (path)
+ is_folder = is_dir(path);
+ } while( !is_folder && path != NULL );
+
+ if( path != NULL ){
+ save_complete( input_window->browser->bw->current_content, path, NULL );
+ }
+
+}
+
+static void __CDECL menu_quit(short item, short title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ netsurf_quit = true;
+}
+
+static void __CDECL menu_cut(short item, short title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ open_browser_search( input_window );
+}
+
+static void __CDECL menu_choices(short item, short title, void *data)
+{
+ static WINDOW * settings_dlg = NULL;
+ LOG(("%s", __FUNCTION__));
+ settings_dlg = open_settings();
+}
+
+static void __CDECL menu_stop(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_stop_click( input_window );
+
+}
+
+static void __CDECL menu_reload(short item, short title, void *data)
+{
+ if( input_window == NULL)
+ return;
+ tb_reload_click( input_window );
+ LOG(("%s", __FUNCTION__));
+}
+
+static void __CDECL menu_toolbars(short item, short title, void *data)
+{
+ static int state = 0;
+ LOG(("%s", __FUNCTION__));
+ if( input_window != null && input_window->root->toolbar != null ){
+ state = !state;
+ tb_hide( input_window, state );
+ }
+}
+
+static void __CDECL menu_savewin(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window && input_window->browser) {
+ GRECT rect;
+ wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ option_window_width = rect.g_w;
+ option_window_height = rect.g_h;
+ option_window_x = rect.g_x;
+ option_window_y = rect.g_y;
+ nsoption_set_int(window_width, rect.g_w);
+ nsoption_set_int(window_height, rect.g_h);
+ nsoption_set_int(window_x, rect.g_x);
+ nsoption_set_int(window_y, rect.g_y);
+ nsoption_write((const char*)&options);
+ }
+
+}
+
+static void __CDECL menu_debug_render(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
+ if ( input_window->browser != NULL
+ && input_window->browser->bw != NULL) {
+ LGRECT rect;
+ 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 );
+ }
+ }
+}
+
+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,
+ (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,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_back_click( input_window );
+}
+
+static void __CDECL menu_forward(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_forward_click( input_window );
+}
+
+static void __CDECL menu_home(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_home_click( input_window );
+}
+
+static void __CDECL menu_lhistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ hotlist_open();
+}
+
+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 );
+}
+
+static void __CDECL menu_help_content(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+}
+
+/*
+ Public deskmenu interface:
+*/
+
+
+/**
+* Setup & display an desktop menu.
+*/
+
+void deskmenu_init(void)
+{
+ int i;
+
+ h_gem_menu = get_tree(MAINMENU);
+
+ // TODO: remove that call somehow...
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ /* Update menu string if not null: */
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
+ menu_evnt_tbl[i].menustr);
+ }
+ i++;
+ }
+ deskmenu_update();
+
+ menu_bar(h_gem_menu, 100);
+ menu_bar(h_gem_menu, 1);
+
+ // TODO: remove windom dependency.
+ EvntAttach(NULL, MN_SELECTED, evnt_menu);
+}
+
+/**
+* Uninstall the desktop menu
+*/
+void deskmenu_destroy(void)
+{
+ int i;
+
+ /* Remove menu from desktop: */
+ menu_bar(h_gem_menu, 0);
+
+ /* Free modified menu titles: */
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
+ }
+}
+
+/**
+* Return the deskmenu AES OBJECT tree
+*/
+OBJECT * deskmenu_get_obj_tree(void)
+{
+ return(h_gem_menu);
+}
+
+/**
+* Handle an menu item event
+*/
+int deskmenu_dispatch_item(short title, short item)
+{
+ int i=0;
+ int retval = 0;
+ OBJECT * menu_root = deskmenu_get_obj_tree();
+
+ menu_tnormal(menu_root, item, 1);
+ menu_tnormal(menu_root, title, 1);
+ menu_bar(menu_root, 1);
+
+ // legacy code, is this sensible?:
+ /*
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ */
+
+
+ while (menu_evnt_tbl[i].rid != -1) {
+ if (menu_evnt_tbl[i].rid == item) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func(item, title, NULL);
+ }
+ break;
+ }
+ i++;
+ }
+
+ return(retval);
+}
+
+/**
+* Handle an keypress (check for accelerator)
+*/
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ char sascii;
+ bool done = 0;
+ int i = 0;
+
+ sascii = keybd2ascii(kcode, K_LSHIFT);
+
+ /* Iterate through the menu function table: */
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ if( kstate == menu_evnt_tbl[i].accel.mod
+ && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ return((done==true) ? 1 : 0);
+}
+
+/**
+* Refresh the desk menu, reflecting netsurf current state.
+*/
+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,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
+
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
new file mode 100644
index 0000000..6ab00dc
--- /dev/null
+++ b/atari/deskmenu.h
@@ -0,0 +1,12 @@
+#ifndef DESKMENU_H_INCLUDED
+#define DESKMENU_H_INCLUDED
+
+void deskmenu_init(void);
+void deskmenu_destroy(void);
+int deskmenu_dispatch_item(short title, short item);
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
+OBJECT * deskmenu_get_obj_tree(void);
+void deskmenu_update( void );
+
+#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 3b15af8..e3a93a0 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,379 +26,31 @@
#include <windom.h>
#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
-#include "atari/findfile.h"
-#include "atari/settings.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
-extern bool html_redraw_debug;
-
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-extern char options[PATH_MAX];
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
-}
-
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
- LGRECT rect;
- 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 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window ) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
+void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
{
int i = 0;
LOG((""));
@@ -406,7 +58,7 @@ void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
}
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
+static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -416,23 +68,23 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if( gw == NULL)
+ if (gw == NULL)
return;
- if( prev_x == evnt.mx && prev_y == evnt.my ){
+ if (prev_x == evnt.mx && prev_y == evnt.my) {
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ if (input_window->root->handle->handle == ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -442,7 +94,7 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
);
}
- if( gw->root->toolbar && within == false ) {
+ if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -466,7 +118,6 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -500,178 +151,23 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
- }
- }
- i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
-
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
}
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
-
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
}
void unbind_global_events( void )
{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
+
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1e13264..76e73fc 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,6 +18,8 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
+
+#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -32,31 +34,14 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
+struct s_evnt_data evnt_data;
/*
- Global & Menu event handlers
+ Global event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
-void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index c2158e0..fdcb752 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,7 +73,8 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
+#include "atari/search.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -82,9 +83,8 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-OBJECT * h_gem_menu;
-OBJECT **rsc_trindex;
-short rsc_ntree;
+//OBJECT **rsc_trindex;
+//short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,6 +789,8 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
+
+ unbind_global_events();
while( gw ) {
tmp = gw->next;
@@ -802,10 +804,8 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- RsrcXtype( 0, rsc_trindex, rsc_ntree);
- unbind_global_events();
- MenuBar( h_gem_menu , 0 );
+
+ deskmenu_destroy();
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,7 +885,8 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form,
+ MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -928,16 +929,18 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ if (rsrc_load(buf)==0) {
+ die("Uable to open GEM Resource file!");
+ }
+ //h_gem_rsrc = RsrcXload( (char*) &buf );
- if( !h_gem_rsrc )
- die("Uable to open GEM Resource file!");
- rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ //if( !h_gem_rsrc )
+ // die("Uable to open GEM Resource file!");
+ //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
- RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -981,19 +984,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
+ plot_init(nsoption_charp(atari_font_driver));
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- MenuBar( h_gem_menu , 1 );
- bind_global_events();
+ deskmenu_init();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ }
+ bind_global_events();
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index 8b745fd..e5b0dc1 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,7 +273,8 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ rsrc_gaddr(R_TREE, idx, &tree);
+ //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 8143cdc..25e0c0f 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,7 +31,8 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-#include "atari/global_evnt.h"
+//#include "atari/global_evnt.h"
+#include "atari/deskmenu.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -232,7 +233,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- main_menu_update();
+ deskmenu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
-----------------------------------------------------------------------
Summary of changes:
atari/{global_evnt.c => deskmenu.c} | 757 +++++++++++++++++------------------
atari/deskmenu.h | 12 +
atari/global_evnt.c | 534 +------------------------
atari/global_evnt.h | 23 +-
atari/gui.c | 47 ++-
atari/misc.c | 3 +-
atari/settings.c | 5 +-
7 files changed, 431 insertions(+), 950 deletions(-)
copy atari/{global_evnt.c => deskmenu.c} (52%)
mode change 100755 => 100644
create mode 100644 atari/deskmenu.h
diff --git a/atari/global_evnt.c b/atari/deskmenu.c
old mode 100755
new mode 100644
similarity index 52%
copy from atari/global_evnt.c
copy to atari/deskmenu.c
index 3b15af8..38e3539
--- a/atari/global_evnt.c
+++ b/atari/deskmenu.c
@@ -1,73 +1,59 @@
-/*
- * 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/>.
- */
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <windom.h>
-
-#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
-#include "utils/log.h"
+#include <stdlib.h>
+#include <windom.h>
+
+#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
-
-#include "atari/gui.h"
-#include "atari/browser_win.h"
-#include "atari/toolbar.h"
-#include "atari/browser.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/options.h"
+#include "desktop/save_complete.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/deskmenu.h"
#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
-#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
+#include "atari/history.h"
+#include "atari/toolbar.h"
+#include "atari/settings.h"
+#include "atari/search.h"
+#include "atari/misc.h"
+#include "atari/gui.h"
#include "atari/findfile.h"
-#include "atari/settings.h"
-#include "cflib.h"
-
-extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
-extern int mouse_click_time[3];
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
-extern bool html_redraw_debug;
+#include "atari/browser.h"
+#include "atari/browser_win.h"
+
+typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
+
+static void register_menu_str(struct s_menu_item_evnt * mi);
+static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
+
+extern void *h_gem_rsrc;
+extern bool html_redraw_debug;
+extern struct gui_window * input_window;
+extern char options[PATH_MAX];
extern const char * option_homepage_url;
extern int option_window_width;
extern int option_window_height;
extern int option_window_x;
extern int option_window_y;
-extern char options[PATH_MAX];
+
+static OBJECT * h_gem_menu;
+
/* Zero based resource tree ids: */
#define T_ABOUT 0
@@ -80,33 +66,184 @@ extern char options[PATH_MAX];
/* Count of the above defines: */
#define NUM_MENU_TITLES 7
-/* Global event handlers: */
-static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
+
+static void __CDECL menu_about(short item, short title, void *data);
+static void __CDECL menu_new_win(short item, short title, void *data);
+static void __CDECL menu_open_url(short item, short title, void *data);
+static void __CDECL menu_open_file(short item, short title, void *data);
+static void __CDECL menu_close_win(short item, short title, void *data);
+static void __CDECL menu_save_page(short item, short title, void *data);
+static void __CDECL menu_quit(short item, short title, void *data);
+static void __CDECL menu_cut(short item, short title, void *data);
+static void __CDECL menu_copy(short item, short title, void *data);
+static void __CDECL menu_paste(short item, short title, void *data);
+static void __CDECL menu_find(short item, short title, void *data);
+static void __CDECL menu_choices(short item, short title, void *data);
+static void __CDECL menu_stop(short item, short title, void *data);
+static void __CDECL menu_reload(short item, short title, void *data);
+static void __CDECL menu_toolbars(short item, short title, void *data);
+static void __CDECL menu_savewin(short item, short title, void *data);
+static void __CDECL menu_debug_render(short item, short title, void *data);
+static void __CDECL menu_fg_images(short item, short title, void *data);
+static void __CDECL menu_bg_images(short item, short title, void *data);
+static void __CDECL menu_back(short item, short title, void *data);
+static void __CDECL menu_forward(short item, short title, void *data);
+static void __CDECL menu_home(short item, short title, void *data);
+static void __CDECL menu_lhistory(short item, short title, void *data);
+static void __CDECL menu_ghistory(short item, short title, void *data);
+static void __CDECL menu_add_bookmark(short item, short title, void *data);
+static void __CDECL menu_bookmarks(short item, short title, void *data);
+static void __CDECL menu_vlog(short item, short title, void *data);
+static void __CDECL menu_help_content(short item, short title, void *data);
+
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
+};
+
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ OBJECT *gem_menu = deskmenu_get_obj_tree();
+
+ assert(gem_menu != NULL);
+
+ char * str = ObjcString( gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+ while (i > 2) {
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+
+ deskmenu_dispatch_item(buff[3], buff[4]);
+}
+
+/*
+ Menu item event handlers:
+*/
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_about(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
char buf[PATH_MAX];
strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ strncat((char*)&buf, (char*)"./doc/README.TXT",
+ PATH_MAX - (strlen("file://")+1) );
browser_window_create((char*)&buf, 0, 0, true, false);
}
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_new_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
browser_window_create(option_homepage_url, 0, 0, true, false);
}
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_url(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -128,7 +265,7 @@ static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
tb_url_input( gw, NK_DEL );
}
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_open_file(short item, short title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
@@ -145,7 +282,7 @@ static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_close_win(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -153,7 +290,7 @@ static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
gui_window_destroy( input_window );
}
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_save_page(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
static bool init = true;
@@ -181,49 +318,49 @@ static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_quit(short item, short title, void *data)
{
short buff[8];
memset( &buff, 0, sizeof(short)*8 );
LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
+ netsurf_quit = true;
}
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_cut(short item, short title, void *data)
{
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
}
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_copy(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
}
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_paste(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
browser_window_key_press( input_window->browser->bw, KEY_PASTE);
}
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_find(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window != NULL )
open_browser_search( input_window );
}
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_choices(short item, short title, void *data)
{
static WINDOW * settings_dlg = NULL;
LOG(("%s", __FUNCTION__));
settings_dlg = open_settings();
}
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -232,7 +369,7 @@ static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_reload(short item, short title, void *data)
{
if( input_window == NULL)
return;
@@ -240,7 +377,7 @@ static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
LOG(("%s", __FUNCTION__));
}
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_toolbars(short item, short title, void *data)
{
static int state = 0;
LOG(("%s", __FUNCTION__));
@@ -250,7 +387,7 @@ static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
}
}
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_savewin(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
@@ -269,12 +406,13 @@ static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
}
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_debug_render(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
html_redraw_debug = !html_redraw_debug;
if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ if ( input_window->browser != NULL
+ && input_window->browser->bw != NULL) {
LGRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
@@ -285,19 +423,21 @@ static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *da
}
}
-static void __CDECL menu_fg_images(WINDOW *win, int item, int 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, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
}
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+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, (nsoption_bool(background_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
}
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_back(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -305,7 +445,7 @@ static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
tb_back_click( input_window );
}
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_forward(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -313,7 +453,7 @@ static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
tb_forward_click( input_window );
}
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_home(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
@@ -321,191 +461,169 @@ static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
tb_home_click( input_window );
}
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_lhistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
}
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_ghistory(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
global_history_open();
}
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- if( input_window ) {
+ if (input_window) {
if( input_window->browser->bw->current_content != NULL ){
atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
NULL
);
}
}
}
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_bookmarks(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
hotlist_open();
}
-static void __CDECL menu_vlog(WINDOW *win, int item, int 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 );
}
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+static void __CDECL menu_help_content(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
-{
- int i = 0;
- LOG((""));
- netsurf_quit = true;
}
-
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
-{
- struct gui_window * gw = input_window;
- static bool prev_url = false;
- static short prev_x=0;
- static short prev_y=0;
- bool within = false;
- LGRECT urlbox, bwbox, sbbox;
- int nx, ny;
-
- if( gw == NULL)
- return;
+/*
+ Public deskmenu interface:
+*/
- if( prev_x == evnt.mx && prev_y == evnt.my ){
- return;
+
+/**
+* Setup & display an desktop menu.
+*/
+
+void deskmenu_init(void)
+{
+ int i;
+
+ h_gem_menu = get_tree(MAINMENU);
+
+ // TODO: remove that call somehow...
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ /* Update menu string if not null: */
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
+ menu_evnt_tbl[i].menustr);
+ }
+ i++;
}
+ deskmenu_update();
- short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ menu_bar(h_gem_menu, 100);
+ menu_bar(h_gem_menu, 1);
- // The window found at x,y is an gui_window
- // and it's the input window.
-
- browser_get_rect( gw, BR_CONTENT, &bwbox );
-
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
- within = true;
- browser_window_mouse_track(
- input_window->browser->bw,
- 0,
- evnt.mx - bwbox.g_x + gw->browser->scroll.current.x,
- evnt.my - bwbox.g_y + gw->browser->scroll.current.y
- );
- }
+ // TODO: remove windom dependency.
+ EvntAttach(NULL, MN_SELECTED, evnt_menu);
+}
- if( gw->root->toolbar && within == false ) {
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
- (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
- gem_set_cursor( &gem_cursors.ibeam );
- prev_url = true;
- } else {
- if( prev_url ) {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
- }
- }
- }
- } else {
- gem_set_cursor( &gem_cursors.arrow );
- prev_url = false;
+/**
+* Uninstall the desktop menu
+*/
+void deskmenu_destroy(void)
+{
+ int i;
+
+ /* Remove menu from desktop: */
+ menu_bar(h_gem_menu, 0);
+
+ /* Free modified menu titles: */
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
}
+}
- prev_x = evnt.mx;
- prev_y = evnt.my;
-}
-
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
-{
- char sascii;
- long kstate = 0;
- long kcode = 0;
- unsigned short nkc = 0;
- unsigned short nks = 0;
-
- int i=0;
- bool done = false;
- struct gui_window * gw = input_window;
- struct gui_window * gw_tmp;
- if( gw == NULL )
- return;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
- nkc= gem_to_norm( (short)kstate, (short)kcode );
- nks = (nkc & 0xFF00);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
- /* make sure we report for the root window and report...: */
- done = tb_url_input( gw, 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( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
- break;
- } else {
- gw_tmp = gw_tmp->next;
+/**
+* Return the deskmenu AES OBJECT tree
+*/
+OBJECT * deskmenu_get_obj_tree(void)
+{
+ return(h_gem_menu);
+}
+
+/**
+* Handle an menu item event
+*/
+int deskmenu_dispatch_item(short title, short item)
+{
+ int i=0;
+ int retval = 0;
+ OBJECT * menu_root = deskmenu_get_obj_tree();
+
+ menu_tnormal(menu_root, item, 1);
+ menu_tnormal(menu_root, title, 1);
+ menu_bar(menu_root, 1);
+
+ // legacy code, is this sensible?:
+ /*
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ */
+
+
+ while (menu_evnt_tbl[i].rid != -1) {
+ if (menu_evnt_tbl[i].rid == item) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func(item, title, NULL);
}
+ break;
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ i++;
+ }
+
+ return(retval);
+}
+
+/**
+* Handle an keypress (check for accelerator)
+*/
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc)
+{
+ char sascii;
+ bool done = 0;
+ int i = 0;
+
+ sascii = keybd2ascii(kcode, K_LSHIFT);
+
+ /* Iterate through the menu function table: */
while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ if( kstate == menu_evnt_tbl[i].accel.mod
+ && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
@@ -513,165 +631,30 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
/* the accel code hides in the keycode: */
if( menu_evnt_tbl[i].accel.keycode != 0) {
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
+ kstate == menu_evnt_tbl[i].accel.mod) {
+ deskmenu_dispatch_item(menu_evnt_tbl[i].title,
+ menu_evnt_tbl[i].rid);
done = true;
break;
}
}
}
i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
+ }
+ return((done==true) ? 1 : 0);
+}
+/**
+* Refresh the desk menu, reflecting netsurf current state.
*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
+void deskmenu_update(void)
{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
+ OBJECT * gem_menu = deskmenu_get_obj_tree();
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-
-/* Bind global and menu events to event handler functions, create accelerators */
-void bind_global_events( void )
-{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
- memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
- EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
- EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+ menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
+ (nsoption_bool(foreground_images)) ? 1 : 0);
+ menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
-}
-
-void unbind_global_events( void )
-{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
new file mode 100644
index 0000000..6ab00dc
--- /dev/null
+++ b/atari/deskmenu.h
@@ -0,0 +1,12 @@
+#ifndef DESKMENU_H_INCLUDED
+#define DESKMENU_H_INCLUDED
+
+void deskmenu_init(void);
+void deskmenu_destroy(void);
+int deskmenu_dispatch_item(short title, short item);
+int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
+ unsigned short nkc);
+OBJECT * deskmenu_get_obj_tree(void);
+void deskmenu_update( void );
+
+#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 3b15af8..e3a93a0 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,379 +26,31 @@
#include <windom.h>
#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/hotlist.h"
-#include "desktop/save_complete.h"
-#include "desktop/options.h"
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/misc.h"
#include "atari/global_evnt.h"
-#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/search.h"
-#include "atari/findfile.h"
-#include "atari/settings.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
extern struct gui_window *input_window;
-extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
-extern bool html_redraw_debug;
-
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-extern char options[PATH_MAX];
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
-static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-
-/* Menu event handlers: */
-static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- global_evnt_apterm( NULL, buff );
-}
-
-static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
- LGRECT rect;
- 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 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window ) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-static struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, NULL,{0,0,0}, NULL }
-};
-
-void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
+void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
{
int i = 0;
LOG((""));
@@ -406,7 +58,7 @@ void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
}
-static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
+static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -416,23 +68,23 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if( gw == NULL)
+ if (gw == NULL)
return;
- if( prev_x == evnt.mx && prev_y == evnt.my ){
+ if (prev_x == evnt.mx && prev_y == evnt.my) {
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if( input_window->root->handle->handle == ghandle ){
+ if (input_window->root->handle->handle == ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -442,7 +94,7 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
);
}
- if( gw->root->toolbar && within == false ) {
+ if (gw->root->toolbar && within == false) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -466,7 +118,6 @@ static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
- char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -500,178 +151,23 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
- }
- }
- i++;
- }
-}
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- char * str = ObjcString( h_gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
-
-
- while( i>2 ){
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
}
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-
-void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
-{
- int title = buff[ 3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
- MenuTnormal( NULL, title, 1);
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- while( menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].rid == buff[4] ) {
- menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
- break;
- }
- i++;
- }
-}
-
-void main_menu_update( void )
-{
- MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+ if(!done)
+ deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
}
-
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
- int i, len;
- int maxlen[NUM_MENU_TITLES]={0};
- char * m, *u, *t;
- char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
- EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- if( menu_evnt_tbl[i].menustr != NULL ){
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
}
void unbind_global_events( void )
{
- int i;
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
+
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 1e13264..76e73fc 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,6 +18,8 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
+
+#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -32,31 +34,14 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
+struct s_evnt_data evnt_data;
/*
- Global & Menu event handlers
+ Global event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
-void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index c2158e0..fdcb752 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,7 +73,8 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
+#include "atari/search.h"
+#include "atari/deskmenu.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -82,9 +83,8 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-OBJECT * h_gem_menu;
-OBJECT **rsc_trindex;
-short rsc_ntree;
+//OBJECT **rsc_trindex;
+//short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,6 +789,8 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
+
+ unbind_global_events();
while( gw ) {
tmp = gw->next;
@@ -802,10 +804,8 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- RsrcXtype( 0, rsc_trindex, rsc_ntree);
- unbind_global_events();
- MenuBar( h_gem_menu , 0 );
+
+ deskmenu_destroy();
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,7 +885,8 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form,
+ MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -928,16 +929,18 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ if (rsrc_load(buf)==0) {
+ die("Uable to open GEM Resource file!");
+ }
+ //h_gem_rsrc = RsrcXload( (char*) &buf );
- if( !h_gem_rsrc )
- die("Uable to open GEM Resource file!");
- rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ //if( !h_gem_rsrc )
+ // die("Uable to open GEM Resource file!");
+ //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
- RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -981,19 +984,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
+ plot_init(nsoption_charp(atari_font_driver));
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- MenuBar( h_gem_menu , 1 );
- bind_global_events();
+ deskmenu_init();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ }
+ bind_global_events();
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index 8b745fd..e5b0dc1 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,7 +273,8 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ rsrc_gaddr(R_TREE, idx, &tree);
+ //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 8143cdc..25e0c0f 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,7 +31,8 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-#include "atari/global_evnt.h"
+//#include "atari/global_evnt.h"
+#include "atari/deskmenu.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -232,7 +233,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- main_menu_update();
+ deskmenu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
--
NetSurf Browser
10 years, 6 months
netsurf: branch chris/frame-scroll updated. fe9252bd5eaa70c0b98203049d9bf38b20f93ca6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fe9252bd5eaa70c0b9820...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fe9252bd5eaa70c0b982030...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fe9252bd5eaa70c0b98203049...
The branch, chris/frame-scroll has been updated
via fe9252bd5eaa70c0b98203049d9bf38b20f93ca6 (commit)
from 2bea506f837c9a1e9c12c448eb206e067770819c (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/fe9252bd5eaa70c0b98...
commit fe9252bd5eaa70c0b98203049d9bf38b20f93ca6
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
First attempt at optimising the redraw of frame scrolls. some of these calculations are wrong.
diff --git a/amiga/gui.c b/amiga/gui.c
index 2933792..d072993 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1036,6 +1036,36 @@ void ami_update_quals(struct gui_window_2 *gwin)
}
}
+bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
+{
+ ULONG xs, ys;
+ int ns_x = *x;
+ int ns_y = *y;
+ struct IBox *bbox;
+
+ GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox);
+
+ ns_x *= gwin->bw->scale;
+ ns_y *= gwin->bw->scale;
+
+ if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
+ return false;
+
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
+ ami_get_vscroll_pos(gwin, (ULONG *)&ys);
+
+ ns_x += xs;
+ ns_y += ys;
+
+ ns_x += bbox->Left;
+ ns_y += bbox->Top;
+
+ *x = ns_x;
+ *y = ns_y;
+
+ return true;
+}
+
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
int mouse_x, int mouse_y)
{
@@ -3565,6 +3595,37 @@ void ami_do_redraw(struct gui_window_2 *g)
g->new_content = false;
}
+bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, int y)
+{
+ struct IBox *bbox;
+ struct gui_window_2 *gwin = g->shared;
+ int src_x = rect->x0;
+ int src_y = rect->y0;
+ int dest_x = x;
+ int dest_y = y;
+ int src_x1 = rect->x1;
+ int src_y1 = rect->y1;
+printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+ if(ami_ns_to_screen_coords(gwin, &src_x, &src_y) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
+printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+
+ BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
+ BLITA_Source, gwin->win->RPort,
+ BLITA_SrcX, src_x,
+ BLITA_SrcY, src_y,
+ BLITA_DestType, BLITT_RASTPORT,
+ BLITA_Dest, gwin->win->RPort,
+ BLITA_DestX, dest_x,
+ BLITA_DestY, dest_y,
+ BLITA_Width, src_x1 - src_x,
+ BLITA_Height, src_y1 - src_y,
+ TAG_DONE);
+
+ return true;
+}
+
void ami_refresh_window(struct gui_window_2 *gwin)
{
/* simplerefresh only */
diff --git a/desktop/browser.c b/desktop/browser.c
index 8948460..0ecb0ac 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1947,6 +1947,38 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect)
}
+/* exported interface, documented in browser.h */
+void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x, int y)
+{
+ int pos_x;
+ int pos_y;
+ struct browser_window *top;
+
+ assert(bw);
+
+ if (bw->window != NULL) {
+ /* Front end window */
+ if(gui_window_copy_box(bw->window, rect, x, y) == false) {
+ gui_window_update_box(bw->window, rect);
+ }
+ } else {
+ /* Core managed browser window */
+ browser_window_get_position(bw, true, &pos_x, &pos_y);
+
+ top = browser_window_get_root(bw);
+
+ rect->x0 += pos_x / bw->scale;
+ rect->y0 += pos_y / bw->scale;
+ rect->x1 += pos_x / bw->scale;
+ rect->y1 += pos_y / bw->scale;
+
+ if(gui_window_copy_box(top->window, rect, x + pos_x, y + pos_y) == false) {
+ gui_window_update_box(top->window, rect);
+ }
+ }
+}
+
+
/**
* Stop all fetching activity in a browser window.
*
diff --git a/desktop/browser.h b/desktop/browser.h
index f3c68fa..b0965e1 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -95,6 +95,17 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
float browser_window_get_scale(struct browser_window *bw);
/**
+ * Copy an area of the browser window to the given x,y co-ordinates.
+ * Source and destination may overlap.
+ *
+ * \param bw browser window
+ * \param rect area to copy
+ * \param x x-coordinate of destination to copy to
+ * \param y y-coordinate of destination to copy to
+ */
+void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x, int y);
+
+/**
* Get access to any content, link URLs and objects (images) currently
* at the given (x, y) coordinates.
*
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 91372ac..d008d88 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -110,6 +110,10 @@ struct browser_window {
struct scrollbar *scroll_x; /**< Horizontal scroll. */
struct scrollbar *scroll_y; /**< Vertical scroll. */
+
+ /** previous scroll offsets */
+ int prev_scroll_x;
+ int prev_scroll_y;
/** scale of window contents */
float scale;
diff --git a/desktop/frames.c b/desktop/frames.c
index cc2cabf..4de33cb 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -64,13 +64,49 @@ void browser_window_scroll_callback(void *client_data,
html_redraw_a_box(bw->parent->current_content, bw->box);
} else {
struct rect rect;
+ struct rect copyrect;
+ int dest_x = 0;
+ int dest_y = 0;
+ int cur_x = scrollbar_get_offset(bw->scroll_x);
+ int cur_y = scrollbar_get_offset(bw->scroll_y);
+
+ if(cur_x > bw->prev_scroll_x) {
+ copyrect.x0 = cur_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = bw->prev_scroll_x;
+
+ rect.x0 = copyrect.x0;
+ rect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ } else {
+ copyrect.x0 = bw->prev_scroll_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
+ dest_x = cur_x;
+
+ rect.x0 = cur_x;
+ rect.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
+ }
- rect.x0 = scrollbar_get_offset(bw->scroll_x);
- rect.y0 = scrollbar_get_offset(bw->scroll_y);
- rect.x1 = rect.x0 + bw->width;
- rect.y1 = rect.y0 + bw->height;
+ if(cur_y > bw->prev_scroll_y) {
+ copyrect.y0 = cur_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = bw->prev_scroll_y;
+
+ rect.y0 = copyrect.y0;
+ rect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ } else {
+ copyrect.y0 = bw->prev_scroll_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
+ dest_y = cur_y;
+
+ rect.y0 = cur_y;
+ rect.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
+ }
+ browser_window_copy_box(bw, ©rect, dest_x, dest_y);
browser_window_update_box(bw, &rect);
+
+ bw->prev_scroll_x = scrollbar_get_offset(bw->scroll_x);
+ bw->prev_scroll_y = scrollbar_get_offset(bw->scroll_y);
}
break;
case SCROLLBAR_MSG_SCROLL_START:
diff --git a/desktop/gui.h b/desktop/gui.h
index 48684c3..5518485 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -79,6 +79,19 @@ void gui_window_set_title(struct gui_window *g, const char *title);
void gui_window_redraw_window(struct gui_window *g);
void gui_window_update_box(struct gui_window *g,
const struct rect *rect);
+
+/**
+ * Copy an area of the displayed gui_window to the co-ordinates
+ * specified by x,y. NB: source and destination may overlap.
+ *
+ * \param g The window to perform the copy on.
+ * \param rect The rectangle to copy.
+ * \param x The X co-ordinate to copy to.
+ * \param y The Y co-ordinate to copy to.
+ * \return true if the region could be copied, false otherwise.
+ */
+bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, int y);
+
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
desktop/browser.c | 32 +++++++++++++++++++++++
desktop/browser.h | 11 ++++++++
desktop/browser_private.h | 4 +++
desktop/frames.c | 44 +++++++++++++++++++++++++++++---
desktop/gui.h | 13 +++++++++
6 files changed, 161 insertions(+), 4 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 2933792..d072993 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1036,6 +1036,36 @@ void ami_update_quals(struct gui_window_2 *gwin)
}
}
+bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
+{
+ ULONG xs, ys;
+ int ns_x = *x;
+ int ns_y = *y;
+ struct IBox *bbox;
+
+ GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox);
+
+ ns_x *= gwin->bw->scale;
+ ns_y *= gwin->bw->scale;
+
+ if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
+ return false;
+
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
+ ami_get_vscroll_pos(gwin, (ULONG *)&ys);
+
+ ns_x += xs;
+ ns_y += ys;
+
+ ns_x += bbox->Left;
+ ns_y += bbox->Top;
+
+ *x = ns_x;
+ *y = ns_y;
+
+ return true;
+}
+
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
int mouse_x, int mouse_y)
{
@@ -3565,6 +3595,37 @@ void ami_do_redraw(struct gui_window_2 *g)
g->new_content = false;
}
+bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, int y)
+{
+ struct IBox *bbox;
+ struct gui_window_2 *gwin = g->shared;
+ int src_x = rect->x0;
+ int src_y = rect->y0;
+ int dest_x = x;
+ int dest_y = y;
+ int src_x1 = rect->x1;
+ int src_y1 = rect->y1;
+printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+ if(ami_ns_to_screen_coords(gwin, &src_x, &src_y) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
+printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
+
+ BltBitMapTags(BLITA_SrcType, BLITT_RASTPORT,
+ BLITA_Source, gwin->win->RPort,
+ BLITA_SrcX, src_x,
+ BLITA_SrcY, src_y,
+ BLITA_DestType, BLITT_RASTPORT,
+ BLITA_Dest, gwin->win->RPort,
+ BLITA_DestX, dest_x,
+ BLITA_DestY, dest_y,
+ BLITA_Width, src_x1 - src_x,
+ BLITA_Height, src_y1 - src_y,
+ TAG_DONE);
+
+ return true;
+}
+
void ami_refresh_window(struct gui_window_2 *gwin)
{
/* simplerefresh only */
diff --git a/desktop/browser.c b/desktop/browser.c
index 8948460..0ecb0ac 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1947,6 +1947,38 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect)
}
+/* exported interface, documented in browser.h */
+void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x, int y)
+{
+ int pos_x;
+ int pos_y;
+ struct browser_window *top;
+
+ assert(bw);
+
+ if (bw->window != NULL) {
+ /* Front end window */
+ if(gui_window_copy_box(bw->window, rect, x, y) == false) {
+ gui_window_update_box(bw->window, rect);
+ }
+ } else {
+ /* Core managed browser window */
+ browser_window_get_position(bw, true, &pos_x, &pos_y);
+
+ top = browser_window_get_root(bw);
+
+ rect->x0 += pos_x / bw->scale;
+ rect->y0 += pos_y / bw->scale;
+ rect->x1 += pos_x / bw->scale;
+ rect->y1 += pos_y / bw->scale;
+
+ if(gui_window_copy_box(top->window, rect, x + pos_x, y + pos_y) == false) {
+ gui_window_update_box(top->window, rect);
+ }
+ }
+}
+
+
/**
* Stop all fetching activity in a browser window.
*
diff --git a/desktop/browser.h b/desktop/browser.h
index f3c68fa..b0965e1 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -95,6 +95,17 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
float browser_window_get_scale(struct browser_window *bw);
/**
+ * Copy an area of the browser window to the given x,y co-ordinates.
+ * Source and destination may overlap.
+ *
+ * \param bw browser window
+ * \param rect area to copy
+ * \param x x-coordinate of destination to copy to
+ * \param y y-coordinate of destination to copy to
+ */
+void browser_window_copy_box(struct browser_window *bw, struct rect *rect, int x, int y);
+
+/**
* Get access to any content, link URLs and objects (images) currently
* at the given (x, y) coordinates.
*
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 91372ac..d008d88 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -110,6 +110,10 @@ struct browser_window {
struct scrollbar *scroll_x; /**< Horizontal scroll. */
struct scrollbar *scroll_y; /**< Vertical scroll. */
+
+ /** previous scroll offsets */
+ int prev_scroll_x;
+ int prev_scroll_y;
/** scale of window contents */
float scale;
diff --git a/desktop/frames.c b/desktop/frames.c
index cc2cabf..4de33cb 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -64,13 +64,49 @@ void browser_window_scroll_callback(void *client_data,
html_redraw_a_box(bw->parent->current_content, bw->box);
} else {
struct rect rect;
+ struct rect copyrect;
+ int dest_x = 0;
+ int dest_y = 0;
+ int cur_x = scrollbar_get_offset(bw->scroll_x);
+ int cur_y = scrollbar_get_offset(bw->scroll_y);
+
+ if(cur_x > bw->prev_scroll_x) {
+ copyrect.x0 = cur_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ dest_x = bw->prev_scroll_x;
+
+ rect.x0 = copyrect.x0;
+ rect.x1 = copyrect.x0 + bw->width - (cur_x - bw->prev_scroll_x);
+ } else {
+ copyrect.x0 = bw->prev_scroll_x;
+ copyrect.x1 = copyrect.x0 + bw->width - (bw->prev_scroll_x - cur_x);
+ dest_x = cur_x;
+
+ rect.x0 = cur_x;
+ rect.x1 = cur_x + bw->width - (bw->prev_scroll_x - cur_x);
+ }
- rect.x0 = scrollbar_get_offset(bw->scroll_x);
- rect.y0 = scrollbar_get_offset(bw->scroll_y);
- rect.x1 = rect.x0 + bw->width;
- rect.y1 = rect.y0 + bw->height;
+ if(cur_y > bw->prev_scroll_y) {
+ copyrect.y0 = cur_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ dest_y = bw->prev_scroll_y;
+
+ rect.y0 = copyrect.y0;
+ rect.y1 = copyrect.y0 + bw->height - (cur_y - bw->prev_scroll_y);
+ } else {
+ copyrect.y0 = bw->prev_scroll_y;
+ copyrect.y1 = copyrect.y0 + bw->height - (bw->prev_scroll_y - cur_y);
+ dest_y = cur_y;
+
+ rect.y0 = cur_y;
+ rect.y1 = cur_y + bw->height - (bw->prev_scroll_y - cur_y);
+ }
+ browser_window_copy_box(bw, ©rect, dest_x, dest_y);
browser_window_update_box(bw, &rect);
+
+ bw->prev_scroll_x = scrollbar_get_offset(bw->scroll_x);
+ bw->prev_scroll_y = scrollbar_get_offset(bw->scroll_y);
}
break;
case SCROLLBAR_MSG_SCROLL_START:
diff --git a/desktop/gui.h b/desktop/gui.h
index 48684c3..5518485 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -79,6 +79,19 @@ void gui_window_set_title(struct gui_window *g, const char *title);
void gui_window_redraw_window(struct gui_window *g);
void gui_window_update_box(struct gui_window *g,
const struct rect *rect);
+
+/**
+ * Copy an area of the displayed gui_window to the co-ordinates
+ * specified by x,y. NB: source and destination may overlap.
+ *
+ * \param g The window to perform the copy on.
+ * \param rect The rectangle to copy.
+ * \param x The X co-ordinate to copy to.
+ * \param y The Y co-ordinate to copy to.
+ * \return true if the region could be copied, false otherwise.
+ */
+bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, int y);
+
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. 2bea506f837c9a1e9c12c448eb206e067770819c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2bea506f837c9a1e9c12c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2bea506f837c9a1e9c12c44...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2bea506f837c9a1e9c12c448e...
The branch, master has been updated
via 2bea506f837c9a1e9c12c448eb206e067770819c (commit)
from 9acba6cbcc6dc807b93ad34b8e8b4e430ee7d5b0 (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/2bea506f837c9a1e9c1...
commit 2bea506f837c9a1e9c12c448eb206e067770819c
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add Node interface binding just to get the prototype
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index eff2052..2a33565 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -20,6 +20,7 @@ JSAPI_BINDING_location := javascript/jsapi/location.bnd
JSAPI_BINDING_htmlcollection := javascript/jsapi/htmlcollection.bnd
JSAPI_BINDING_nodelist := javascript/jsapi/nodelist.bnd
JSAPI_BINDING_text := javascript/jsapi/text.bnd
+JSAPI_BINDING_node := javascript/jsapi/node.bnd
# 1: input file
# 2: output file
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index c6a460c..6400217 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -143,4 +143,9 @@ JSObject *jsapi_new_Text(JSContext *cx,
dom_text *node,
struct html_content *htmlc);
+JSObject *jsapi_InitClass_Node(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Node(JSContext *cx,
+ JSObject *prototype,
+ JSObject *parent);
+
#endif
diff --git a/javascript/jsapi/node.bnd b/javascript/jsapi/node.bnd
new file mode 100644
index 0000000..bcf0ef7
--- /dev/null
+++ b/javascript/jsapi/node.bnd
@@ -0,0 +1,34 @@
+/* Binding to generate Node interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+webidlfile "dom.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding node {
+ type js_libdom; /* the binding type */
+
+ interface Node; /* Web IDL interface to generate */
+}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 45541fa..767b94f 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -135,6 +135,11 @@ api init %{
return NULL;
}
+ user_proto = jsapi_InitClass_Node(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
-----------------------------------------------------------------------
Summary of changes:
Makefile.sources.javascript | 1 +
javascript/jsapi/binding.h | 5 +++++
javascript/jsapi/{text.bnd => node.bnd} | 21 +++++----------------
javascript/jsapi/window.bnd | 5 +++++
4 files changed, 16 insertions(+), 16 deletions(-)
copy javascript/jsapi/{text.bnd => node.bnd} (68%)
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index eff2052..2a33565 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -20,6 +20,7 @@ JSAPI_BINDING_location := javascript/jsapi/location.bnd
JSAPI_BINDING_htmlcollection := javascript/jsapi/htmlcollection.bnd
JSAPI_BINDING_nodelist := javascript/jsapi/nodelist.bnd
JSAPI_BINDING_text := javascript/jsapi/text.bnd
+JSAPI_BINDING_node := javascript/jsapi/node.bnd
# 1: input file
# 2: output file
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index c6a460c..6400217 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -143,4 +143,9 @@ JSObject *jsapi_new_Text(JSContext *cx,
dom_text *node,
struct html_content *htmlc);
+JSObject *jsapi_InitClass_Node(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Node(JSContext *cx,
+ JSObject *prototype,
+ JSObject *parent);
+
#endif
diff --git a/javascript/jsapi/text.bnd b/javascript/jsapi/node.bnd
similarity index 68%
copy from javascript/jsapi/text.bnd
copy to javascript/jsapi/node.bnd
index 42791d0..bcf0ef7 100644
--- a/javascript/jsapi/text.bnd
+++ b/javascript/jsapi/node.bnd
@@ -1,4 +1,4 @@
-/* Binding to generate Text interface
+/* Binding to generate Node interface
*
* Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*
@@ -8,9 +8,7 @@
* http://www.opensource.org/licenses/mit-license
*/
-#include "dom.bnd"
-
-webidlfile "html.idl";
+webidlfile "dom.idl";
hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
@@ -20,7 +18,7 @@ hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -29,17 +27,8 @@ preamble %{
%}
-binding text {
+binding node {
type js_libdom; /* the binding type */
- interface Text; /* Web IDL interface to generate */
-
- private "dom_text *" node;
- private "struct html_content *" htmlc;
+ interface Node; /* Web IDL interface to generate */
}
-
-api finalise %{
- if (private != NULL) {
- dom_node_unref(private->node);
- }
-%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 45541fa..767b94f 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -135,6 +135,11 @@ api init %{
return NULL;
}
+ user_proto = jsapi_InitClass_Node(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
--
NetSurf Browser
10 years, 6 months