Browse Source

Avoiding flicker when handling synchronous repainting of desktop windows when they are resized.

tags/2021-05-28
jules 11 years ago
parent
commit
19b412c1a8
2 changed files with 23 additions and 1 deletions
  1. +20
    -1
      modules/juce_gui_basics/components/juce_Component.cpp
  2. +3
    -0
      modules/juce_gui_basics/components/juce_Component.h

+ 20
- 1
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -1182,11 +1182,25 @@ void Component::setBounds (const int x, const int y, int w, int h)
cachedImage->invalidateAll();
}
flags.isMoveCallbackPending = wasMoved;
flags.isResizeCallbackPending = wasResized;
if (flags.hasHeavyweightPeerFlag)
if (ComponentPeer* const peer = getPeer())
peer->updateBounds();
sendMovedResizedMessages (wasMoved, wasResized);
sendMovedResizedMessagesIfPending();
}
}
void Component::sendMovedResizedMessagesIfPending()
{
if (flags.isMoveCallbackPending || flags.isResizeCallbackPending)
{
sendMovedResizedMessages (flags.isMoveCallbackPending, flags.isResizeCallbackPending);
flags.isMoveCallbackPending = false;
flags.isResizeCallbackPending = false;
}
}
@@ -2047,6 +2061,11 @@ void Component::paintComponentAndChildren (Graphics& g)
void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel)
{
// If sizing a top-level-window and the OS paint message is delivered synchronously
// before resized() is called, then we'll invoke the callback here, to make sure
// the components inside have had a chance to sort their sizes out..
sendMovedResizedMessagesIfPending();
#if JUCE_DEBUG
flags.isInsidePaintCall = true;
#endif


+ 3
- 0
modules/juce_gui_basics/components/juce_Component.h View File

@@ -2306,6 +2306,8 @@ private:
bool childCompFocusedFlag : 1;
bool dontClipGraphicsFlag : 1;
bool mouseDownWasBlocked : 1;
bool isMoveCallbackPending : 1;
bool isResizeCallbackPending : 1;
#if JUCE_DEBUG
bool isInsidePaintCall : 1;
#endif
@@ -2344,6 +2346,7 @@ private:
void paintComponentAndChildren (Graphics&);
void paintWithinParentContext (Graphics&);
void sendMovedResizedMessages (bool wasMoved, bool wasResized);
void sendMovedResizedMessagesIfPending();
void repaintParent();
void sendFakeMouseMove() const;
void takeKeyboardFocus (const FocusChangeType);


Loading…
Cancel
Save