# 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