Skip to content

Commit

Permalink
LibGUI: Get rid of GWindow::should_exit_event_loop_on_close().
Browse files Browse the repository at this point in the history
This behavior and API was extremely counter-intuitive since our default
behavior was for applications to never exit after you close all of their
windows.

Now that we exit the event loop by default when the very last GWindow is
deleted, we don't have to worry about this.
  • Loading branch information
awesomekling committed Jul 23, 2019
1 parent fbae03b commit 72a3f69
Show file tree
Hide file tree
Showing 19 changed files with 8 additions and 27 deletions.
1 change: 0 additions & 1 deletion Applications/About/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ int main(int argc, char** argv)
window_rect.center_within(GDesktop::the().rect());
window->set_resizable(false);
window->set_rect(window_rect);
window->set_should_exit_event_loop_on_close(true);

auto* widget = new GWidget;
window->set_main_widget(widget);
Expand Down
1 change: 0 additions & 1 deletion Applications/FileManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("File Manager");
window->set_rect(20, 200, 640, 480);
window->set_should_exit_event_loop_on_close(true);

auto* widget = new GWidget;
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
Expand Down
1 change: 0 additions & 1 deletion Applications/FontEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ int main(int argc, char** argv)
window->set_rect({ 50, 50, 390, 342 });
auto* font_editor = new FontEditorWidget(path, move(edited_font));
window->set_main_widget(font_editor);
window->set_should_exit_event_loop_on_close(true);
window->show();
window->set_icon_path("/res/icons/16x16/app-font-editor.png");
return app.exec();
Expand Down
1 change: 0 additions & 1 deletion Applications/IRCClient/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ int main(int argc, char** argv)
GApplication app(argc, argv);

IRCAppWindow app_window;
app_window.set_should_exit_event_loop_on_close(true);
app_window.show();

printf("Entering main loop...\n");
Expand Down
1 change: 0 additions & 1 deletion Applications/Launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ int main(int argc, char** argv)
signal(SIGCHLD, handle_sigchld);

auto* launcher_window = make_launcher_window();
launcher_window->set_should_exit_event_loop_on_close(true);
launcher_window->show();

return app.exec();
Expand Down
1 change: 0 additions & 1 deletion Applications/PaintBrush/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("PaintBrush");
window->set_rect(100, 100, 640, 480);
window->set_should_exit_event_loop_on_close(true);

auto* horizontal_container = new GWidget(nullptr);
window->set_main_widget(horizontal_container);
Expand Down
1 change: 0 additions & 1 deletion Applications/Piano/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("Piano");
window->set_rect(100, 100, 512, 512);
window->set_should_exit_event_loop_on_close(true);

auto* piano_widget = new PianoWidget;
window->set_main_widget(piano_widget);
Expand Down
4 changes: 2 additions & 2 deletions Applications/ProcessManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int main(int argc, char** argv)
process_context_menu->add_action(stop_action);
process_context_menu->add_action(continue_action);
process_table_view->on_context_menu_request = [&](const GModelIndex& index, const GContextMenuEvent& event) {
(void) index;
(void)index;
process_context_menu->popup(event.screen_position());
};

Expand Down Expand Up @@ -153,7 +153,7 @@ int main(int argc, char** argv)
window->set_title("Process Manager");
window->set_rect(20, 200, 680, 400);
window->set_main_widget(keeper);
window->set_should_exit_event_loop_on_close(true);

window->show();

window->set_icon_path("/res/icons/16x16/app-process-manager.png");
Expand Down
3 changes: 1 addition & 2 deletions Applications/QuickShow/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "QSWidget.h"
#include <LibDraw/PNGLoader.h>
#include <LibGUI/GAction.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GMenu.h>
#include <LibGUI/GMenuBar.h>
#include <LibGUI/GWindow.h>
#include <LibDraw/PNGLoader.h>
#include <stdio.h>

int main(int argc, char** argv)
Expand Down Expand Up @@ -67,7 +67,6 @@ int main(int argc, char** argv)
widget->set_bitmap(*bitmap);
window->set_main_widget(widget);

window->set_should_exit_event_loop_on_close(true);
window->show();

