mirror of https://github.com/aseprite/aseprite.git
Avoid enqueuing events directly to laf-os
This commit is contained in:
parent
a3236bc1e9
commit
45fbeda95b
|
@ -55,8 +55,6 @@
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "gfx/point.h"
|
#include "gfx/point.h"
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
#include "os/event.h"
|
|
||||||
#include "os/event_queue.h"
|
|
||||||
#include "os/surface.h"
|
#include "os/surface.h"
|
||||||
#include "os/system.h"
|
#include "os/system.h"
|
||||||
#include "text/font.h"
|
#include "text/font.h"
|
||||||
|
@ -4496,8 +4494,7 @@ void Timeline::onDragLeave(ui::DragEvent& e)
|
||||||
m_dropRange.clearRange();
|
m_dropRange.clearRange();
|
||||||
invalidate();
|
invalidate();
|
||||||
flushRedraw();
|
flushRedraw();
|
||||||
os::Event ev;
|
flushMessages();
|
||||||
os::System::instance()->eventQueue()->queueEvent(ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline::onDrag(ui::DragEvent& e)
|
void Timeline::onDrag(ui::DragEvent& e)
|
||||||
|
@ -4526,8 +4523,7 @@ void Timeline::onDrag(ui::DragEvent& e)
|
||||||
|
|
||||||
updateDropRange(e.position());
|
updateDropRange(e.position());
|
||||||
flushRedraw();
|
flushRedraw();
|
||||||
os::Event ev;
|
flushMessages();
|
||||||
os::System::instance()->eventQueue()->queueEvent(ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline::onDrop(ui::DragEvent& e)
|
void Timeline::onDrop(ui::DragEvent& e)
|
||||||
|
@ -4603,8 +4599,7 @@ void Timeline::onDrop(ui::DragEvent& e)
|
||||||
m_dropRange.clearRange();
|
m_dropRange.clearRange();
|
||||||
invalidate();
|
invalidate();
|
||||||
flushRedraw();
|
flushRedraw();
|
||||||
os::Event ev;
|
flushMessages();
|
||||||
os::System::instance()->eventQueue()->queueEvent(ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Timeline::tagFramesDuration(const Tag* tag) const
|
int Timeline::tagFramesDuration(const Tag* tag) const
|
||||||
|
|
|
@ -881,6 +881,13 @@ void Manager::dispatchMessages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Manager::flushMessages() const
|
||||||
|
{
|
||||||
|
// Send a dummy event just to break the waiting loop.
|
||||||
|
os::Event evt;
|
||||||
|
m_eventQueue->queueEvent(evt);
|
||||||
|
}
|
||||||
|
|
||||||
void Manager::addToGarbage(Widget* widget)
|
void Manager::addToGarbage(Widget* widget)
|
||||||
{
|
{
|
||||||
ASSERT(widget);
|
ASSERT(widget);
|
||||||
|
|
|
@ -63,6 +63,10 @@ public:
|
||||||
bool generateMessages();
|
bool generateMessages();
|
||||||
void dispatchMessages();
|
void dispatchMessages();
|
||||||
|
|
||||||
|
// Wakes up the system's events queue to process the currently enqueued UI
|
||||||
|
// messages.
|
||||||
|
void flushMessages() const;
|
||||||
|
|
||||||
// Makes the generateMessages() function to return immediately if
|
// Makes the generateMessages() function to return immediately if
|
||||||
// there is no user events in the OS queue. Useful only for tests
|
// there is no user events in the OS queue. Useful only for tests
|
||||||
// or benchmarks where we don't wait the user (or we don't even
|
// or benchmarks where we don't wait the user (or we don't even
|
||||||
|
|
|
@ -1176,6 +1176,16 @@ void Widget::flushRedraw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::flushMessages() const
|
||||||
|
{
|
||||||
|
Manager* manager = this->manager();
|
||||||
|
ASSERT(manager);
|
||||||
|
if (!manager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
manager->flushMessages();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::paint(Graphics* graphics, const gfx::Region& drawRegion, const bool isBg)
|
void Widget::paint(Graphics* graphics, const gfx::Region& drawRegion, const bool isBg)
|
||||||
{
|
{
|
||||||
if (drawRegion.isEmpty())
|
if (drawRegion.isEmpty())
|
||||||
|
|
|
@ -313,6 +313,10 @@ public:
|
||||||
// Generates paint messages for the current update region.
|
// Generates paint messages for the current update region.
|
||||||
void flushRedraw();
|
void flushRedraw();
|
||||||
|
|
||||||
|
// Wakes up the system's events queue to process the currently enqueued UI
|
||||||
|
// messages.
|
||||||
|
void flushMessages() const;
|
||||||
|
|
||||||
GraphicsPtr getGraphics(const gfx::Rect& clip);
|
GraphicsPtr getGraphics(const gfx::Rect& clip);
|
||||||
|
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
Loading…
Reference in New Issue