From cb3b8d6caa623ba07b17d267957fc77fd997bbcd Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 21 Jan 2011 23:48:30 +0100 Subject: quick fix for Layout::getWidgetAtPoint() crash in fltk-1.3 fltk-1.3 calls fl_fix_focus() on widget deletion, which causes dillo to traverse it's own widget tree while it's getting deleted. Stop this using a flag for now. It would be nice if we could fix this more elegantly. --- dw/layout.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index e33da4d1..c73b9760 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -185,6 +185,7 @@ Layout::Layout (Platform *platform) view = NULL; topLevel = NULL; widgetAtPoint = NULL; + deletingTopLevel = false; DBG_OBJ_CREATE (this, "DwRenderLayout"); @@ -278,9 +279,11 @@ void Layout::removeWidget () void Layout::setWidget (Widget *widget) { + widgetAtPoint = NULL; + deletingTopLevel = true; if (topLevel) delete topLevel; - widgetAtPoint = NULL; + deletingTopLevel = false; textZone->zoneFree (); addWidget (widget); @@ -828,7 +831,7 @@ Widget *Layout::getWidgetAtPoint (int x, int y) { _MSG ("------------------------------------------------------------\n"); _MSG ("widget at (%d, %d)\n", x, y); - if (topLevel) + if (topLevel && !deletingTopLevel) return topLevel->getWidgetAtPoint (x, y, 0); else return NULL; -- cgit v1.2.3 From 2411c95059cb0f26a4b38075916f597e7948eca2 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 23 Jan 2011 18:55:28 +0000 Subject: extend Johannes's deletingTopLevel workaround from 400a06a83891 --- dw/layout.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index c73b9760..bfaf9969 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -226,8 +226,10 @@ Layout::~Layout () platform->removeIdle (resizeIdleId); if (bgColor) bgColor->unref (); + deletingTopLevel = true; if (topLevel) delete topLevel; + deletingTopLevel = false; delete platform; delete view; delete anchorsTable; @@ -773,6 +775,9 @@ bool Layout::motionNotify (View *view, int x, int y, ButtonState state) { EventButton event; + if (deletingTopLevel) + return true; + moveToWidgetAtPoint (x, y, state); event.xCanvas = x; -- cgit v1.2.3 From bc476c13039158dea4e5370987f5f5adbff4f02d Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 23 Feb 2011 18:39:01 +0000 Subject: different fix for the getWidgetAtPoint problems --- dw/layout.cc | 24 +++++++++++------------- dw/layout.hh | 1 - 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index bfaf9969..3680e0c8 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -185,7 +185,6 @@ Layout::Layout (Platform *platform) view = NULL; topLevel = NULL; widgetAtPoint = NULL; - deletingTopLevel = false; DBG_OBJ_CREATE (this, "DwRenderLayout"); @@ -226,10 +225,11 @@ Layout::~Layout () 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::removeWidget () 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 @@ bool Layout::motionNotify (View *view, int x, int y, ButtonState state) { EventButton event; - if (deletingTopLevel) - return true; - moveToWidgetAtPoint (x, y, state); event.xCanvas = x; @@ -836,7 +834,7 @@ Widget *Layout::getWidgetAtPoint (int x, int y) { _MSG ("------------------------------------------------------------\n"); _MSG ("widget at (%d, %d)\n", x, y); - if (topLevel && !deletingTopLevel) + if (topLevel) return topLevel->getWidgetAtPoint (x, y, 0); else return NULL; diff --git a/dw/layout.hh b/dw/layout.hh index 495a8526..dc9bf227 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -132,7 +132,6 @@ private: 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; -- cgit v1.2.3 From e90273b90ea846855dfeb5fd675104d26114701e Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 24 Feb 2011 04:56:13 +0000 Subject: add some band-aids again for now for this whole events-during-deletion problem Conceptually, what feels like it 'should' happen when the form widgets are deleted and MOVEs and LEAVEs and whatnot are flying around is for the viewport not to do anything with events. But it would want to accept FOCUS, and no doubt there are other cases to make it not so simple. --- dw/layout.cc | 3 +++ src/uicmd.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index 3680e0c8..d1fecf48 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -852,6 +852,9 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) int trackLen, i; EventCrossing crossingEvent; + if (!topLevel) + return; + if (newWidgetAtPoint != widgetAtPoint) { // The mouse pointer has been moved into another widget. if (newWidgetAtPoint && widgetAtPoint) diff --git a/src/uicmd.cc b/src/uicmd.cc index 885d704e..268321d6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -551,7 +551,6 @@ void a_UIcmd_close_bw(void *vbw) MSG("a_UIcmd_close_bw\n"); a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force); - delete(layout); if (ui->tabs()) { ui->tabs()->remove(ui); if (ui->tabs()->value()) @@ -559,6 +558,7 @@ void a_UIcmd_close_bw(void *vbw) else ui->tabs()->window()->hide(); } + delete(layout); delete(ui); a_Bw_free(bw); -- cgit v1.2.3 From f68c508f8bed52834e2894abe312d1c8e8b1cd1d Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 25 Feb 2011 00:54:06 +0000 Subject: layout: less bandaidy suggested by Johannes --- dw/layout.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index d1fecf48..d2097859 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -219,6 +219,8 @@ Layout::Layout (Platform *platform) Layout::~Layout () { + widgetAtPoint = NULL; + if (scrollIdleId != -1) platform->removeIdle (scrollIdleId); if (resizeIdleId != -1) @@ -852,9 +854,6 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) int trackLen, i; EventCrossing crossingEvent; - if (!topLevel) - return; - if (newWidgetAtPoint != widgetAtPoint) { // The mouse pointer has been moved into another widget. if (newWidgetAtPoint && widgetAtPoint) -- cgit v1.2.3 From 49f3a54f982e682a20dafc74fa32c3619cc4bef4 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 6 May 2011 18:50:29 -0300 Subject: Fixed a typo bug in Layout::setSizeHints --- dw/layout.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index d2097859..8a439ae6 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -698,7 +698,7 @@ void Layout::setSizeHints () if (topLevel) { topLevel->setWidth (viewportWidth - (canvasHeightGreater ? vScrollbarThickness : 0)); - topLevel->setAscent (viewportHeight - vScrollbarThickness); + topLevel->setAscent (viewportHeight - hScrollbarThickness); topLevel->setDescent (0); } } -- cgit v1.2.3 From 9a5cfc077d9f70be42d3202f1ff5f9eec0d76f16 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 10 May 2011 21:07:30 +0000 Subject: straighten out free/delete/delete[] --- dw/fltkui.cc | 8 ++++---- dw/image.cc | 2 +- dw/layout.cc | 2 +- lout/object.cc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 9ce5a816..b70220a2 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -235,7 +235,7 @@ FltkLabelButtonResource::FltkLabelButtonResource (FltkPlatform *platform, FltkLabelButtonResource::~FltkLabelButtonResource () { - delete label; + free((char *)label); } Fl_Widget *FltkLabelButtonResource::createNewWidget (core::Allocation @@ -450,7 +450,7 @@ FltkEntryResource::~FltkEntryResource () if (initText) delete initText; if (label) - delete label; + free((char *)label); } Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation @@ -885,7 +885,7 @@ FltkOptionMenuResource::~FltkOptionMenuResource () if (menu[i].text) free((char *) menu[i].text); } - delete menu; + delete[] menu; } void FltkOptionMenuResource::setWidgetStyle (Fl_Widget *widget, @@ -961,7 +961,7 @@ void FltkOptionMenuResource::enlargeMenu () newMenu = new Fl_Menu_Item[itemsAllocated]; memcpy(newMenu, menu, itemsUsed * sizeof(Fl_Menu_Item)); memset(newMenu + itemsUsed, 0, 0x10 * sizeof(Fl_Menu_Item)); - delete menu; + delete[] menu; menu = newMenu; ch->menu(menu); ch->value(selected); diff --git a/dw/image.cc b/dw/image.cc index cab40ed5..23e2dc84 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -157,7 +157,7 @@ Image::Image(const char *altText) Image::~Image() { if (altText) - delete altText; + free(altText); if (buffer) buffer->unref (); if (mapKey) diff --git a/dw/layout.cc b/dw/layout.cc index d2097859..d3983559 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -174,7 +174,7 @@ bool Layout::LinkEmitter::emitClick (Widget *widget, int link, int img, Layout::Anchor::~Anchor () { - delete name; + free(name); } // --------------------------------------------------------------------- diff --git a/lout/object.cc b/lout/object.cc index d72b1eec..08ea0452 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -224,7 +224,7 @@ String::String (const char *str): ConstString (str ? strdup(str) : NULL) String::~String () { if (str) - delete str; + free((char *)str); } // ------------ -- cgit v1.2.3 From 0b7264545ccd3dfe286e66f7fe1f282c46a12d31 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 12 May 2011 07:56:37 -0400 Subject: Bug fix: resize the viewport internally (when attached to a layout) * It also has a fix for scrollbars resize, and an optimization to avoid scrollbar adjustment overhead. --- dw/fltkviewbase.cc | 2 ++ dw/fltkviewport.cc | 27 +++++++++++++++++++-------- dw/layout.cc | 7 +++---- dw/view.hh | 6 ------ 4 files changed, 24 insertions(+), 18 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index d14f866c..10c3fa65 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -297,6 +297,8 @@ int FltkViewBase::handle (int event) void FltkViewBase::setLayout (core::Layout *layout) { theLayout = layout; + if (usesViewport()) + theLayout->viewportSizeChanged(this, w(), h()); } void FltkViewBase::setCanvasSize (int width, int ascent, int descent) diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index c0574dff..135550e8 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -40,11 +40,13 @@ FltkViewport::FltkViewport (int X, int Y, int W, int H, const char *label): hscrollbar = new Fl_Scrollbar (x (), y (), 1, 1); hscrollbar->type(FL_HORIZONTAL); hscrollbar->callback (hscrollbarCallback, this); + hscrollbar->hide(); add (hscrollbar); vscrollbar = new Fl_Scrollbar (x (), y(), 1, 1); vscrollbar->type(FL_VERTICAL); vscrollbar->callback (vscrollbarCallback, this); + vscrollbar->hide(); add (vscrollbar); scrollX = scrollY = scrollDX = scrollDY = 0; @@ -70,6 +72,7 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation () int hdiff = 0, vdiff = 0; int visibility = 0; + _MSG(" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n"); if (hscrollbar->visible ()) visibility |= 1; if (vscrollbar->visible ()) @@ -384,18 +387,26 @@ void FltkViewport::setViewportSize (int width, int height, int hScrollbarThickness, int vScrollbarThickness) { - if (hScrollbarThickness > 0) - hscrollbar->show (); - else - hscrollbar->hide (); - if (vScrollbarThickness > 0) - vscrollbar->show (); - else - vscrollbar->hide (); + int adjustReq = + (hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) || + (vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness); + + _MSG("FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n" + "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n", + w(),h(),width,height, + hScrollbarThickness,hscrollbar->visible(), + vScrollbarThickness,vscrollbar->visible(), adjustReq); + + (hScrollbarThickness > 0) ? hscrollbar->show () : hscrollbar->hide (); + (vScrollbarThickness > 0) ? vscrollbar->show () : vscrollbar->hide (); /* If no scrollbar, go to the beginning */ scroll(hScrollbarThickness ? 0 : -scrollX, vScrollbarThickness ? 0 : -scrollY); + + /* Adjust when scrollbar visibility changes */ + if (adjustReq) + adjustScrollbarsAndGadgetsAllocation (); } void FltkViewport::updateCanvasWidgets (int dx, int dy) diff --git a/dw/layout.cc b/dw/layout.cc index b430eaa1..a02c87b7 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -679,10 +679,9 @@ void Layout::resizeIdle () } // Set viewport sizes. - if (view->usesViewport ()) - view->setViewportSize (viewportWidth, viewportHeight, - actualHScrollbarThickness, - actualVScrollbarThickness); + view->setViewportSize (viewportWidth, viewportHeight, + actualHScrollbarThickness, + actualVScrollbarThickness); } } diff --git a/dw/view.hh b/dw/view.hh index 308e5e31..f2504091 100644 --- a/dw/view.hh +++ b/dw/view.hh @@ -92,12 +92,6 @@ public: * This will normally imply a resize of the UI widget. Width and height are * the dimensions of the new size, \em including the scrollbar thicknesses. * - * \bug The rest of this comment needs to be updated. - * - * markerWidthDiff and markerHeightDiff are the respective dimensions of - * the viewport markers (see dw::core::getMarkerWidthDiff and - * dw::core::getMarkerHeightDiff), if they are 0, the respective - * marker should not be shown at all. */ virtual void setViewportSize (int width, int height, int hScrollbarThickness, -- cgit v1.2.3 From b4354b564c4ffc0b941f7871202739839861d78d Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 13 May 2011 00:51:50 +0000 Subject: more free/delete --- dw/findtext.cc | 8 ++++---- dw/layout.cc | 2 +- lout/misc.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/findtext.cc b/dw/findtext.cc index f3e0ba20..bce6f565 100644 --- a/dw/findtext.cc +++ b/dw/findtext.cc @@ -37,7 +37,7 @@ FindtextState::FindtextState () FindtextState::~FindtextState () { if (key) - delete key; + free(key); if (nexttab) delete[] nexttab; if (iterator) @@ -52,7 +52,7 @@ void FindtextState::setWidget (Widget *widget) // A widget change will restart the search. if (key) - delete key; + free(key); key = NULL; if (nexttab) delete[] nexttab; @@ -81,7 +81,7 @@ FindtextState::Result FindtextState::search (const char *key, bool caseSens, strcmp (this->key, key) != 0) { newKey = true; if (this->key) - delete this->key; + free(this->key); this->key = strdup (key); this->caseSens = caseSens; @@ -147,7 +147,7 @@ void FindtextState::resetSearch () unhighlight (); if (key) - delete key; + free(key); key = NULL; } diff --git a/dw/layout.cc b/dw/layout.cc index a02c87b7..b502ae65 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -534,7 +534,7 @@ void Layout::setAnchor (const char *anchor) _MSG("setAnchor (%s)\n", anchor); if (requestedAnchor) - delete requestedAnchor; + free(requestedAnchor); requestedAnchor = anchor ? strdup (anchor) : NULL; updateAnchor (); } diff --git a/lout/misc.cc b/lout/misc.cc index 78f758fd..f45a3450 100644 --- a/lout/misc.cc +++ b/lout/misc.cc @@ -144,7 +144,7 @@ void StringBuffer::clear () Node *node, *nextNode; for (node = firstNode; node; node = nextNode) { nextNode = node->next; - delete node->data; + free(node->data); delete node; } firstNode = lastNode = NULL; -- cgit v1.2.3 From c5dbb7e648f6130544bbf1957d0a558a0634c63b Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 8 Jul 2011 11:56:44 -0400 Subject: Layout::moveToWidget(): send crossing events considering border cases i.e. when the source or target widget is NULL (This patch doesn't fix a *known* bug ATM, but it could be doing it, or may avoid one in the future). --- dw/layout.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index b502ae65..e6aebc62 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -850,9 +850,10 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) { Widget *ancestor, *w; Widget **track; - int trackLen, i; + int trackLen, i, i_a; EventCrossing crossingEvent; + _MSG("moveToWidget: wap=%p nwap=%p\n",widgetAtPoint,newWidgetAtPoint); if (newWidgetAtPoint != widgetAtPoint) { // The mouse pointer has been moved into another widget. if (newWidgetAtPoint && widgetAtPoint) @@ -881,6 +882,7 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) /* first part */ for (w = widgetAtPoint; w != ancestor; w = w->getParent ()) track[i++] = w; + i_a = i; track[i++] = ancestor; if (newWidgetAtPoint) { /* second part */ @@ -889,16 +891,21 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) track[i--] = w; } - /* Send events to all events on the track */ + /* Send events to the widgets on the track */ for (i = 0; i < trackLen; i++) { crossingEvent.state = state; crossingEvent.currentWidget = widgetAtPoint; // ??? crossingEvent.lastWidget = widgetAtPoint; // ??? - - if (i != 0) - track[i]->enterNotify (&crossingEvent); - if (i != trackLen - 1) + if (i < i_a) { track[i]->leaveNotify (&crossingEvent); + } else if (i == i_a) { /* ancestor */ + if (!widgetAtPoint) + track[i]->enterNotify (&crossingEvent); + else if (!newWidgetAtPoint) + track[i]->leaveNotify (&crossingEvent); + } else { + track[i]->enterNotify (&crossingEvent); + } } delete[] track; -- cgit v1.2.3 From 6f2e86c52fbf90d5efaef55fc9757b23bb27a80f Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 27 Jul 2011 10:06:39 -0400 Subject: Layout::moveToWidget(): send crossing events (part 2) This patch fixes 3f74e4d60ac1 (which is partly wrong). The idea is to avoid spurious leave/enter events, and thus prevent bugs. * avoid issuing spurious leave/enter events, and send the necessary ones. * remove the need for a workaround linkEnter() call in Textblock::leaveNotifyImpl(). --- dw/layout.cc | 15 +++++++++++---- dw/textblock.cc | 20 ++++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index e6aebc62..cf19df37 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -844,7 +844,7 @@ Widget *Layout::getWidgetAtPoint (int x, int y) /* * Emit the necessary crossing events, when the mouse pointer has moved to - * the given widget. + * the given widget (by mouse or scrolling). */ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) { @@ -890,6 +890,12 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) for (w = newWidgetAtPoint; w != ancestor; w = w->getParent ()) track[i--] = w; } +#if 0 + MSG("Track: %s[ ", widgetAtPoint ? "" : "nil "); + for (i = 0; i < trackLen; i++) + MSG("%s%p ", i == i_a ? ">" : "", track[i]); + MSG("] %s\n", newWidgetAtPoint ? "" : "nil"); +#endif /* Send events to the widgets on the track */ for (i = 0; i < trackLen; i++) { @@ -899,10 +905,11 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) if (i < i_a) { track[i]->leaveNotify (&crossingEvent); } else if (i == i_a) { /* ancestor */ - if (!widgetAtPoint) - track[i]->enterNotify (&crossingEvent); - else if (!newWidgetAtPoint) + /* don't touch ancestor unless moving into/from NULL */ + if (i_a == trackLen-1 && !newWidgetAtPoint) track[i]->leaveNotify (&crossingEvent); + else if (i_a == 0 && !widgetAtPoint) + track[i]->enterNotify (&crossingEvent); } else { track[i]->enterNotify (&crossingEvent); } diff --git a/dw/textblock.cc b/dw/textblock.cc index 045ab729..e1689ea5 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -536,6 +536,11 @@ bool Textblock::buttonReleaseImpl (core::EventButton *event) return sendSelectionEvent (core::SelectionState::BUTTON_RELEASE, event); } +/* + * Handle motion inside the widget + * (special care is necessary when switching from another widget, + * because hoverLink and hoverTooltip are meaningless then). + */ bool Textblock::motionNotifyImpl (core::EventMotion *event) { if (event->state & core::BUTTON1_MASK) @@ -557,6 +562,7 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) hoverLink = style->x_link; hoverTooltip = style->x_tooltip; } + // Show/hide tooltip if (tooltipOld != hoverTooltip) { if (tooltipOld) @@ -566,21 +572,27 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) } else if (hoverTooltip) hoverTooltip->onMotion (); - if (hoverLink != linkOld) + _MSG("tb=%p word=%p linkOld=%d hoverLink=%d\n", + this, word, linkOld, hoverLink); + if (hoverLink != linkOld) { + /* LinkEnter with hoverLink == -1 is the same as LinkLeave */ return layout->emitLinkEnter (this, hoverLink, -1, -1, -1); - else + } else { return hoverLink != -1; + } } } void Textblock::enterNotifyImpl (core::EventCrossing *event) { + _MSG(" tb=%p, ENTER NotifyImpl\n", this); + /* reset hoverLink so linkEnter is detected */ + hoverLink = -2; } void Textblock::leaveNotifyImpl (core::EventCrossing *event) { - hoverLink = -1; - (void) layout->emitLinkEnter (this, hoverLink, -1, -1, -1); + _MSG(" tb=%p, LEAVE NotifyImpl\n", this); if (hoverTooltip) { hoverTooltip->onLeave(); hoverTooltip = NULL; -- cgit v1.2.3 From ccd39b8804cba58206d254944c8e7c3bb8e02cdf Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 29 Jul 2011 15:45:45 -0400 Subject: avoid double draw after scrollIdle() After going back or forward to any page, there were two redraws: one from the origin and another from the scroll position. This patch avoids flicker, and makes rendering 100% faster in this case. --- ChangeLog | 1 + dw/layout.cc | 12 +++++++++++- dw/layout.hh | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'dw/layout.cc') diff --git a/ChangeLog b/ChangeLog index 9bb746c0..e787ba61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ dillo-3.0 [August ??, 2011] display of the control panels otherwise. - Remove 'fullscreen' key action. - Fixed a border case in URL resolver: empty path + {query|fragment} (BUG#948) + - Avoid double draw after going Back or Forward (it takes half the time now!). Patches: Jorge Arellano Cid +- Remove --enable-ansi configure option. - Limit saved cookie size. diff --git a/dw/layout.cc b/dw/layout.cc index cf19df37..170ec20e 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -194,6 +194,7 @@ Layout::Layout (Platform *platform) canvasWidth = canvasAscent = canvasDescent = 0; usesViewport = false; + drawAfterScrollReq = false; scrollX = scrollY = 0; viewportWidth = viewportHeight = 0; hScrollbarThickness = vScrollbarThickness = 0; @@ -456,6 +457,11 @@ void Layout::scrollIdle () if (xChanged || yChanged) { adjustScrollPos (); view->scrollTo (scrollX, scrollY); + if (drawAfterScrollReq) { + drawAfterScrollReq = false; + view->queueDrawTotal (); + MSG("Layout::scrollIdle: view->queueDrawTotal()\n"); + } } scrollIdleId = -1; @@ -503,7 +509,11 @@ void Layout::draw (View *view, Rectangle *area) { Rectangle widgetArea, intersection, widgetDrawArea; - if (topLevel) { + if (scrollIdleId != -1) { + /* scroll is pending, defer draw until after scrollIdle() */ + drawAfterScrollReq = true; + + } else if (topLevel) { /* Draw the top level widget. */ widgetArea.x = topLevel->allocation.x; widgetArea.y = topLevel->allocation.y; diff --git a/dw/layout.hh b/dw/layout.hh index 98aa4fc1..d08eb363 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -138,7 +138,7 @@ private: style::Cursor cursor; int canvasWidth, canvasAscent, canvasDescent; - bool usesViewport; + bool usesViewport, drawAfterScrollReq; int scrollX, scrollY, viewportWidth, viewportHeight; bool canvasHeightGreater; int hScrollbarThickness, vScrollbarThickness; -- cgit v1.2.3 From f94032dccada873a355e8665036bf1c2fefe4a8b Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 29 Jul 2011 16:20:32 -0400 Subject: Removed lingering MSG --- dw/layout.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index 170ec20e..1e3da7ca 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -460,7 +460,6 @@ void Layout::scrollIdle () if (drawAfterScrollReq) { drawAfterScrollReq = false; view->queueDrawTotal (); - MSG("Layout::scrollIdle: view->queueDrawTotal()\n"); } } -- cgit v1.2.3 From b1fdbc950ab2cd17b09d8d23556d0cced6966b96 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Mon, 1 Aug 2011 11:29:53 -0400 Subject: crossing-events part3 (fix leaving a link into a non-dw widget) This patch also disables unused code in Layout::leaveNotify() --- dw/layout.cc | 4 ++++ dw/textblock.cc | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index 1e3da7ca..1c8c44b7 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -823,6 +823,7 @@ void Layout::enterNotify (View *view, int x, int y, ButtonState state) */ void Layout::leaveNotify (View *view, ButtonState state) { +#if 0 Widget *lastWidget; EventCrossing event; @@ -835,6 +836,9 @@ void Layout::leaveNotify (View *view, ButtonState state) event.currentWidget = widgetAtPoint; lastWidget->leaveNotify (&event); } +#else + moveOutOfView (state); +#endif } /* diff --git a/dw/textblock.cc b/dw/textblock.cc index e1689ea5..3a2bf49c 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -592,7 +592,12 @@ void Textblock::enterNotifyImpl (core::EventCrossing *event) void Textblock::leaveNotifyImpl (core::EventCrossing *event) { - _MSG(" tb=%p, LEAVE NotifyImpl\n", this); + _MSG(" tb=%p, LEAVE NotifyImpl: hoverLink=%d\n", this, hoverLink); + + /* leaving the viewport can't be handled by motionNotifyImpl() */ + if (hoverLink >= 0) + layout->emitLinkEnter (this, -1, -1, -1, -1); + if (hoverTooltip) { hoverTooltip->onLeave(); hoverTooltip = NULL; -- cgit v1.2.3 From 422c01e42e09209d26b0baa1820a8b36bbdccbd6 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 9 Aug 2011 12:27:07 -0400 Subject: crossing-events part4 (fix corner case: moving into the common ancestor) In this case the ancestor is already in "entered" state, but we need to emit the signal again, for it to reset its state and resume. --- dw/layout.cc | 7 +++++-- dw/textblock.cc | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'dw/layout.cc') diff --git a/dw/layout.cc b/dw/layout.cc index 1c8c44b7..9dfd5e9b 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -918,10 +918,13 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) if (i < i_a) { track[i]->leaveNotify (&crossingEvent); } else if (i == i_a) { /* ancestor */ - /* don't touch ancestor unless moving into/from NULL */ + /* Don't touch ancestor unless: + * - moving into/from NULL, + * - ancestor becomes the newWidgetAtPoint */ if (i_a == trackLen-1 && !newWidgetAtPoint) track[i]->leaveNotify (&crossingEvent); - else if (i_a == 0 && !widgetAtPoint) + else if ((i_a == 0 && !widgetAtPoint) || + (i_a == trackLen-1 && newWidgetAtPoint)) track[i]->enterNotify (&crossingEvent); } else { track[i]->enterNotify (&crossingEvent); diff --git a/dw/textblock.cc b/dw/textblock.cc index 3a2bf49c..312cb238 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -572,7 +572,7 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) } else if (hoverTooltip) hoverTooltip->onMotion (); - _MSG("tb=%p word=%p linkOld=%d hoverLink=%d\n", + _MSG("MN tb=%p word=%p linkOld=%d hoverLink=%d\n", this, word, linkOld, hoverLink); if (hoverLink != linkOld) { /* LinkEnter with hoverLink == -1 is the same as LinkLeave */ -- cgit v1.2.3