mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-11 18:41:05 +00:00
Add more tracing options to debug UI messages
Added REPORT_MOUSE/PAINT/TIMER_MESSAGES macros, and change _EVENTS to _MESSAGES to avoid confusion with the current terminology. The output string for each message was also simplified.
This commit is contained in:
parent
71f6dbad28
commit
a7799b76fc
@ -63,4 +63,5 @@ target_link_libraries(ui-lib
|
|||||||
laf-os
|
laf-os
|
||||||
laf-gfx
|
laf-gfx
|
||||||
laf-base
|
laf-base
|
||||||
obs)
|
obs
|
||||||
|
fmt)
|
||||||
|
@ -5,11 +5,14 @@
|
|||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
// #define REPORT_EVENTS
|
// #define REPORT_MESSAGES 1
|
||||||
// #define REPORT_FOCUS_MOVEMENT
|
// #define REPORT_MOUSE_MESSAGES 1
|
||||||
// #define DEBUG_PAINT_EVENTS
|
// #define REPORT_PAINT_MESSAGES 1
|
||||||
// #define LIMIT_DISPATCH_TIME
|
// #define REPORT_TIMER_MESSAGES 1
|
||||||
#define GARBAGE_TRACE(...)
|
// #define REPORT_FOCUS_MOVEMENT 1
|
||||||
|
// #define DEBUG_PAINT_MESSAGES 1
|
||||||
|
// #define LIMIT_DISPATCH_TIME 1
|
||||||
|
#define GARBAGE_TRACE(...) // TRACE(__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -21,6 +24,7 @@
|
|||||||
#include "base/scoped_value.h"
|
#include "base/scoped_value.h"
|
||||||
#include "base/thread.h"
|
#include "base/thread.h"
|
||||||
#include "base/time.h"
|
#include "base/time.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
#include "os/event.h"
|
#include "os/event.h"
|
||||||
#include "os/event_queue.h"
|
#include "os/event_queue.h"
|
||||||
#include "os/surface.h"
|
#include "os/surface.h"
|
||||||
@ -38,7 +42,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(DEBUG_PAINT_EVENTS)
|
#if defined(_WIN32) && defined(DEBUG_PAINT_MESSAGES)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#undef min
|
#undef min
|
||||||
@ -989,7 +993,7 @@ void Manager::setFocus(Widget* widget)
|
|||||||
|
|
||||||
void Manager::setMouse(Widget* widget)
|
void Manager::setMouse(Widget* widget)
|
||||||
{
|
{
|
||||||
#ifdef REPORT_EVENTS
|
#if REPORT_MOUSE_MESSAGES
|
||||||
TRACEARGS("Manager::setMouse ",
|
TRACEARGS("Manager::setMouse ",
|
||||||
(widget ? typeid(*widget).name(): "null"),
|
(widget ? typeid(*widget).name(): "null"),
|
||||||
(widget ? widget->id(): ""));
|
(widget ? widget->id(): ""));
|
||||||
@ -1812,13 +1816,13 @@ int Manager::pumpQueue()
|
|||||||
{
|
{
|
||||||
ASSERT(manager_thread == std::this_thread::get_id());
|
ASSERT(manager_thread == std::this_thread::get_id());
|
||||||
|
|
||||||
#ifdef LIMIT_DISPATCH_TIME
|
#if LIMIT_DISPATCH_TIME
|
||||||
base::tick_t t = base::current_tick();
|
base::tick_t t = base::current_tick();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int count = 0; // Number of processed messages
|
int count = 0; // Number of processed messages
|
||||||
while (!msg_queue.empty()) {
|
while (!msg_queue.empty()) {
|
||||||
#ifdef LIMIT_DISPATCH_TIME
|
#if LIMIT_DISPATCH_TIME
|
||||||
if (base::current_tick()-t > 250)
|
if (base::current_tick()-t > 250)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -1887,7 +1891,7 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
|||||||
if (!widget)
|
if (!widget)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef REPORT_EVENTS
|
#if REPORT_MESSAGES
|
||||||
{
|
{
|
||||||
static const char* msg_name[] = {
|
static const char* msg_name[] = {
|
||||||
"kOpenMessage",
|
"kOpenMessage",
|
||||||
@ -1918,15 +1922,38 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
|||||||
static_assert(kOpenMessage == 0 &&
|
static_assert(kOpenMessage == 0 &&
|
||||||
kCallbackMessage == sizeof(msg_name)/sizeof(const char*)-1,
|
kCallbackMessage == sizeof(msg_name)/sizeof(const char*)-1,
|
||||||
"MessageType enum has changed");
|
"MessageType enum has changed");
|
||||||
const char* string =
|
const char* messageStr =
|
||||||
(msg->type() >= 0 &&
|
(msg->type() >= 0 &&
|
||||||
msg->type() < sizeof(msg_name)/sizeof(const char*)) ?
|
msg->type() < sizeof(msg_name)/sizeof(const char*)) ?
|
||||||
msg_name[msg->type()]: "Unknown";
|
msg_name[msg->type()]: "Unknown";
|
||||||
|
|
||||||
TRACEARGS("Event", msg->type(), "(", string, ")",
|
if (
|
||||||
"for", ((void*)widget),
|
#if !REPORT_MOUSE_MESSAGES
|
||||||
typeid(*widget).name(),
|
(msg->type() < kMouseDownMessage ||
|
||||||
widget->id().empty());
|
msg->type() > kTouchMagnifyMessage) &&
|
||||||
|
#endif
|
||||||
|
#if !REPORT_PAINT_MESSAGES
|
||||||
|
(msg->type() != kPaintMessage) &&
|
||||||
|
#endif
|
||||||
|
#if !REPORT_TIMER_MESSAGES
|
||||||
|
(msg->type() != kTimerMessage) &&
|
||||||
|
#endif
|
||||||
|
true)
|
||||||
|
{
|
||||||
|
TRACEARGS(fmt::format(
|
||||||
|
"-- {} ({}) for {} {}{}{} --",
|
||||||
|
messageStr,
|
||||||
|
(int)msg->type(),
|
||||||
|
((void*)widget),
|
||||||
|
typeid(*widget).name(),
|
||||||
|
!widget->id().empty() ? " " + widget->id() : "",
|
||||||
|
#if REPORT_PAINT_MESSAGES
|
||||||
|
(msg->type() == kPaintMessage) ?
|
||||||
|
" clipRect=" +
|
||||||
|
base_args_to_string(static_cast<PaintMessage*>(msg)->rect()) :
|
||||||
|
#endif
|
||||||
|
""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1953,11 +1980,7 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
|||||||
surface->saveClip();
|
surface->saveClip();
|
||||||
|
|
||||||
if (surface->clipRect(paintMsg->rect())) {
|
if (surface->clipRect(paintMsg->rect())) {
|
||||||
#ifdef REPORT_EVENTS
|
#if DEBUG_PAINT_MESSAGES
|
||||||
TRACEARGS(" - clipRect ", paintMsg->rect());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG_PAINT_EVENTS
|
|
||||||
{
|
{
|
||||||
os::SurfaceLock lock(surface.get());
|
os::SurfaceLock lock(surface.get());
|
||||||
os::Paint p;
|
os::Paint p;
|
||||||
@ -2280,7 +2303,7 @@ bool Manager::processFocusMovementMessage(Message* msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REPORT_FOCUS_MOVEMENT
|
#if REPORT_FOCUS_MOVEMENT
|
||||||
// Print list of widgets
|
// Print list of widgets
|
||||||
for (int i=c; i<count-1; ++i) {
|
for (int i=c; i<count-1; ++i) {
|
||||||
TRACE("list[%d] = %d (%s)\n",
|
TRACE("list[%d] = %d (%s)\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user