移除Window::input_event,减少一次传递

This commit is contained in:
2025-07-03 10:24:30 +08:00
parent b6cf73deca
commit bc5623e462
3 changed files with 3 additions and 16 deletions

View File

@@ -1,5 +1,4 @@
#ifndef HGL_GRAPH_WINDOW_INCLUDE #pragma once
#define HGL_GRAPH_WINDOW_INCLUDE
#include<hgl/type/String.h> #include<hgl/type/String.h>
#include<hgl/io/event/WindowEvent.h> #include<hgl/io/event/WindowEvent.h>
@@ -21,14 +20,6 @@ namespace hgl
protected: protected:
/**
* 外部输入事件<br>
* 比如Windows平台是由WindowProc函数传递过来的。
* 本事件传递器会呼叫io::WindowEvent的对象指针在本类中指向的是自己。<br>
* 注仅当前类会如此设计本身此Event是要放在外面的不该在此级别。
*/
io::EventDispatch input_event;
void OnResize(uint,uint) override; void OnResize(uint,uint) override;
void OnActive(bool) override; void OnActive(bool) override;
void OnClose () override; void OnClose () override;
@@ -71,4 +62,3 @@ namespace hgl
void InitNativeWindowSystem(); void InitNativeWindowSystem();
}//namespace hgl }//namespace hgl
#endif//HGL_GRAPH_WINDOW_INCLUDE

View File

@@ -83,7 +83,7 @@ namespace hgl
} }
win_dc = GetDC(win_hwnd); win_dc = GetDC(win_hwnd);
SetWindowLongPtrW(win_hwnd, GWLP_USERDATA, (LONG_PTR)&input_event); SetWindowLongPtrW(win_hwnd, GWLP_USERDATA, (LONG_PTR)this);
return(true); return(true);
} }

View File

@@ -10,8 +10,6 @@ namespace hgl
active=false; active=false;
is_close=true; is_close=true;
is_min=false; is_min=false;
input_event.RegisterEventDispatch(this);
} }
void Window::OnResize(uint w,uint h) void Window::OnResize(uint w,uint h)
@@ -39,7 +37,6 @@ namespace hgl
void Window::OnClose() void Window::OnClose()
{ {
input_event.UnregisterEventDispatch(this);
is_close=true; is_close=true;
} }