| 19 | |
| 20 | extern bool paintTaskbar; |
| 21 | void ShellInstance::PollCommands(){ |
| 22 | handle_t client; |
| 23 | Lemon::Message m; |
| 24 | while(shellSrv.Poll(client, m)){ |
| 25 | paintTaskbar = true; |
| 26 | if(m.id() == Lemon::MessagePeerDisconnect){ // Disconnected |
| 27 | continue; |
| 28 | } |
| 29 | |
| 30 | switch (m.id()) |
| 31 | { |
| 32 | case Lemon::Shell::LemonShellAddWindow: |
| 33 | { |
| 34 | std::string title; |
| 35 | short state; |
| 36 | long id; |
| 37 | if(m.Decode(id, state, title)){ |
| 38 | continue; // Invalid message |
| 39 | } |
| 40 | |
| 41 | ShellWindow* win = new ShellWindow(); |
| 42 | |
| 43 | win->id = id; |
| 44 | win->state = state; |
| 45 | win->title = title; |
| 46 | |
| 47 | windows.insert(std::pair<long, ShellWindow*>(id, win)); |
| 48 | |
| 49 | if(AddWindow) AddWindow(win); |
| 50 | |
| 51 | if(win->state == Lemon::Shell::ShellWindowStateActive){ |
| 52 | if(active && active != win){ |
| 53 | active->state = Lemon::Shell::ShellWindowStateNormal; |
| 54 | } |
| 55 | |
| 56 | active = win; |
| 57 | } |
| 58 | } |
| 59 | break; |
| 60 | case Lemon::Shell::LemonShellRemoveWindow: { |
| 61 | long id; |
| 62 | if(m.Decode(id)){ |
| 63 | continue; // Invalid message |
| 64 | } |
| 65 | |
| 66 | ShellWindow* win; |
| 67 | try{ |
| 68 | win = windows.at(id); |
| 69 | } catch (const std::out_of_range& e){ |
| 70 | printf("[Shell] Warning: LemonShellSetActive: Window ID out of range\n"); |
| 71 | break; |
| 72 | } |
| 73 | |
| 74 | if(RemoveWindow) RemoveWindow(win); |
| 75 | |
| 76 | windows.erase(id); |
| 77 | break; |
| 78 | } case Lemon::Shell::LemonShellToggleMenu: |