Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset resize counter when viewport changes size #301

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dw/layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Layout::Anchor::~Anchor ()

// ---------------------------------------------------------------------

Layout::Layout (Platform *platform)
Layout::Layout (Platform *platform, bool limit)
{
this->platform = platform;
view = NULL;
Expand Down Expand Up @@ -308,6 +308,7 @@ Layout::Layout (Platform *platform)

resizeIdleCounter = queueResizeCounter = sizeAllocateCounter
= sizeRequestCounter = getExtremesCounter = resizeCounter = 0;
resizeLimit = limit;
}

Layout::~Layout ()
Expand Down Expand Up @@ -882,7 +883,7 @@ void Layout::resizeIdle ()

/* Prevent infinite resize loop, if we reach this point it is very likely
* there is a bug in the layouting process */
if (resizeCounter >= 1000) {
if (resizeLimit && resizeCounter >= 1000) {
MSG_ERR("Emergency layout stop after %d iterations\n", resizeCounter);
MSG_ERR("Please file a bug report with the complete console output\n");
resizeIdleId = -1;
Expand Down Expand Up @@ -1328,6 +1329,7 @@ void Layout::viewportSizeChanged (View *view, int width, int height)
canvasHeightGreater = false; // reset value here
viewportWidth = width;
viewportHeight = height;
resizeCounter = 0;
containerSizeChanged ();

DBG_OBJ_SET_SYM ("canvasHeightGreater",
Expand Down
3 changes: 2 additions & 1 deletion dw/layout.hh
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ private:

int resizeIdleCounter, queueResizeCounter, sizeAllocateCounter,
sizeRequestCounter, getExtremesCounter, resizeCounter;
bool resizeLimit;

void enterResizeIdle () { resizeIdleCounter++; }
void leaveResizeIdle () { resizeIdleCounter--; }

public:
Layout (Platform *platform);
Layout (Platform *platform, bool limit=true);
~Layout ();

inline void connectLink (LinkReceiver *receiver)
Expand Down
4 changes: 3 additions & 1 deletion dw/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Dillo Widget
*
* Copyright 2005-2007 Sebastian Geerken <[email protected]>
* Copyright 2024 Rodrigo Arias Mallo <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -343,7 +344,8 @@ void ComplexButtonResource::init (Widget *widget)
{
childWidget = widget;

layout = new Layout (createPlatform ());
/* FIXME: Buttons should not need a full Layout */
layout = new Layout (createPlatform (), false);
setLayout (layout);
DBG_OBJ_ASSOC_CHILD (layout);
layout->setWidget (widget);
Expand Down
Loading