Skip to content

Commit

Permalink
One connection to LemonWM per process (not per window)
Browse files Browse the repository at this point in the history
  • Loading branch information
fido2020 committed Jul 4, 2021
1 parent 46383fe commit 48d4029
Show file tree
Hide file tree
Showing 31 changed files with 386 additions and 290 deletions.
4 changes: 3 additions & 1 deletion Applications/DeviceManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ int main(int argc, char** argv){
lv->SetModel(&model);

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
}

window->Paint();
window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

return 0;
Expand Down
5 changes: 3 additions & 2 deletions Applications/FileManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ int main(int argc, char** argv){
fv->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::WidgetAlignment::WAlignLeft);

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
}

window->Paint();

window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

delete window;
Expand Down
5 changes: 3 additions & 2 deletions Applications/GUITest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ int main(){
cxt.push_back(ent);

while(!win->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(win->PollEvent(ev)){
win->GUIHandleEvent(ev);
}

win->Paint();

win->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

delete win;
Expand Down
21 changes: 12 additions & 9 deletions Applications/ImgView/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,11 @@ void OnWindowCmd(unsigned short cmd, Lemon::GUI::Window* win){
}

int main(int argc, char** argv){
window = new Lemon::GUI::Window("Image Viewer", {800, 500}, WINDOW_FLAGS_RESIZABLE, Lemon::GUI::WindowType::GUI);
window->CreateMenuBar();

window->menuBar->items.push_back(fileMenu);
window->menuBar->items.push_back(viewMenu);
window->OnMenuCmd = OnWindowCmd;

imgWidget = new Lemon::GUI::Image({{0, 0}, {0, 0}});
imgWidget->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch);
imgWidget->SetScaling(Lemon::Graphics::Texture::TextureScaling::ScaleFit);

window->AddWidget(imgWidget);

if(argc > 1){
if(LoadImage(argv[1])){
return -1;
Expand All @@ -76,13 +68,24 @@ int main(int argc, char** argv){
return -1;
}

window = new Lemon::GUI::Window("Image Viewer", {800, 500}, WINDOW_FLAGS_RESIZABLE, Lemon::GUI::WindowType::GUI);
window->CreateMenuBar();

window->menuBar->items.push_back(fileMenu);
window->menuBar->items.push_back(viewMenu);
window->OnMenuCmd = OnWindowCmd;

window->AddWidget(imgWidget);

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
}

window->Paint();
window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}
}
6 changes: 3 additions & 3 deletions Applications/LemonMonitor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ int main(int argc, char** argv){
paint = true; // Refresh processes every 800ms
}

Lemon::WindowServer::Instance()->Poll();
Lemon::LemonEvent ev;

while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);

Expand All @@ -147,8 +147,8 @@ int main(int argc, char** argv){
if(paint){
window->Paint();
}

window->WaitEvent(800000); // Wait up to 800ms
Lemon::WindowServer::Instance()->Wait(800000);
}

