changeset 1933:cedef3974c12

merge
author Jorge Arellano Cid <jcid@dillo.org>
date Wed, 09 Mar 2011 17:10:21 -0300
parents 22d9dd1fb523 (current diff) 8955c455fa01 (diff)
children cc972f9d7f59
files
diffstat 7 files changed, 34 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkviewbase.cc	Wed Mar 09 17:07:35 2011 -0300
+++ b/dw/fltkviewbase.cc	Wed Mar 09 17:10:21 2011 -0300
@@ -29,6 +29,8 @@
 #include <wctype.h>
 #include "../lout/msg.h"
 
+extern Fl_Widget* fl_oldfocus;
+
 using namespace lout::object;
 using namespace lout::container::typed;
 
@@ -71,6 +73,7 @@
    canvasHeight = 1;
    bgColor = FL_WHITE;
    mouse_x = mouse_y = 0;
+   focused_child = NULL;
    exposeArea = NULL;
    if (backBuffer == NULL) {
       backBuffer = new BackBuffer ();
@@ -268,6 +271,17 @@
       theLayout->leaveNotify (this, getDwButtonState ());
       return Fl_Group::handle (event);
 
+   case FL_FOCUS:
+      if (focused_child && find(focused_child) < children()) {
+         /* strangely, find() == children() if the child is not found */
+         focused_child->take_focus();
+      }
+      return 1;
+
+   case FL_UNFOCUS:
+      focused_child = fl_oldfocus;
+      return 0;
+      
    default:
       return Fl_Group::handle (event);
    }
--- a/dw/fltkviewbase.hh	Wed Mar 09 17:07:35 2011 -0300
+++ b/dw/fltkviewbase.hh	Wed Mar 09 17:10:21 2011 -0300
@@ -56,6 +56,7 @@
    core::Layout *theLayout;
    int canvasWidth, canvasHeight;
    int mouse_x, mouse_y;
+   Fl_Widget *focused_child;
 
    virtual int translateViewXToCanvasX (int x) = 0;
    virtual int translateViewYToCanvasY (int y) = 0;
--- a/dw/fltkviewport.cc	Wed Mar 09 17:07:35 2011 -0300
+++ b/dw/fltkviewport.cc	Wed Mar 09 17:10:21 2011 -0300
@@ -223,17 +223,6 @@
 
    case FL_FOCUS:
       /** \bug Draw focus box. */
-#if 0
-PORT1.3
-      /* If the user clicks with the left button we take focus
-       * and thereby unfocus any form widgets.
-       * Otherwise we let fltk do the focus handling.
-       */
-      if (Fl::event_button() == FL_LEFT_MOUSE || focus_index() < 0) {
-         focus_index(-1);
-         return 1;
-      }
-#endif
       break;
 
    case FL_UNFOCUS:
@@ -241,17 +230,15 @@
       break;
 
    case FL_PUSH:
-      take_focus();
-      if (Fl::event_button() == FL_MIDDLE_MOUSE) {
+      if (FltkWidgetView::handle (event) == 0 &&
+          Fl::event_button() == FL_MIDDLE_MOUSE) {
          /* pass event so that middle click can open link in new window */
-         if (FltkWidgetView::handle (event) == 0) {
-            dragScrolling = 1;
-            dragX = Fl::event_x();
-            dragY = Fl::event_y();
-            setCursor (core::style::CURSOR_MOVE);
-         }
-         return 1;
+         dragScrolling = 1;
+         dragX = Fl::event_x();
+         dragY = Fl::event_y();
+         setCursor (core::style::CURSOR_MOVE);
       }
+      return 1;
       break;
 
    case FL_DRAG:
--- a/dw/layout.cc	Wed Mar 09 17:07:35 2011 -0300
+++ b/dw/layout.cc	Wed Mar 09 17:10:21 2011 -0300
@@ -185,7 +185,6 @@
    view = NULL;
    topLevel = NULL;
    widgetAtPoint = NULL;
-   deletingTopLevel = false;
 
    DBG_OBJ_CREATE (this, "DwRenderLayout");
 
@@ -226,10 +225,11 @@
       platform->removeIdle (resizeIdleId);
    if (bgColor)
       bgColor->unref ();
-   deletingTopLevel = true;
-   if (topLevel)
-      delete topLevel;
-   deletingTopLevel = false;
+   if (topLevel) {
+      Widget *w = topLevel;
+      topLevel = NULL;
+      delete w;
+   }
    delete platform;
    delete view;
    delete anchorsTable;
@@ -282,10 +282,11 @@
 void Layout::setWidget (Widget *widget)
 {
    widgetAtPoint = NULL;
-   deletingTopLevel = true;
-   if (topLevel)
-      delete topLevel;
-   deletingTopLevel = false;
+   if (topLevel) {
+      Widget *w = topLevel;
+      topLevel = NULL;
+      delete w;
+   }
    textZone->zoneFree ();
    addWidget (widget);
 
@@ -775,9 +776,6 @@
 {
    EventButton event;
 
-   if (deletingTopLevel)
-      return true;
-
    moveToWidgetAtPoint (x, y, state);
 
    event.xCanvas = x;
@@ -836,7 +834,7 @@
 {
    _MSG ("------------------------------------------------------------\n");
    _MSG ("widget at (%d, %d)\n", x, y);
-   if (topLevel && !deletingTopLevel)
+   if (topLevel)
       return topLevel->getWidgetAtPoint (x, y, 0);
    else
       return NULL;
--- a/dw/layout.hh	Wed Mar 09 17:07:35 2011 -0300
+++ b/dw/layout.hh	Wed Mar 09 17:10:21 2011 -0300
@@ -132,7 +132,6 @@
    Platform *platform;
    View *view;
    Widget *topLevel, *widgetAtPoint;
-   bool deletingTopLevel; // XXX quick hack for fltk-1.3 port
 
    /* The state, which must be projected into the view. */
    style::Color *bgColor;
--- a/src/findbar.cc	Wed Mar 09 17:07:35 2011 -0300
+++ b/src/findbar.cc	Wed Mar 09 17:10:21 2011 -0300
@@ -82,19 +82,6 @@
 }
 
 /*
- * Find next occurrence of input key
- */
-void Findbar::search_cb2(Fl_Widget *widget, void *vfb)
-{
-   /*
-    * Somehow fltk even regards the first loss of focus for the
-    * window as a WHEN_ENTER_KEY_ALWAYS event.
-    */
-   if (Fl::event_key() == FL_Enter)
-      search_cb(widget, vfb);
-}
-
-/*
  * Hide the search bar
  */
 void Findbar::hide_cb(Fl_Widget *, void *vfb)
@@ -133,8 +120,7 @@
     x += input_width + gap;
     resizable(i);
     i->color(206);
-    i->when(FL_WHEN_ENTER_KEY_ALWAYS);
-    i->callback(search_cb2, this);
+    i->when(FL_WHEN_NEVER);
    add(i);
 
     next_btn = new Fl_Button(x, border, button_width, height, "Next");
--- a/src/findbar.hh	Wed Mar 09 17:07:35 2011 -0300
+++ b/src/findbar.hh	Wed Mar 09 17:10:21 2011 -0300
@@ -20,7 +20,6 @@
 
    static void search_cb (Fl_Widget *, void *);
    static void searchBackwards_cb (Fl_Widget *, void *);
-   static void search_cb2 (Fl_Widget *, void *);
    static void hide_cb (Fl_Widget *, void *);
 
 public: