[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev54597 - src/apps/firstbootprompt
From:       Adrien Destugues <pulkomandy () gmail ! com>
Date:       2020-09-24 19:43:28
Message-ID: 20200924194328.05E2022E72 () turing ! freelists ! org
[Download RAW message or body]

hrev54597 adds 1 changeset to branch 'master'
old head: da30d8fafc1344ace87a351062e744232e9d67b2
new head: 64ab6cf0db6a070fb19831bc091537b19f9e39a5
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=64ab6cf0db6a+%5Eda30d8fafc13

----------------------------------------------------------------------------

64ab6cf0db6a: FirstBootPrompt: even more fixes
  
  The previous code tried to add a boolean to the quit requested message,
  but that is not propagated from the app to the window QuitRequested, so
  it didn't work. Instead, split the task between the app and the window'
  QuitRequested functions.

                             [ Adrien Destugues <pulkomandy@pulkomandy.tk> ]

----------------------------------------------------------------------------

Revision:    hrev54597
Commit:      64ab6cf0db6a070fb19831bc091537b19f9e39a5
URL:         https://git.haiku-os.org/haiku/commit/?id=64ab6cf0db6a
Author:      Adrien Destugues <pulkomandy@pulkomandy.tk>
Date:        Thu Sep 24 19:34:29 2020 UTC

----------------------------------------------------------------------------

3 files changed, 43 insertions(+), 51 deletions(-)
src/apps/firstbootprompt/BootPrompt.cpp       | 19 ++++--
src/apps/firstbootprompt/BootPrompt.h         |  1 +
src/apps/firstbootprompt/BootPromptWindow.cpp | 74 +++++++++--------------

----------------------------------------------------------------------------

diff --git a/src/apps/firstbootprompt/BootPrompt.cpp \
b/src/apps/firstbootprompt/BootPrompt.cpp index 9352123294..25a6cd3dbd 100644
--- a/src/apps/firstbootprompt/BootPrompt.cpp
+++ b/src/apps/firstbootprompt/BootPrompt.cpp
@@ -63,9 +63,7 @@ BootPromptApp::MessageReceived(BMessage* message)
 			BLaunchRoster().Target("desktop");
 			sExitValue = 1;
 
-			BMessage* newMessage = new BMessage(B_QUIT_REQUESTED);
-			newMessage->AddBool("dont_reboot", true);
-			PostMessage(newMessage);
+			PostMessage(B_QUIT_REQUESTED);
 			break;
 		}
 		case MSG_RUN_INSTALLER:
@@ -73,9 +71,7 @@ BootPromptApp::MessageReceived(BMessage* message)
 			BLaunchRoster().Target("installer");
 			sExitValue = 0;
 
-			BMessage* newMessage = new BMessage(B_QUIT_REQUESTED);
-			newMessage->AddBool("dont_reboot", true);
-			PostMessage(newMessage);
+			PostMessage(B_QUIT_REQUESTED);
 			break;
 		}
 		case MSG_REBOOT_REQUESTED:
@@ -98,3 +94,14 @@ BootPromptApp::ReadyToRun()
 	new BootPromptWindow();
 }
 
+
+bool
+BootPromptApp::QuitRequested()
+{
+	// Override the default QuitRequested because we don't want to ask the
+	// window. The window QuitRequested is used when closing the window, and
+	// offers to reboot the system. When we get here, it means we got the
+	// message from one of the Desktop/Installer buttons and we should just
+	// exit.
+	return true;
+}
diff --git a/src/apps/firstbootprompt/BootPrompt.h \
b/src/apps/firstbootprompt/BootPrompt.h index c479c90a39..aed7ff03be 100644
--- a/src/apps/firstbootprompt/BootPrompt.h
+++ b/src/apps/firstbootprompt/BootPrompt.h
@@ -25,6 +25,7 @@ public:
 								BootPromptApp();
 
 	virtual	void				MessageReceived(BMessage* message);
+			bool				QuitRequested();
 	virtual	void				ReadyToRun();
 };
 