return 0;
Expand Down
5 changes: 3 additions & 2 deletions Applications/Minesweeper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ int main(int argc, char** argv){
window->Paint();

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while (window->PollEvent(ev))
{
Expand All @@ -308,8 +310,7 @@ int main(int argc, char** argv){
}

window->Paint();

window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

delete window;
Expand Down
4 changes: 3 additions & 1 deletion Applications/Run/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ int main(int argc, char** argv){
window->AddWidget(okButton);

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
}

window->Paint();
window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

return 0;
Expand Down
8 changes: 6 additions & 2 deletions Applications/Shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ void OnTaskbarPaint(surface_t* surface){
}

int main(){
if(chdir("/system")){
return 1;
}

handle_t svc = Lemon::CreateService("lemon.shell");
shell = new ShellInstance(svc, "Instance");

Expand Down Expand Up @@ -134,10 +138,10 @@ int main(){

Lemon::Waiter waiter;
waiter.WaitOnAll(&shell->GetInterface());
waiter.WaitOn(taskbar);
waiter.WaitOn(menuWindow);
waiter.WaitOn(Lemon::WindowServer::Instance());

for(;;){
Lemon::WindowServer::Instance()->Poll();
shell->Poll();

Lemon::LemonEvent ev;
Expand Down
10 changes: 7 additions & 3 deletions Applications/Shell/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,21 @@ Lemon::GUI::Window* InitializeMenu(){

menuWindow = new Lemon::GUI::Window("", {MENU_WIDTH, MENU_HEIGHT}, WINDOW_FLAGS_NODECORATION | WINDOW_FLAGS_NOSHELL | WINDOW_FLAGS_ALWAYS_ACTIVE, Lemon::GUI::GUI);

vector2i_t screenBounds = menuWindow->GetScreenBounds();
vector2i_t screenBounds = Lemon::WindowServer::Instance()->GetScreenBounds();
menuWindow->Relocate({ screenBounds.x / 2 - 200, screenBounds.y / 2 - 150 });

listView = new Lemon::GUI::ListView({0, 0, 0, 24});
menuWindow->AddWidget(listView);
listView->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::WidgetAlignment::WAlignLeft, Lemon::GUI::WidgetAlignment::WAlignBottom);
listView->SetModel(&menuModel);
listView->displayColumnNames = false;
listView->drawBackground = false;

filterBox = new Lemon::GUI::TextBox({0, 0, 0, 24}, false);

menuWindow->AddWidget(listView);
menuWindow->AddWidget(filterBox);
menuWindow->SetActive(filterBox);

listView->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::WidgetAlignment::WAlignLeft, Lemon::GUI::WidgetAlignment::WAlignBottom);
filterBox->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::WidgetAlignment::WAlignLeft, Lemon::GUI::WidgetAlignment::WAlignTop);

const char* itemsPath = "/system/lemon/menu/";
Expand Down
6 changes: 6 additions & 0 deletions Applications/Snake/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void GameOverLoop(){
win->SwapBuffers();

while(!win->closed && gameOver){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(win->PollEvent(ev)){
if(ev.event == Lemon::EventKeyPressed){
Expand All @@ -50,6 +52,8 @@ void GameOverLoop(){
exit(0);
}
}

Lemon::WindowServer::Instance()->Wait();
}
}

Expand Down Expand Up @@ -86,6 +90,8 @@ int main(){
Reset();

while(!win->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(win->PollEvent(ev)){
if(ev.event == Lemon::EventKeyPressed){
Expand Down
4 changes: 3 additions & 1 deletion Applications/SysInfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ int main(int argc, char** argv){
ypos += 16;

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
Expand All @@ -64,6 +66,6 @@ int main(int argc, char** argv){
usedMem->label = buf;
} sysInfo = _sysInfo;

window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}
}
4 changes: 3 additions & 1 deletion Applications/Terminal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ int main(int argc, char** argv){
}

for(;;){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
if(ev.event == Lemon::EventKeyPressed){
Expand Down Expand Up @@ -640,7 +642,7 @@ int main(int argc, char** argv){
paintAll = false;
}

window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

return 0;
Expand Down
5 changes: 3 additions & 2 deletions Applications/TextEdit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ int main(int argc, char** argv){
}

while(!window->closed){
Lemon::WindowServer::Instance()->Poll();

Lemon::LemonEvent ev;
while(window->PollEvent(ev)){
window->GUIHandleEvent(ev);
}

window->Paint();

window->WaitEvent();
Lemon::WindowServer::Instance()->Wait();
}

delete window;
Expand Down
1 change: 1 addition & 0 deletions LibGUI/include/Lemon/GUI/Widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ namespace Lemon::GUI {

int selected = 0;
bool displayColumnNames = true;
bool drawBackground = true;

protected:
DataModel* model = nullptr;
Expand Down
Loading

0 comments on commit 48d4029

Please sign in to comment.