[PATCH 0 of 3] tweaking the dillo ui for embedded devices
Hey folks :) I've got a new toy (the Neo FreeRunner) and dillo2 runs quite nicely on that little device, but there are some problems: * there is no way to create bookmarks Adressed in the second patch which adds an add bookmark button to the main toolbar. * the scrollbars are unusable without a stylus A more natural way of scrolling on embedded devices with touchscreens is finger scrolling. A proof of concept is attached as the third patch. Acceleration would be a nice feature for big pages. * buttons on dialogs are too small Proposed solution: There is code for creating dialogs in src/dialog.cc for a_Dialog_choice5 that creates the dialog window without relying on fltks choice(). We could generalize that and use it for all dialogs. This way we could resize the buttons and stack them vertically on top of each other. What do you think? Justus ps: the first patch is a small cleanup patch. all three patches should apply cleanly independently in spite of being a patch set)
# HG changeset patch # User Justus Winter <justus.winter@informatik.uni-hamburg.de> # Date 1236616924 -3600 # Node ID 46c62dde8967ae87914d0fbcc0ba7df61853750c # Parent 78c0fa261c84df53da7f69cc8f33dc85fa152f9c Easy panning with the left mouse button This is particulary useful for embedded devices with touch screens. In order to select text you have to double click and drag the pointer. Note that this functionality is disabled by default and can be enabled by the easy_panning directive in the configuration file with the exception of the selection behavior which is located in dw/selection.cc and lacks a reference to the prefs struct by design (dw is a toolkit and frontend agnostic). I think that dw needs an interface to tweak it's behaviour ie dw_config(DW_DOUBLECLICK_TO_SELECT, true). Any ideas? diff -r 78c0fa261c84 -r 46c62dde8967 dillorc --- a/dillorc Mon Mar 09 17:21:32 2009 +0100 +++ b/dillorc Mon Mar 09 17:42:04 2009 +0100 @@ -223,6 +223,8 @@ # (Such as "TAB character inside <PRE>"). #show_extra_warnings=NO +# Finger panning for embedded devices +#easy_panning=NO # ----------------------------------------------------------------------- # dillorc ends here. diff -r 78c0fa261c84 -r 46c62dde8967 dw/fltkviewport.cc --- a/dw/fltkviewport.cc Mon Mar 09 17:21:32 2009 +0100 +++ b/dw/fltkviewport.cc Mon Mar 09 17:42:04 2009 +0100 @@ -1,3 +1,4 @@ + /* * Dillo Widget * @@ -59,6 +60,8 @@ gadgets = new container::typed::List <object::TypedPointer < ::fltk::Widget> > (true); + + easyPanning = 0; } FltkViewport::~FltkViewport () @@ -140,6 +143,18 @@ scroll (0, vscrollbar->value () - scrollY); } +void FltkViewport::setEasyPanning(int value) +{ + easyPanning = value; + if (easyPanning) { + hscrollbar->hide(); + vscrollbar->hide(); + } else { + hscrollbar->show(); + vscrollbar->show(); + } +} + void FltkViewport::vscrollbarCallback (Widget *vscrollbar, void *viewportPtr) { ((FltkViewport*)viewportPtr)->vscrollbarChanged (); @@ -235,8 +250,9 @@ case ::fltk::PUSH: take_focus(); - if (::fltk::event_button() == ::fltk::MiddleButton) { - /* pass event so that middle click can open link in new window */ + if (::fltk::event_button() == ::fltk::MiddleButton || + (easyPanning && ::fltk::event_button() == ::fltk::LeftButton)) { + /* pass event so that the click can interact with any widgets */ if (FltkWidgetView::handle (event) == 0) { dragScrolling = 1; dragX = ::fltk::event_x(); @@ -248,7 +264,8 @@ break; case ::fltk::DRAG: - if (::fltk::event_button() == ::fltk::MiddleButton) { + if (::fltk::event_button() == ::fltk::MiddleButton || + (easyPanning && ::fltk::event_button() == ::fltk::LeftButton)) { if (dragScrolling) { scroll(dragX - ::fltk::event_x(), dragY - ::fltk::event_y()); dragX = ::fltk::event_x(); @@ -263,7 +280,8 @@ break; case ::fltk::RELEASE: - if (::fltk::event_button() == ::fltk::MiddleButton) { + if (::fltk::event_button() == ::fltk::MiddleButton || + (easyPanning && ::fltk::event_button() == ::fltk::LeftButton)) { dragScrolling = 0; setCursor (core::style::CURSOR_DEFAULT); } diff -r 78c0fa261c84 -r 46c62dde8967 dw/fltkviewport.hh --- a/dw/fltkviewport.hh Mon Mar 09 17:21:32 2009 +0100 +++ b/dw/fltkviewport.hh Mon Mar 09 17:42:04 2009 +0100 @@ -21,7 +21,7 @@ int scrollX, scrollY; int scrollDX, scrollDY; - int dragScrolling, dragX, dragY; + int easyPanning, dragScrolling, dragX, dragY; ::fltk::Scrollbar *vscrollbar, *hscrollbar; @@ -68,6 +68,7 @@ void setGadgetOrientation (bool hscrollbarVisible, bool vscrollbarVisible, GadgetOrientation gadgetOrientation); void addGadget (::fltk::Widget *gadget); + void setEasyPanning(int value); }; } // namespace fltk diff -r 78c0fa261c84 -r 46c62dde8967 dw/selection.cc --- a/dw/selection.cc Mon Mar 09 17:21:32 2009 +0100 +++ b/dw/selection.cc Mon Mar 09 17:42:04 2009 +0100 @@ -141,7 +141,7 @@ } } else { // normal selection handling - if (event && event->button == 1) { + if (event && event->button == 1 && event->numPressed == 2) { highlight (false, 0); resetSelection (); diff -r 78c0fa261c84 -r 46c62dde8967 src/prefs.c --- a/src/prefs.c Mon Mar 09 17:21:32 2009 +0100 +++ b/src/prefs.c Mon Mar 09 17:42:04 2009 +0100 @@ -153,6 +153,7 @@ { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL }, { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 }, { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL }, + { "easy_panning", &prefs.easy_panning, PREFS_BOOL }, { "enterpress_forces_submit", &prefs.enterpress_forces_submit, PREFS_BOOL }, { "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL }, { "font_cursive", &prefs.font_cursive, PREFS_STRING }, diff -r 78c0fa261c84 -r 46c62dde8967 src/prefs.h --- a/src/prefs.h Mon Mar 09 17:21:32 2009 +0100 +++ b/src/prefs.h Mon Mar 09 17:42:04 2009 +0100 @@ -71,6 +71,7 @@ bool_t show_msg; bool_t show_extra_warnings; bool_t middle_click_drags_page; + bool_t easy_panning; }; /* Global Data */ diff -r 78c0fa261c84 -r 46c62dde8967 src/uicmd.cc --- a/src/uicmd.cc Mon Mar 09 17:21:32 2009 +0100 +++ b/src/uicmd.cc Mon Mar 09 17:42:04 2009 +0100 @@ -427,6 +427,10 @@ Layout *layout = new Layout (platform); FltkViewport *viewport = new FltkViewport (0, 0, 1, 1); + if (prefs.easy_panning) { + viewport->setEasyPanning (true); + fprintf(stderr, "easy panning enabled"); + } if (prefs.buffered_drawing == 1) viewport->setBufferedDrawing (true); else
# HG changeset patch # User Justus Winter <justus.winter@informatik.uni-hamburg.de> # Date 1236615471 -3600 # Node ID 9638f05098cf2687dbb863f47fd82461c5417403 # Parent cc974615ae3906d4e36fb1d30a90e8be056d497a Use event_button() instead of event_key() since we're dealing with mouse events diff -r cc974615ae39 -r 9638f05098cf src/ui.cc --- a/src/ui.cc Fri Mar 06 18:35:40 2009 +0000 +++ b/src/ui.cc Mon Mar 09 17:17:51 2009 +0100 @@ -279,7 +279,7 @@ static void b1_cb(Widget *wid, void *cb_data) { int bn = VOIDP2INT(cb_data); - int k = event_key(); + int k = event_button(); if (k && k <= 7) { _MSG("[%s], mouse button %d was pressed\n", button_names[bn], k); _MSG("mouse button %d was pressed\n", k);
# HG changeset patch # User Justus Winter <justus.winter@informatik.uni-hamburg.de> # Date 1236615692 -3600 # Node ID 78c0fa261c84df53da7f69cc8f33dc85fa152f9c # Parent 9638f05098cf2687dbb863f47fd82461c5417403 Add a bookmark button to the toolbar This is useful for embedded devices with touch screens which lack a proper keyboard and the ability to generate right click events. diff -r 9638f05098cf -r 78c0fa261c84 src/pixmaps.h --- a/src/pixmaps.h Mon Mar 09 17:17:51 2009 +0100 +++ b/src/pixmaps.h Mon Mar 09 17:21:32 2009 +0100 @@ -789,6 +789,34 @@ " . . "}; /* XPM */ +static const char * bm_add_xpm[] = { +"22 22 2 1", +" c None", +". c #FF0000", +" ", +" ", +" ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ............... ", +" ............... ", +" ............... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ", +" ", +" ", +" "}; + +/* XPM */ static const char *const tools_xpm[] = { "22 22 25 1", " c #None", @@ -1373,6 +1401,28 @@ " .v. wx. "}; /* XPM */ +static const char * bm_add_s_xpm[] = { +"16 16 2 1", +" c None", +". c #FF0000", +" ", +" ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ........... ", +" ........... ", +" .. ", +" .. ", +" .. ", +" .. ", +" ", +" ", +" "}; + +/* XPM */ static const char *const tools_s_xpm[] = { "16 16 45 1", " c #7B127D1C7D08", diff -r 9638f05098cf -r 78c0fa261c84 src/ui.cc --- a/src/ui.cc Mon Mar 09 17:17:51 2009 +0100 +++ b/src/ui.cc Mon Mar 09 17:21:32 2009 +0100 @@ -28,6 +28,7 @@ #include "ui.hh" #include "msg.h" #include "timeout.hh" +#include "html_common.hh" // for DilloHtml using namespace fltk; @@ -38,7 +39,7 @@ struct iconset { Image *ImgMeterOK, *ImgMeterBug, - *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, + *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgBookAdd, *ImgTools, *ImgClear,*ImgSearch; MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti; }; @@ -50,6 +51,7 @@ new xpmImage(reload_xpm), new xpmImage(save_xpm), new xpmImage(bm_xpm), + new xpmImage(bm_add_xpm), new xpmImage(tools_xpm), new xpmImage(new_s_xpm), new xpmImage(search_xpm), @@ -68,6 +70,7 @@ new xpmImage(reload_s_xpm), new xpmImage(save_s_xpm), new xpmImage(bm_s_xpm), + new xpmImage(bm_add_s_xpm), new xpmImage(tools_s_xpm), new xpmImage(new_s_xpm), standard_icons.ImgSearch, @@ -324,6 +327,12 @@ a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid)); } break; + case UI_BOOK_ADD: + if (k == 1) { + BrowserWindow *bw = a_UIcmd_get_bw_by_widget(wid); + a_UIcmd_add_bookmark(bw, ((DilloHtml *) a_Bw_get_current_doc(bw))->page_url); + } + break; case UI_TOOLS: if (k == 1 || k == 3) { a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid); @@ -416,6 +425,12 @@ b->callback(b1_cb, (void *)UI_BOOK); b->clear_tab_to_focus(); + Bookmarks = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Add" : 0); + b->image(icons->ImgBookAdd); + b->tooltip("Add bookmark"); + b->callback(b1_cb, (void *)UI_BOOK_ADD); + b->clear_tab_to_focus(); + Tools = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Tools" : 0); b->image(icons->ImgTools); b->tooltip("Settings"); diff -r 9638f05098cf -r 78c0fa261c84 src/ui.hh --- a/src/ui.hh Mon Mar 09 17:17:51 2009 +0100 +++ b/src/ui.hh Mon Mar 09 17:21:32 2009 +0100 @@ -26,6 +26,7 @@ UI_SAVE, UI_STOP, UI_BOOK, + UI_BOOK_ADD, UI_TOOLS, UI_CLEAR, UI_SEARCH
Hi Justus, On Mon, Mar 09, 2009 at 05:59:31PM +0100, Justus Winter wrote:
Hey folks :)
I've got a new toy (the Neo FreeRunner) and dillo2 runs quite nicely on that little device, but there are some problems:
* there is no way to create bookmarks
What about the context menus in general? Is there no way to simulate a right mouse click? dillo uses context menus in many cases so we probabely need a general solution for this.
Adressed in the second patch which adds an add bookmark button to the main toolbar.
What about a dillorc option to make it optional like the other buttons?
* the scrollbars are unusable without a stylus
A more natural way of scrolling on embedded devices with touchscreens is finger scrolling. A proof of concept is attached as the third patch.
Didn't look at the code yet, but the concept seems nice. Maybe we could ship a "dillorc.handheld" or something like that...
Acceleration would be a nice feature for big pages.
* buttons on dialogs are too small
Proposed solution: There is code for creating dialogs in src/dialog.cc for a_Dialog_choice5 that creates the dialog window without relying on fltks choice(). We could generalize that and use it for all dialogs.
That would be a good thing anyway so that all dialogs share a consistent look.
This way we could resize the buttons and stack them vertically on top of each other.
Why not, if that's better for mobile devices and if it's configurable. Cheers, Johannes
Hofmann Johannes wrote:
Hi Justus,
On Mon, Mar 09, 2009 at 05:59:31PM +0100, Justus Winter wrote:
Hey folks :)
I've got a new toy (the Neo FreeRunner) and dillo2 runs quite nicely on that little device, but there are some problems:
* there is no way to create bookmarks
What about the context menus in general? Is there no way to simulate a right mouse click? dillo uses context menus in many cases so we probabely need a general solution for this. There is a module for gtk2 (libgtkstylus.so) that simulates a right click when the user holds the left mouse button, that works quite nicely in practice.
That was actually what I wanted to implement at first. I looked through the fltk2 event handling code (most thoroughly with respect to the button widget) and I am convinced that this behavior cannot be implemented without patching fltk2 since the widgets do not call the callback when the button is pressed but only when it's released. I prototyped a solution that abuses the DRAG events to detect PUSH events, but that didn't work very well since DRAG events are only emitted when the cursor moves. Patching fltk2 to also call the callback function on PUSH events is problematic since (at least in dillo2) many callback functions do not test properly whether they are actually interested in that particular event and just assume that it must have been a RELEASE event.
Adressed in the second patch which adds an add bookmark button to the main toolbar.
What about a dillorc option to make it optional like the other buttons? Sure thing, that would be great. It shouldn't be too hard to make the toolbar content configurable.
* the scrollbars are unusable without a stylus
A more natural way of scrolling on embedded devices with touchscreens is finger scrolling. A proof of concept is attached as the third patch.
Didn't look at the code yet, but the concept seems nice. Maybe we could ship a "dillorc.handheld" or something like that...
The changes are actually quite small since a similar functionality was already present, namely panning via the middle mouse button. My patch just adds a configuration option to do so with the left button and to fiddle with the event handling code (you have to pass some events to the page content or you end up with a browser with non functional links :)). Note that this is just a mockup that needs some cleanups (works only for the first tab, need to adjust the open tab functionality in uicmd, text selection works fine with a mouse but is next to impossible on the moko due to double click tolerances (at least thats what I think)). And the text selection part is not configurable at the moment, that's the most problematic part. Any thoughts on how to make dw configurable at runtime while keeping it implementation agnostic with respect to the frontend? Justus
On Tue, Mar 10, 2009 at 02:12:56AM +0100, Justus Winter wrote:
Hofmann Johannes wrote:
Hi Justus,
On Mon, Mar 09, 2009 at 05:59:31PM +0100, Justus Winter wrote:
Hey folks :)
I've got a new toy (the Neo FreeRunner) and dillo2 runs quite nicely on that little device, but there are some problems:
* there is no way to create bookmarks
What about the context menus in general? Is there no way to simulate a right mouse click? dillo uses context menus in many cases so we probabely need a general solution for this. There is a module for gtk2 (libgtkstylus.so) that simulates a right click when the user holds the left mouse button, that works quite nicely in practice.
Andreas suggestd the same, and it looks like a good solution. Even more if handheld users are accustomed to it.
That was actually what I wanted to implement at first. I looked through the fltk2 event handling code (most thoroughly with respect to the button widget) [...]
Maybe something like what's used for tooltip can be of help. This has to be asked in fltk general before discarding it. If there's no way, a right-click button may be of help. This is left-click on RCB and the next left-click will be processed as a right click. The idea is to try to reuse the UI as much as possible, and to just code the necessary hooks for it. Please contact Andreas K., he may have good ideas for handheld related issues. -- Cheers Jorge.-
On Thu, Mar 12, 2009 at 11:07:58PM +0100, Andreas Kemnade wrote:
Hi,
On Wed, 11 Mar 2009 08:41:20 -0300 Jorge Arellano Cid <jcid@dillo.org> wrote:
On Tue, Mar 10, 2009 at 02:12:56AM +0100, Justus Winter wrote:
Hofmann Johannes wrote:
Hi Justus,
On Mon, Mar 09, 2009 at 05:59:31PM +0100, Justus Winter wrote:
Hey folks :)
I've got a new toy (the Neo FreeRunner) and dillo2 runs quite nicely on that little device, but there are some problems:
* there is no way to create bookmarks
What about the context menus in general? Is there no way to simulate a right mouse click? dillo uses context menus in many cases so we probabely need a general solution for this. There is a module for gtk2 (libgtkstylus.so) that simulates a right click when the user holds the left mouse button, that works quite nicely in practice.
Andreas suggestd the same, and it looks like a good solution. Even more if handheld users are accustomed to it.
That was actually what I wanted to implement at first. I looked through the fltk2 event handling code (most thoroughly with respect to the button widget) [...]
I have done a quick-hack for proof-of-concept purposes. It is a really dirty patch. But maybe it is a starting point for experimenting. If the button is released after pressing it more than two seconds, the menu will popup on the page. I have successfully added bookmarks without using the right mouse button.
Good. Please continue working on this line into a clean patch. Also wrapping it with a pref switch looks right: e.g. emulate_right_click
Maybe something like what's used for tooltip can be of help. This has to be asked in fltk general before discarding it.
If there's no way, a right-click button may be of help. This is left-click on RCB and the next left-click will be processed as a right click.
A button like that does already exist. It is a matchbox-panel app called xmonobut. It toggles the button you hit when you touch the touchscreen. I don't know why I don't get it work with the freerunner yet. On my Ipaq I have no problems with it.
Asking xmonobut developers may save some work. Anyway having the option in dillo doesn't hurt much. -- Cheers Jorge.-
participants (4)
-
4winter@informatik.uni-hamburg.de
-
akemnade@tzi.de
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de