| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  | #include <LibGUI/GDesktop.h>
 | 
					
						
							|  |  |  | #include <LibGUI/GEventLoop.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-03 17:22:14 +02:00
										 |  |  | #include <unistd.h>
 | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | GDesktop& GDesktop::the() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-05 05:10:18 +02:00
										 |  |  |     static GDesktop* the; | 
					
						
							|  |  |  |     if (!the) | 
					
						
							|  |  |  |         the = new GDesktop; | 
					
						
							|  |  |  |     return *the; | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GDesktop::GDesktop() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-17 18:28:30 +02:00
										 |  |  | void GDesktop::did_receive_screen_rect(Badge<GWindowServerConnection>, const Rect& rect) | 
					
						
							| 
									
										
										
										
											2019-04-03 17:22:14 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-03 19:38:44 +02:00
										 |  |  |     if (m_rect == rect) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2019-04-03 17:22:14 +02:00
										 |  |  |     m_rect = rect; | 
					
						
							| 
									
										
										
										
											2019-04-03 19:38:44 +02:00
										 |  |  |     if (on_rect_change) | 
					
						
							|  |  |  |         on_rect_change(rect); | 
					
						
							| 
									
										
										
										
											2019-04-03 17:22:14 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-02 14:58:02 +02:00
										 |  |  | bool GDesktop::set_wallpaper(const StringView& path) | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     WSAPI_ClientMessage message; | 
					
						
							|  |  |  |     message.type = WSAPI_ClientMessage::Type::SetWallpaper; | 
					
						
							|  |  |  |     ASSERT(path.length() < (int)sizeof(message.text)); | 
					
						
							| 
									
										
										
										
											2019-07-08 15:38:44 +02:00
										 |  |  |     strncpy(message.text, path.characters_without_null_termination(), path.length()); | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  |     message.text_length = path.length(); | 
					
						
							| 
									
										
										
										
											2019-07-17 20:57:27 +02:00
										 |  |  |     auto response = GWindowServerConnection::the().sync_request(message, WSAPI_ServerMessage::Type::DidSetWallpaper); | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  |     return response.value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String GDesktop::wallpaper() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WSAPI_ClientMessage message; | 
					
						
							|  |  |  |     message.type = WSAPI_ClientMessage::Type::GetWallpaper; | 
					
						
							| 
									
										
										
										
											2019-07-17 20:57:27 +02:00
										 |  |  |     auto response = GWindowServerConnection::the().sync_request(message, WSAPI_ServerMessage::Type::DidGetWallpaper); | 
					
						
							| 
									
										
										
										
											2019-03-21 15:54:19 +01:00
										 |  |  |     return String(response.text, response.text_length); | 
					
						
							|  |  |  | } |