diff --git a/src/apps/firstbootprompt/BootPromptWindow.cpp \
b/src/apps/firstbootprompt/BootPromptWindow.cpp index 6869233a53..1e2fd1ebe3 100644
--- a/src/apps/firstbootprompt/BootPromptWindow.cpp
+++ b/src/apps/firstbootprompt/BootPromptWindow.cpp
@@ -136,7 +136,8 @@ BootPromptWindow::BootPromptWindow()
 	:
 	BWindow(BRect(0, 0, 530, 400), "",
 		B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
-			| B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES),
+			| B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE,
+		B_ALL_WORKSPACES),
 	fDefaultKeymapItem(NULL)
 {
 	SetSizeLimits(450, 16384, 350, 16384);
@@ -251,13 +252,6 @@ BootPromptWindow::BootPromptWindow()
 	fInfoTextView->SetText("x\n\n\n\n\n\n\n\n\n\n\n\n\n\nx");
 	ResizeToPreferred();
 
-	// Minimizing will not be possible, unless if the user is
-	// able to bring the window back up. That means that the
-	// Desktop must be running, in order for the window to be
-	// minimizable.
-	if (!be_roster->IsRunning(kDeskbarSignature))
-		SetFlags(Flags() | B_NOT_MINIMIZABLE);
-
 	_UpdateStrings();
 	CenterOnScreen();
 	Show();
@@ -305,46 +299,36 @@ BootPromptWindow::MessageReceived(BMessage* message)
 bool
 BootPromptWindow::QuitRequested()
 {
-	BMessage* message = CurrentMessage();
-	bool dont_reboot = false;
-
-	if (message != NULL)
-		dont_reboot = message->GetBool("dont_reboot");
-
-	if (!be_roster->IsRunning(kDeskbarSignature) && !dont_reboot)
-	{
-		// If the Deskbar is not running, then FirstBootPrompt is
-		// is the only thing visible on the screen and that we won't
-		// have anything else to show. In that case, it would make
-		// sense to reboot the machine instead, but doing so without
-		// a warning could be confusing.
-		//
-		// Rebooting is managed by BootPrompt.cpp.
-
-		BAlert* alert = new(std::nothrow) BAlert(
-			B_TRANSLATE_SYSTEM_NAME("Quit Haiku"),
-			B_TRANSLATE("Are you sure you want to close this window? This will "
-				"restart your system!"),
-			B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL,
-			B_WIDTH_AS_USUAL, B_STOP_ALERT);
-		// If there is not enough memory to create the alert here, we may as
-		// well try to reboot. There probably isn't much else to do anyway.
-		if (alert != NULL) {
-			alert->SetShortcut(0, B_ESCAPE);
-
-			if (alert->Go() == 0)
-				return false;
+	// If the Deskbar is not running, then FirstBootPrompt is
+	// is the only thing visible on the screen and that we won't
+	// have anything else to show. In that case, it would make
+	// sense to reboot the machine instead, but doing so without
+	// a warning could be confusing.
+	//
+	// Rebooting is managed by BootPrompt.cpp.
+
+	BAlert* alert = new(std::nothrow) BAlert(
+		B_TRANSLATE_SYSTEM_NAME("Quit Haiku"),
+		B_TRANSLATE("Are you sure you want to close this window? This will "
+			"restart your system!"),
+		B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL,
+		B_WIDTH_AS_USUAL, B_STOP_ALERT);
+
+	// If there is not enough memory to create the alert here, we may as
+	// well try to reboot. There probably isn't much else to do anyway.
+	if (alert != NULL) {
+		alert->SetShortcut(0, B_ESCAPE);
+
+		if (alert->Go() == 0) {
+			// User doesn't want to exit after all
+			return false;
 		}
+	}
 
+	// If deskbar is running, don't actually reboot: we are in test mode
+	// (probably run by a developer manually).
+	if (!be_roster->IsRunning(kDeskbarSignature))
 		be_app->PostMessage(MSG_REBOOT_REQUESTED);
-		// Don't quit, instead let the app run and handle the reboot request
-		return false;
-	} else {
-		// The aforementioned warning is only shown if the condition
-		// is true, because if FirstBootPrompt is running on the Desktop,
-		// the system will not reboot upon closing the window.
-		be_app->PostMessage(B_QUIT_REQUESTED);
-	}
 
 	return true;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic