MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Poll

Method Poll

System/LemonWM/wm.cpp:102–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void WMInstance::Poll(){
103 Lemon::Message m;
104 handle_t client;
105
106 while(server.Poll(client, m)){
107 if(client > 0){
108 auto cmd = m.id();
109
110 if(cmd == Lemon::MessagePeerDisconnect){
111 WMWindow* win = FindWindow(client);
112
113 if(!win){
114 continue;
115 }
116
117 if(active == win){
118 SetActive(nullptr);
119 }
120
121 if(shellConnected && !(win->flags & WINDOW_FLAGS_NOSHELL)){
122 Lemon::Shell::RemoveWindow(client, shellClient);
123 }
124
125 windows.remove(win);
126 redrawBackground = true;
127
128 delete win;
129 } else if(cmd == Lemon::GUI::WMCreateWindow){
130 int x = 0;
131 int y = 0;
132 int width = 0;
133 int height = 0;
134 unsigned int flags;
135 std::string title;
136
137 if(m.Decode(x, y, width, height, flags, title)){
138 printf("[LemonWM] WMCreateWindow: Invalid msg\n");
139 continue; // Invalid or corrupted message, just ignore
140 }
141
142 printf("[LemonWM] Creating Window: Pos: (%d, %d), Size: %dx%d, Title: %s\n", x,y, width, height, title.c_str());
143
144 WindowBuffer* wBufferInfo = nullptr;
145 int64_t wBufferKey = CreateWindowBuffer(width, height, &wBufferInfo);
146 if(wBufferKey <= 0 || !wBufferInfo){
147 continue; // Error obtaining window buffer shared memory
148 }
149
150 WMWindow* win = new WMWindow(this, client, client, wBufferKey, wBufferInfo, {x,y}, {width, height}, flags, title);
151 win->RecalculateButtonRects();
152
153 windows.push_back(win);
154
155 if(shellConnected && !(win->flags & WINDOW_FLAGS_NOSHELL)){
156 Lemon::Shell::AddWindow(client, Lemon::Shell::ShellWindowState::ShellWindowStateNormal, title, shellClient);
157 }
158 SetActive(win);
159

Callers 2

UpdateMethod · 0.45
PollCommandsMethod · 0.45

Calls 9

ContextMenuItemClass · 0.85
idMethod · 0.80
DecodeMethod · 0.80
RemoveWindowFunction · 0.50
AddWindowFunction · 0.50
removeMethod · 0.45
ResizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected