Browse Source

Added focus_password config option: focus password field
when default_user is enabled

Note: not implemented for PAM yet


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@154 7c53e7cc-98ea-0310-8f1f-a0b24da60408

sip 13 years ago
parent
commit
c14af2218f
5 changed files with 34 additions and 16 deletions
  1. 6 0
      ChangeLog
  2. 21 15
      app.cpp
  3. 1 1
      app.h
  4. 1 0
      cfg.cpp
  5. 5 0
      slim.conf

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+1.3.1 - XXXX.XX.XX
+    * Added focus_password config option for focusing password
+      automatically when default_user is enabled
+    * Fixed uninitialized daemonmode, see
+      http://www.freebsd.org/cgi/query-pr.cgi?pr=114366
+
 1.3.0 - 2006.07.14
     * Added PAM support by Martin Parm
     * Fixed segfault on exit when testing themes. Thanks

+ 21 - 15
app.cpp

@@ -297,7 +297,7 @@ void App::Run() {
     // for tests we use a standard window
     if (testing) {
         Window RealRoot = RootWindow(Dpy, Scr);
-        Root = XCreateSimpleWindow(Dpy, RealRoot, 0, 0, 640, 480, 0, 0, 0);
+        Root = XCreateSimpleWindow(Dpy, RealRoot, 0, 0, 1280, 1024, 0, 0, 0);
         XMapWindow(Dpy, Root);
         XFlush(Dpy);
     } else {
@@ -313,6 +313,7 @@ void App::Run() {
     int panelclosed = 1;
     Panel::ActionType Action;
     bool firstloop = true; // 1st time panel is shown (for automatic username)
+    bool focuspass = cfg->getOption("focus_password")=="yes";
 
     while(1) {
         if(panelclosed) {
@@ -330,19 +331,22 @@ void App::Run() {
         }
 
         LoginPanel->Reset();
+	
+	
         if (firstloop && cfg->getOption("default_user") != "") {
             LoginPanel->SetName(cfg->getOption("default_user") );
-            firstloop = false;
         }
 
 
-        if (!AuthenticateUser()){
+        if (!AuthenticateUser(focuspass && firstloop)){
             panelclosed = 0;
+            firstloop = false;
             LoginPanel->ClearPanel();
             XBell(Dpy, 100);
             continue;
         }
-        
+	
+	firstloop = false;
 
         Action = LoginPanel->getAction();
         // for themes test we just quit
@@ -376,7 +380,7 @@ void App::Run() {
 }
 
 #ifdef USE_PAM
-bool App::AuthenticateUser(void){
+bool App::AuthenticateUser(bool focuspass){
     // Reset the username
     try{
         pam.set_item(PAM::Authenticator::User, 0);
@@ -400,16 +404,18 @@ bool App::AuthenticateUser(void){
     return true;
 }
 #else
-bool App::AuthenticateUser(void){
-    LoginPanel->EventHandler(Panel::Get_Name);
-    switch(LoginPanel->getAction()){
-        case Panel::Exit:
-        case Panel::Console:
-            cerr << APPNAME << ": Got a special command (" << LoginPanel->GetName() << ")" << endl;
-            return true; // <--- This is simply fake!
-        default:
-            break;
-    };
+bool App::AuthenticateUser(bool focuspass){
+    if (!focuspass){
+        LoginPanel->EventHandler(Panel::Get_Name);
+        switch(LoginPanel->getAction()){
+            case Panel::Exit:
+            case Panel::Console:
+                cerr << APPNAME << ": Got a special command (" << LoginPanel->GetName() << ")" << endl;
+                return true; // <--- This is simply fake!
+            default:
+                break;
+        }
+    }
     LoginPanel->EventHandler(Panel::Get_Passwd);
     
     char *encrypted, *correct;

+ 1 - 1
app.h

@@ -57,7 +57,7 @@ private:
     char* StrConcat(const char* str1, const char* str2);
     void UpdatePid();
 
-    bool AuthenticateUser(void);
+    bool AuthenticateUser(bool focuspass);
  
     static std::string findValidRandomTheme(const std::string& set);
     static void replaceVariables(std::string& input,

+ 1 - 0
cfg.cpp

@@ -44,6 +44,7 @@ Cfg::Cfg()
     options.insert(option("screenshot_cmd","import -window root /slim.png"));
     options.insert(option("welcome_msg","Welcome to %host"));
     options.insert(option("default_user",""));
+    options.insert(option("focus_password","no"));
     options.insert(option("current_theme","default"));
     options.insert(option("lockfile","/var/run/slim.lock"));
     options.insert(option("logfile","/var/log/slim.log"));

+ 5 - 0
slim.conf

@@ -67,6 +67,11 @@ reboot_msg         The system is rebooting...
 # for avoid pre-loading the username.
 #default_user        simone
 
+# Focus the password field on start when default_user is set
+# Set to "yes" to enable this feature
+#focus_password      no
+
+
 # current theme, use comma separated list to specify a set to 
 # randomly choose from
 current_theme       default