mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-26 02:52:35 +00:00 
			
		
		
		
	 fc5cab5c21
			
		
	
	
		fc5cab5c21
		
	
	
	
	
		
			
			This is easily identifiable by anyone who uses Duration::now_monotonic, and any downstream users of that data.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			969 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			969 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Jelle Raaijmakers <jelle@gmta.nl>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Error.h>
 | |
| #include <AK/Function.h>
 | |
| #include <AK/NonnullRefPtr.h>
 | |
| #include <AK/Optional.h>
 | |
| #include <AK/Time.h>
 | |
| #include <LibGUI/Widget.h>
 | |
| #include <LibGUI/Window.h>
 | |
| #include <LibGfx/Point.h>
 | |
| 
 | |
| namespace Desktop {
 | |
| 
 | |
| class Screensaver : public GUI::Widget {
 | |
|     C_OBJECT_ABSTRACT(Screensaver)
 | |
| public:
 | |
|     Function<void()> on_screensaver_exit;
 | |
| 
 | |
|     static ErrorOr<NonnullRefPtr<GUI::Window>> create_window(StringView title, StringView icon);
 | |
| 
 | |
|     virtual void keydown_event(GUI::KeyEvent&) override;
 | |
|     virtual void mousedown_event(GUI::MouseEvent& event) override;
 | |
|     virtual void mousemove_event(GUI::MouseEvent& event) override;
 | |
| 
 | |
| protected:
 | |
|     Screensaver()
 | |
|         : m_start_time(MonotonicTime::now())
 | |
|     {
 | |
|     }
 | |
| 
 | |
| private:
 | |
|     void trigger_exit();
 | |
| 
 | |
|     Optional<Gfx::IntPoint> m_mouse_origin;
 | |
|     MonotonicTime m_start_time;
 | |
| };
 | |
| 
 | |
| }
 |