diff options
Diffstat (limited to '26')
-rw-r--r-- | 26/index.md | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/26/index.md b/26/index.md new file mode 100644 index 0000000..4f7c072 --- /dev/null +++ b/26/index.md @@ -0,0 +1,170 @@ +Title: HTML5 "autofocus" tag for input element in dillo +Author: rodarima +Created: Thu, 21 Dec 2023 11:43:16 +0000 +State: open + +We may want to integrate a patch to support autofocus from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033320 : + +> The attached patch adds support for HTML5's autofocus tag to Dillo: this allows to automatically focus certain input fields as soon as the page with the form loads. We're using this to implement a barcode scanner on a raspberry pi 3, so that the browser is immediately ready to scan, without a need to touch into the input field first. + +Here is the diff: + +```diff +diff -ur dillo-3.0.5.orig/dw/fltkplatform.cc dillo-3.0.5/dw/fltkplatform.cc +--- dillo-3.0.5.orig/dw/fltkplatform.cc 2015-06-10 23:48:53.000000000 +0200 ++++ dillo-3.0.5/dw/fltkplatform.cc 2023-03-18 12:41:21.910464773 +0100 +@@ -370,6 +370,10 @@ + { + } + ++void FltkView::focusFltkWidget (Fl_Widget *widget) ++{ ++} ++ + void FltkView::allocateFltkWidget (Fl_Widget *widget, + core::Allocation *allocation) + { +diff -ur dillo-3.0.5.orig/dw/fltkplatform.hh dillo-3.0.5/dw/fltkplatform.hh +--- dillo-3.0.5.orig/dw/fltkplatform.hh 2015-06-30 16:06:08.000000000 +0200 ++++ dillo-3.0.5/dw/fltkplatform.hh 2023-03-18 12:46:12.542094720 +0100 +@@ -86,6 +86,7 @@ + virtual void allocateFltkWidget (Fl_Widget *widget, + core::Allocation *allocation); + virtual void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area); ++ virtual void focusFltkWidget (Fl_Widget *widget); + }; + + +diff -ur dillo-3.0.5.orig/dw/fltkui.cc dillo-3.0.5/dw/fltkui.cc +--- dillo-3.0.5.orig/dw/fltkui.cc 2015-06-30 16:06:08.000000000 +0200 ++++ dillo-3.0.5/dw/fltkui.cc 2023-03-18 12:33:36.914259944 +0100 +@@ -460,6 +460,11 @@ + this->view = NULL; + } + ++void FltkResource::focus () ++{ ++ view->focusFltkWidget (widget); ++} ++ + void FltkResource::sizeAllocate (core::Allocation *allocation) + { + this->allocation = *allocation; +@@ -574,6 +579,11 @@ + FltkResource::setEnabled (enabled); + } + ++template <class I> void FltkSpecificResource<I>::focus () ++{ ++ FltkResource::focus (); ++} ++ + // ---------------------------------------------------------------------- + + class EnterButton : public Fl_Button { +diff -ur dillo-3.0.5.orig/dw/fltkui.hh dillo-3.0.5/dw/fltkui.hh +--- dillo-3.0.5.orig/dw/fltkui.hh 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/dw/fltkui.hh 2023-03-18 12:38:41.898264236 +0100 +@@ -217,6 +217,8 @@ + + bool isEnabled (); + void setEnabled (bool enabled); ++ ++ void focus (); + }; + + +@@ -232,6 +234,8 @@ + + bool isEnabled (); + void setEnabled (bool enabled); ++ ++ void focus (); + }; + + +diff -ur dillo-3.0.5.orig/dw/fltkviewbase.cc dillo-3.0.5/dw/fltkviewbase.cc +--- dillo-3.0.5.orig/dw/fltkviewbase.cc 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/dw/fltkviewbase.cc 2023-03-18 12:18:12.234001790 +0100 +@@ -711,6 +711,12 @@ + add (widget); + } + ++void FltkWidgetView::focusFltkWidget (Fl_Widget *widget) ++{ ++ focused_child=widget; ++ widget->take_focus(); ++} ++ + void FltkWidgetView::removeFltkWidget (Fl_Widget *widget) + { + remove (widget); +diff -ur dillo-3.0.5.orig/dw/fltkviewbase.hh dillo-3.0.5/dw/fltkviewbase.hh +--- dillo-3.0.5.orig/dw/fltkviewbase.hh 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/dw/fltkviewbase.hh 2023-03-18 12:39:07.514936690 +0100 +@@ -132,6 +132,7 @@ + void allocateFltkWidget (Fl_Widget *widget, + core::Allocation *allocation); + void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area); ++ void focusFltkWidget (Fl_Widget *widget); + }; + + } // namespace fltk +diff -ur dillo-3.0.5.orig/dw/ui.cc dillo-3.0.5/dw/ui.cc +--- dillo-3.0.5.orig/dw/ui.cc 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/dw/ui.cc 2023-03-18 12:41:55.403344022 +0100 +@@ -223,6 +223,10 @@ + { + } + ++void Resource::focus () ++{ ++} ++ + void Resource::emitEnter () + { + activateEmitter.emitEnter(this); +diff -ur dillo-3.0.5.orig/dw/ui.hh dillo-3.0.5/dw/ui.hh +--- dillo-3.0.5.orig/dw/ui.hh 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/dw/ui.hh 2023-03-18 12:33:20.465828321 +0100 +@@ -347,6 +347,8 @@ + virtual bool isEnabled () = 0; + virtual void setEnabled (bool enabled) = 0; + ++ virtual void focus () = 0; ++ + inline void connectActivate (ActivateReceiver *receiver) { + activateEmitter.connectActivate (receiver); } + inline void connectClicked (ClickedReceiver *receiver) { +diff -ur dillo-3.0.5.orig/src/form.cc dillo-3.0.5/src/form.cc +--- dillo-3.0.5.orig/src/form.cc 2015-06-30 16:06:09.000000000 +0200 ++++ dillo-3.0.5/src/form.cc 2023-03-18 12:40:04.192424547 +0100 +@@ -431,7 +431,7 @@ + DilloHtmlInputType inp_type; + Resource *resource = NULL; + Embed *embed = NULL; +- char *value, *name, *type, *init_str, *placeholder = NULL; ++ char *value, *name, *type, *init_str, *placeholder = NULL, *autofocus; + const char *attrbuf, *label; + bool init_val = false; + ResourceFactory *factory; +@@ -451,6 +451,7 @@ + value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL); + name = a_Html_get_attr_wdef(html, tag, tagsize, "name", NULL); + type = a_Html_get_attr_wdef(html, tag, tagsize, "type", ""); ++ autofocus = a_Html_get_attr_wdef(html, tag, tagsize, "autofocus", NULL); + + init_str = NULL; + inp_type = DILLO_HTML_INPUT_UNKNOWN; +@@ -541,6 +542,9 @@ + if (resource) + embed = new Embed (resource); + ++ if (resource && autofocus) ++ resource->focus(); ++ + if (inp_type != DILLO_HTML_INPUT_UNKNOWN) { + Html_add_input(html, inp_type, embed, name, + (init_str) ? init_str : "", init_val); + +```
\ No newline at end of file |