mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:12:44 +00:00 
			
		
		
		
	Move windowing stuff from AbstractScreen to WindowManager.
This commit is contained in:
		
							parent
							
								
									415c4b90c5
								
							
						
					
					
						commit
						02f4d6ef8e
					
				
					 6 changed files with 59 additions and 58 deletions
				
			
		|  | @ -3,12 +3,9 @@ | |||
| #include "Event.h" | ||||
| #include "Widget.h" | ||||
| #include <AK/Assertions.h> | ||||
| #include "TerminalWidget.h" | ||||
| 
 | ||||
| static AbstractScreen* s_the; | ||||
| 
 | ||||
| extern TerminalWidget* g_tw; | ||||
| 
 | ||||
| AbstractScreen& AbstractScreen::the() | ||||
| { | ||||
|     ASSERT(s_the); | ||||
|  | @ -28,35 +25,3 @@ AbstractScreen::~AbstractScreen() | |||
| { | ||||
| } | ||||
| 
 | ||||
| void AbstractScreen::event(Event& event) | ||||
| { | ||||
|     if (event.type() == Event::MouseMove | ||||
|         || event.type() == Event::MouseDown | ||||
|         || event.type() == Event::MouseUp) { | ||||
|         auto& me = static_cast<MouseEvent&>(event); | ||||
|         //printf("AbstractScreen::onMouseMove: %d, %d\n", me.x(), me.y());
 | ||||
|         auto result = m_rootWidget->hitTest(me.x(), me.y()); | ||||
|         //printf("hit test for %d,%d found: %s{%p} %d,%d\n", me.x(), me.y(), result.widget->className(), result.widget, result.localX, result.localY);
 | ||||
|         auto localEvent = make<MouseEvent>(event.type(), result.localX, result.localY, me.button()); | ||||
|         result.widget->event(*localEvent); | ||||
|         return Object::event(event); | ||||
|     } | ||||
| 
 | ||||
|     if (event.type() == Event::KeyDown || event.type() == Event::KeyUp) { | ||||
|         // FIXME: Implement proper focus.
 | ||||
|         Widget* focusedWidget = g_tw; | ||||
|         return focusedWidget->event(event); | ||||
|     } | ||||
| 
 | ||||
|     return Object::event(event); | ||||
| } | ||||
| 
 | ||||
| void AbstractScreen::setRootWidget(Widget* widget) | ||||
| { | ||||
|     // FIXME: Should we support switching root widgets?
 | ||||
|     ASSERT(!m_rootWidget); | ||||
|     ASSERT(widget); | ||||
|      | ||||
|     m_rootWidget = widget; | ||||
|     EventLoop::main().postEvent(m_rootWidget, make<ShowEvent>()); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling