A new debugger.
Lots of bugs/rough edges/etc - issues will be filed. Old-style debugging still works (just use --emit_source_annotations to get the helpful movs back and --break_on_instruction will still fire).
This commit is contained in:
@@ -39,6 +39,11 @@ Loop::~Loop() {
|
||||
}
|
||||
|
||||
void Loop::PostSynchronous(std::function<void()> fn) {
|
||||
if (is_on_loop_thread()) {
|
||||
// Prevent deadlock if we are executing on ourselves.
|
||||
fn();
|
||||
return;
|
||||
}
|
||||
xe::threading::Fence fence;
|
||||
Post([&fn, &fence]() {
|
||||
fn();
|
||||
|
||||
@@ -31,6 +31,9 @@ class Loop {
|
||||
Loop();
|
||||
virtual ~Loop();
|
||||
|
||||
// Returns true if the currently executing code is within the loop thread.
|
||||
virtual bool is_on_loop_thread() = 0;
|
||||
|
||||
virtual void Post(std::function<void()> fn) = 0;
|
||||
virtual void PostDelayed(std::function<void()> fn, uint64_t delay_millis) = 0;
|
||||
void PostSynchronous(std::function<void()> fn);
|
||||
|
||||
@@ -87,6 +87,10 @@ void Win32Loop::ThreadMain() {
|
||||
on_quit(&e);
|
||||
}
|
||||
|
||||
bool Win32Loop::is_on_loop_thread() {
|
||||
return thread_id_ == GetCurrentThreadId();
|
||||
}
|
||||
|
||||
void Win32Loop::Post(std::function<void()> fn) {
|
||||
assert_true(thread_id_ != 0);
|
||||
if (!PostThreadMessage(
|
||||
|
||||
@@ -26,6 +26,8 @@ class Win32Loop : public Loop {
|
||||
Win32Loop();
|
||||
~Win32Loop() override;
|
||||
|
||||
bool is_on_loop_thread() override;
|
||||
|
||||
void Post(std::function<void()> fn) override;
|
||||
void PostDelayed(std::function<void()> fn, uint64_t delay_millis) override;
|
||||
|
||||
|
||||
@@ -493,6 +493,7 @@ void Window::OnKeyUp(KeyEvent* e) {
|
||||
|
||||
void Window::OnKeyChar(KeyEvent* e) {
|
||||
OnKeyPress(e, true, true);
|
||||
on_key_char(e);
|
||||
OnKeyPress(e, false, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,6 +320,10 @@ LRESULT CALLBACK Win32Window::WndProcThunk(HWND hWnd, UINT message,
|
||||
|
||||
LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
if (hWnd != hwnd_) {
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
if (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) {
|
||||
if (HandleMouse(message, wParam, lParam)) {
|
||||
return 0;
|
||||
@@ -328,7 +332,6 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
}
|
||||
} else if (message >= WM_KEYFIRST && message <= WM_KEYLAST) {
|
||||
if (HandleKeyboard(message, wParam, lParam)) {
|
||||
SetFocus(hwnd_);
|
||||
return 0;
|
||||
} else {
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
@@ -363,10 +366,14 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
|
||||
case WM_PAINT: {
|
||||
ValidateRect(hwnd_, nullptr);
|
||||
auto e = UIEvent(this);
|
||||
OnPaint(&e);
|
||||
static bool in_paint = false;
|
||||
if (!in_paint) {
|
||||
in_paint = true;
|
||||
auto e = UIEvent(this);
|
||||
OnPaint(&e);
|
||||
in_paint = false;
|
||||
}
|
||||
return 0; // Ignored because of custom paint.
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
return 0; // Ignored because of custom paint.
|
||||
|
||||
Reference in New Issue
Block a user