From 0efb25854aaf4a3a2da429d3d1c43cf15837970b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 20 Apr 2008 16:14:53 +0000 Subject: [PATCH] - login window should be visible on all workspaces - add a DesktopWindow that can show replicants. To edit the shelf run Login --edit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25083 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/login/DesktopWindow.cpp | 92 ++++++++++++++++++++++++++++++++ src/apps/login/DesktopWindow.h | 22 ++++++++ src/apps/login/Jamfile | 1 + src/apps/login/LoginApp.cpp | 56 ++++++++++--------- src/apps/login/LoginApp.h | 24 ++++----- src/apps/login/LoginWindow.cpp | 3 +- 6 files changed, 161 insertions(+), 37 deletions(-) create mode 100644 src/apps/login/DesktopWindow.cpp create mode 100644 src/apps/login/DesktopWindow.h diff --git a/src/apps/login/DesktopWindow.cpp b/src/apps/login/DesktopWindow.cpp new file mode 100644 index 0000000000..c0aa690f1b --- /dev/null +++ b/src/apps/login/DesktopWindow.cpp @@ -0,0 +1,92 @@ +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "LoginApp.h" +#include "DesktopWindow.h" + +const window_feel kPrivateDesktopWindowFeel = window_feel(1024); +const window_look kPrivateDesktopWindowLook = window_look(4); + // this is a mirror of an app server private values + + +DesktopWindow::DesktopWindow(BRect frame, bool editMode) + : BWindow(frame, "Desktop", + kPrivateDesktopWindowLook, + kPrivateDesktopWindowFeel, + B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE + | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE + | B_ASYNCHRONOUS_CONTROLS, + editMode?B_CURRENT_WORKSPACE:B_ALL_WORKSPACES), + fEditShelfMode(editMode) +{ + BScreen screen; + BView *desktop = new BView(Bounds(), "desktop", B_FOLLOW_NONE, 0); + desktop->SetViewColor(screen.DesktopColor()); + AddChild(desktop); + + // load the shelf + BPath path; + status_t err; + entry_ref ref; + err = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path, true); + if (err >= B_OK) { + BDirectory dir(path.Path()); + if (!dir.Contains("x-vnd.Haiku-Login", B_DIRECTORY_NODE)) + dir.CreateDirectory("x-vnd.Haiku-Login", NULL); + path.Append("x-vnd.Haiku-Login"); + dir.SetTo(path.Path()); + if (!dir.Contains("Shelf", B_FILE_NODE)) + dir.CreateFile("Shelf", NULL); + path.Append("Shelf"); + get_ref_for_path(path.Path(), &ref); + } + + fDesktopShelf = new BShelf(&ref, desktop, fEditShelfMode, "DesktopShelf"); + if (fDesktopShelf) + fDesktopShelf->SetDisplaysZombies(true); +} + + +DesktopWindow::~DesktopWindow() +{ + delete fDesktopShelf; +} + + +bool +DesktopWindow::QuitRequested() +{ + status_t err; + err = fDesktopShelf->Save(); + printf("error %s\n", strerror(err)); + return BWindow::QuitRequested(); +} + + +void +DesktopWindow::DispatchMessage(BMessage *message, BHandler *handler) +{ + switch (message->what) { + case B_MOUSE_DOWN: + case B_MOUSE_UP: + case B_MOUSE_MOVED: + case B_KEY_DOWN: + case B_KEY_UP: + case B_UNMAPPED_KEY_DOWN: + case B_UNMAPPED_KEY_UP: + /* don't allow interacting with the replicants */ + if (!fEditShelfMode) + break; + default: + BWindow::DispatchMessage(message, handler); + } +} + + diff --git a/src/apps/login/DesktopWindow.h b/src/apps/login/DesktopWindow.h new file mode 100644 index 0000000000..1454f7df7a --- /dev/null +++ b/src/apps/login/DesktopWindow.h @@ -0,0 +1,22 @@ +#ifndef _DESKTOPWINDOW_H_ +#define _DESKTOPWINDOW_H_ + +#include +#include + +class DesktopWindow : public BWindow { + public: + DesktopWindow(BRect frame, bool editMode); + virtual ~DesktopWindow(); + + bool QuitRequested(); + void DispatchMessage(BMessage *message, BHandler *handler); + + private: + bool fEditShelfMode; + + //TODO: + BShelf* fDesktopShelf; +}; + +#endif // _DESKTOPWINDOW_H_ diff --git a/src/apps/login/Jamfile b/src/apps/login/Jamfile index 5b4a014d58..95bfb4a73c 100644 --- a/src/apps/login/Jamfile +++ b/src/apps/login/Jamfile @@ -14,6 +14,7 @@ if $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { UseHeaders [ FDirName $(HAIKU_TOP) src bin multiuser ] ; Application Login : + DesktopWindow.cpp LoginApp.cpp LoginWindow.cpp LoginView.cpp diff --git a/src/apps/login/LoginApp.cpp b/src/apps/login/LoginApp.cpp index d5a8d82c60..285f5c4c03 100644 --- a/src/apps/login/LoginApp.cpp +++ b/src/apps/login/LoginApp.cpp @@ -10,6 +10,7 @@ #include "LoginApp.h" #include "LoginWindow.h" +#include "DesktopWindow.h" #ifdef __HAIKU__ #include @@ -20,13 +21,10 @@ const char *kLoginAppSig = "application/x-vnd.Haiku-Login"; -const window_feel kPrivateDesktopWindowFeel = window_feel(1024); -const window_look kPrivateDesktopWindowLook = window_look(4); - // this is a mirror of an app server private values - LoginApp::LoginApp() - : BApplication(kLoginAppSig) + : BApplication(kLoginAppSig), + fEditShelfMode(false) { } @@ -39,25 +37,23 @@ LoginApp::~LoginApp() void LoginApp::ReadyToRun() { - BScreen s; - BRect frame(0, 0, 400, 150); - frame.OffsetBySelf(s.Frame().Width()/2 - frame.Width()/2, - s.Frame().Height()/2 - frame.Height()/2); - fLoginWindow = new LoginWindow(frame); - fLoginWindow->Show(); - BScreen screen; - fDesktopWindow = new BWindow(screen.Frame(), "Desktop", - kPrivateDesktopWindowLook, - kPrivateDesktopWindowFeel, - B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE - | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE - | B_ASYNCHRONOUS_CONTROLS, - B_ALL_WORKSPACES); - BView *desktop = new BView(fDesktopWindow->Bounds(), "desktop", - B_FOLLOW_NONE, 0); - desktop->SetViewColor(screen.DesktopColor()); - fDesktopWindow->AddChild(desktop); + + if (fEditShelfMode) { + (new BAlert("Info", "You can customize the desktop shown " + "behind the Login app by dropping replicants onto it.\n" + "\n" + "When you are finished just quit the application (Alt-Q).", + "Ok"))->Go(NULL); + } else { + BRect frame(0, 0, 400, 150); + frame.OffsetBySelf(screen.Frame().Width()/2 - frame.Width()/2, + screen.Frame().Height()/2 - frame.Height()/2); + fLoginWindow = new LoginWindow(frame); + fLoginWindow->Show(); + } + + fDesktopWindow = new DesktopWindow(screen.Frame(), fEditShelfMode); fDesktopWindow->Show(); // TODO: add a shelf with Activity Monitor replicant :) } @@ -100,6 +96,18 @@ LoginApp::MessageReceived(BMessage *message) } +void +LoginApp::ArgvReceived(int32 argc, char **argv) +{ + int i; + for (i = 1; i < argc; i++) { + printf("[%d]: %s\n", i, argv[i]); + if (argv[i] == BString("--edit")) + fEditShelfMode = true; + } +} + + void LoginApp::TryLogin(BMessage *message) { @@ -137,7 +145,7 @@ LoginApp::TryLogin(BMessage *message) status_t -LoginApp::ValidateLogin(const char *login, const char *password/*, bool force = false*/) +LoginApp::ValidateLogin(const char *login, const char *password) { struct passwd *pwd; diff --git a/src/apps/login/LoginApp.h b/src/apps/login/LoginApp.h index 93f25f25f1..4c2a443d0a 100644 --- a/src/apps/login/LoginApp.h +++ b/src/apps/login/LoginApp.h @@ -12,25 +12,25 @@ const uint32 kLoginBad = 'lgba'; const uint32 kLoginOk = 'lgok'; class LoginWindow; +class DesktopWindow; class LoginApp : public BApplication { public: - LoginApp(); - virtual ~LoginApp(); - void ReadyToRun(); - void MessageReceived(BMessage *message); + LoginApp(); + virtual ~LoginApp(); + void ReadyToRun(); + void MessageReceived(BMessage *message); + void ArgvReceived(int32 argc, char **argv); private: - void TryLogin(BMessage *message); - status_t ValidateLogin(const char *login, const char *password/*, bool force = false*/); - status_t StartUserSession(const char *login); - int getpty(char *pty, char *tty); + void TryLogin(BMessage *message); + status_t ValidateLogin(const char *login, const char *password); + status_t StartUserSession(const char *login); + int getpty(char *pty, char *tty); - BWindow* fDesktopWindow; + DesktopWindow* fDesktopWindow; LoginWindow* fLoginWindow; - - //TODO: - //BShelf* fDesktopShelf; + bool fEditShelfMode; }; #endif // _LOGINAPP_H_ diff --git a/src/apps/login/LoginWindow.cpp b/src/apps/login/LoginWindow.cpp index 801cb138bc..1b72a378a4 100644 --- a/src/apps/login/LoginWindow.cpp +++ b/src/apps/login/LoginWindow.cpp @@ -9,7 +9,8 @@ LoginWindow::LoginWindow(BRect frame) WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | - B_ASYNCHRONOUS_CONTROLS) + B_ASYNCHRONOUS_CONTROLS, + B_ALL_WORKSPACES) { LoginView *v = new LoginView(Bounds()); AddChild(v);