- 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
This commit is contained in:
François Revol 2008-04-20 16:14:53 +00:00
parent 3d9c0d7c37
commit 0efb25854a
6 changed files with 161 additions and 37 deletions

View File

@ -0,0 +1,92 @@
#include <string.h>
#include <stdio.h>
#include <Directory.h>
#include <Entry.h>
#include <FindDirectory.h>
#include <Path.h>
#include <Screen.h>
#include <View.h>
#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);
}
}

View File

@ -0,0 +1,22 @@
#ifndef _DESKTOPWINDOW_H_
#define _DESKTOPWINDOW_H_
#include <Shelf.h>
#include <Window.h>
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_

View File

@ -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

View File

@ -10,6 +10,7 @@
#include "LoginApp.h"
#include "LoginWindow.h"
#include "DesktopWindow.h"
#ifdef __HAIKU__
#include <RosterPrivate.h>
@ -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;

View File

@ -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_

View File

@ -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);