return app.exec();
Expand Down
1 change: 0 additions & 1 deletion Applications/Taskbar/TaskbarWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ TaskbarWindow::TaskbarWindow()
{
set_window_type(GWindowType::Taskbar);
set_title("Taskbar");
set_should_exit_event_loop_on_close(true);

on_screen_rect_change(GDesktop::the().rect());

Expand Down
1 change: 0 additions & 1 deletion Applications/Terminal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ int main(int argc, char** argv)
window->set_title("Terminal");
window->set_background_color(Color::Black);
window->set_double_buffering_enabled(false);
window->set_should_exit_event_loop_on_close(true);

RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
Terminal terminal(ptm_fd, config);
Expand Down
3 changes: 1 addition & 2 deletions Applications/TextEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("Text Editor");
window->set_rect(20, 200, 640, 400);
window->set_should_exit_event_loop_on_close(true);

auto* text_widget = new TextEditorWidget();
window->set_main_widget(text_widget);
Expand All @@ -19,4 +18,4 @@ int main(int argc, char** argv)
window->set_icon_path("/res/icons/TextEditor16.png");

return app.exec();
}
}
3 changes: 1 addition & 2 deletions Demos/Fire/Fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* [ ] handle fire bitmap edges better
*/

#include <LibDraw/GraphicsBitmap.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GPainter.h>
#include <LibGUI/GWidget.h>
#include <LibGUI/GWindow.h>
#include <LibDraw/GraphicsBitmap.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Expand Down Expand Up @@ -214,7 +214,6 @@ int main(int argc, char** argv)
GApplication app(argc, argv);

auto* window = new GWindow;
window->set_should_exit_event_loop_on_close(true);
window->set_double_buffering_enabled(false);
window->set_title("Fire");
window->set_resizable(false);
Expand Down
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char** argv)
window->set_title(form1->name());
window->set_rect(120, 200, 640, 400);
window->set_main_widget(form1);
window->set_should_exit_event_loop_on_close(true);

window->show();

auto* toolbox = make_toolbox_window();
Expand Down
1 change: 0 additions & 1 deletion Games/Minesweeper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main(int argc, char** argv)
GApplication app(argc, argv);

auto* window = new GWindow;
window->set_should_exit_event_loop_on_close(true);
window->set_resizable(false);
window->set_title("Minesweeper");
window->set_rect(100, 100, 139, 175);
Expand Down
2 changes: 1 addition & 1 deletion Games/Snake/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char** argv)
GApplication app(argc, argv);

auto* window = new GWindow;
window->set_should_exit_event_loop_on_close(true);

window->set_double_buffering_enabled(false);
window->set_title("Snake");
window->set_rect(100, 100, 320, 320);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GDialog::GDialog(CObject* parent)
: GWindow(parent)
{
set_modal(true);
set_should_exit_event_loop_on_close(true);

}

GDialog::~GDialog()
Expand Down
2 changes: 0 additions & 2 deletions Libraries/LibGUI/GWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ GWindow::~GWindow()

void GWindow::close()
{
if (should_exit_event_loop_on_close())
GEventLoop::current().quit(0);
if (should_destroy_on_close())
delete_later();
}
Expand Down
4 changes: 0 additions & 4 deletions Libraries/LibGUI/GWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class GWindow : public CObject {
GWidget* automatic_cursor_tracking_widget() { return m_automatic_cursor_tracking_widget.ptr(); }
const GWidget* automatic_cursor_tracking_widget() const { return m_automatic_cursor_tracking_widget.ptr(); }

bool should_exit_event_loop_on_close() const { return m_should_exit_app_on_close; }
void set_should_exit_event_loop_on_close(bool b) { m_should_exit_app_on_close = b; }

GWidget* hovered_widget() { return m_hovered_widget.ptr(); }
const GWidget* hovered_widget() const { return m_hovered_widget.ptr(); }
void set_hovered_widget(GWidget*);
Expand Down Expand Up @@ -160,7 +157,6 @@ class GWindow : public CObject {
Color m_background_color { Color::WarmGray };
GWindowType m_window_type { GWindowType::Normal };
bool m_is_active { false };
bool m_should_exit_app_on_close { false };
bool m_destroy_on_close { true };
bool m_has_alpha_channel { false };
bool m_double_buffering_enabled { true };
Expand Down

0 comments on commit 72a3f69

Please sign in to comment.