Browse Source

Fix coding style

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@231 7c53e7cc-98ea-0310-8f1f-a0b24da60408
iwamatsu 11 years ago
parent
commit
ae2b9db56d
15 changed files with 157 additions and 158 deletions
  1. 9 9
      Ck.h
  2. 1 1
      PAM.cpp
  3. 11 12
      app.cpp
  4. 15 15
      app.h
  5. 5 6
      cfg.cpp
  6. 5 5
      cfg.h
  7. 14 15
      image.cpp
  8. 20 20
      image.h
  9. 1 1
      log.cpp
  10. 8 8
      main.cpp
  11. 3 3
      numlock.cpp
  12. 14 14
      numlock.h
  13. 5 5
      panel.cpp
  14. 18 18
      panel.h
  15. 28 26
      png.c

+ 9 - 9
Ck.h

@@ -16,31 +16,31 @@
 #include <dbus/dbus.h>
 #include <dbus/dbus.h>
 
 
 namespace Ck {
 namespace Ck {
-  class Exception {
-  public:
+	class Exception {
+	public:
 	std::string func;
 	std::string func;
 	std::string errstr;
 	std::string errstr;
 	Exception(const std::string &func, const std::string &errstr);
 	Exception(const std::string &func, const std::string &errstr);
-  };
+	};
 
 
-  class Session {
-  private:
+	class Session {
+	private:
 	CkConnector *ckc;
 	CkConnector *ckc;
 	DBusError error;
 	DBusError error;
 
 
 	const char * get_x11_device(const std::string &display);
 	const char * get_x11_device(const std::string &display);
 	dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
 	dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
-												  uid_t uid);
-  public:
+		uid_t uid);
+	public:
 	const char * get_xdg_session_cookie();
 	const char * get_xdg_session_cookie();
 	void open_session(const std::string &display, uid_t uid);
 	void open_session(const std::string &display, uid_t uid);
 	void close_session();
 	void close_session();
 
 
 	Session();
 	Session();
 	~Session();
 	~Session();
-  };
+	};
 };
 };
 
 
-std::ostream& operator<<( std::ostream& os, const Ck::Exception& e);
+std::ostream &operator<<(std::ostream &os, const Ck::Exception &e);
 
 
 #endif /* _CK_H_ */
 #endif /* _CK_H_ */

+ 1 - 1
PAM.cpp

@@ -145,7 +145,7 @@ namespace PAM {
 			case PAM_USER_UNKNOWN:
 			case PAM_USER_UNKNOWN:
 				_end();
 				_end();
 				throw Exception(pam_handle, "pam_acct_mgmt()", last_result);
 				throw Exception(pam_handle, "pam_acct_mgmt()", last_result);
-				
+
 			case PAM_AUTH_ERR:
 			case PAM_AUTH_ERR:
 			case PAM_PERM_DENIED:
 			case PAM_PERM_DENIED:
 				throw Auth_Exception(pam_handle, "pam_acct_mgmt()", last_result);
 				throw Auth_Exception(pam_handle, "pam_acct_mgmt()", last_result);

+ 11 - 12
app.cpp

@@ -176,7 +176,7 @@ App::App(int argc, char** argv)
 			break;
 			break;
 		}
 		}
 	}
 	}
-#ifndef XNEST_DEBUG 
+#ifndef XNEST_DEBUG
 	if (getuid() != 0 && !testing) {
 	if (getuid() != 0 && !testing) {
 		logStream << APPNAME << ": only root can run this program" << endl;
 		logStream << APPNAME << ": only root can run this program" << endl;
 		exit(ERR_EXIT);
 		exit(ERR_EXIT);
@@ -316,7 +316,7 @@ void App::Run() {
 	bool firstloop = true; /* 1st time panel is shown (for automatic username) */
 	bool firstloop = true; /* 1st time panel is shown (for automatic username) */
 	bool focuspass = cfg->getOption("focus_password")=="yes";
 	bool focuspass = cfg->getOption("focus_password")=="yes";
 	bool autologin = cfg->getOption("auto_login")=="yes";
 	bool autologin = cfg->getOption("auto_login")=="yes";
-	
+
 	if (firstlogin && cfg->getOption("default_user") != "") {
 	if (firstlogin && cfg->getOption("default_user") != "") {
 		LoginPanel->SetName(cfg->getOption("default_user") );
 		LoginPanel->SetName(cfg->getOption("default_user") );
 #ifdef USE_PAM
 #ifdef USE_PAM
@@ -335,7 +335,7 @@ void App::Run() {
 	} else if (numlock == "off") {
 	} else if (numlock == "off") {
 		NumLock::setOff(Dpy);
 		NumLock::setOff(Dpy);
 	}
 	}
-	
+
 	/* Start looping */
 	/* Start looping */
 	int panelclosed = 1;
 	int panelclosed = 1;
 	Panel::ActionType Action;
 	Panel::ActionType Action;
@@ -369,7 +369,7 @@ void App::Run() {
 			XBell(Dpy, 100);
 			XBell(Dpy, 100);
 			continue;
 			continue;
 		}
 		}
-	
+
 		firstloop = false;
 		firstloop = false;
 
 
 		Action = LoginPanel->getAction();
 		Action = LoginPanel->getAction();
@@ -442,7 +442,7 @@ bool App::AuthenticateUser(bool focuspass){
 		}
 		}
 	}
 	}
 	LoginPanel->EventHandler(Panel::Get_Passwd);
 	LoginPanel->EventHandler(Panel::Get_Passwd);
-	
+
 	char *encrypted, *correct;
 	char *encrypted, *correct;
 	struct passwd *pw;
 	struct passwd *pw;
 
 
@@ -463,7 +463,7 @@ bool App::AuthenticateUser(bool focuspass){
 		return false;
 		return false;
 
 
 #ifdef HAVE_SHADOW
 #ifdef HAVE_SHADOW
-	struct spwd *sp = getspnam(pw->pw_name);	
+	struct spwd *sp = getspnam(pw->pw_name);
 	endspent();
 	endspent();
 	if(sp)
 	if(sp)
 		correct = sp->sp_pwdp;
 		correct = sp->sp_pwdp;
@@ -537,7 +537,7 @@ void App::Login() {
 	maildir.append(pw->pw_name);
 	maildir.append(pw->pw_name);
 	string xauthority = pw->pw_dir;
 	string xauthority = pw->pw_dir;
 	xauthority.append("/.Xauthority");
 	xauthority.append("/.Xauthority");
-	
+
 #ifdef USE_PAM
 #ifdef USE_PAM
 	/* Setup the PAM environment */
 	/* Setup the PAM environment */
 	try{
 	try{
@@ -799,11 +799,11 @@ void App::RestartServer() {
 	};
 	};
 #endif
 #endif
 
 
-	StopServer(); 
+	StopServer();
 	RemoveLock();
 	RemoveLock();
 	while (waitpid(-1, NULL, WNOHANG) > 0); /* Collects all dead childrens */
 	while (waitpid(-1, NULL, WNOHANG) > 0); /* Collects all dead childrens */
 	Run();
 	Run();
-} 
+}
 
 
 void App::KillAllClients(Bool top) {
 void App::KillAllClients(Bool top) {
 	Window dummywindow;
 	Window dummywindow;
@@ -1077,7 +1077,7 @@ void App::setBackground(const string& themedir) {
 		XSetWindowBackgroundPixmap(Dpy, Root, p);
 		XSetWindowBackgroundPixmap(Dpy, Root, p);
 	}
 	}
 	XClearWindow(Dpy, Root);
 	XClearWindow(Dpy, Root);
-	
+
 	XFlush(Dpy);
 	XFlush(Dpy);
 	delete image;
 	delete image;
 }
 }
@@ -1137,8 +1137,7 @@ void App::OpenLog() {
 		RemoveLock();
 		RemoveLock();
 		exit(ERR_EXIT);
 		exit(ERR_EXIT);
 	}
 	}
-	/* I should set the buffers to imediate write, but I just flush on every 
-	   << operation. */ 
+	/* I should set the buffers to imediate write, but I just flush on every << operation. */
 }
 }
 
 
 /* Relases stdout/err */
 /* Relases stdout/err */

+ 15 - 15
app.h

@@ -33,7 +33,7 @@
 
 
 class App {
 class App {
 public:
 public:
-	App(int argc, char** argv);
+	App(int argc, char **argv);
 	~App();
 	~App();
 	void Run();
 	void Run();
 	int GetServerPID();
 	int GetServerPID();
@@ -59,15 +59,15 @@ private:
 	void CloseLog();
 	void CloseLog();
 	void HideCursor();
 	void HideCursor();
 	void CreateServerAuth();
 	void CreateServerAuth();
-	char* StrConcat(const char* str1, const char* str2);
+	char *StrConcat(const char *str1, const char *str2);
 	void UpdatePid();
 	void UpdatePid();
 
 
 	bool AuthenticateUser(bool focuspass);
 	bool AuthenticateUser(bool focuspass);
- 
-	static std::string findValidRandomTheme(const std::string& set);
-	static void replaceVariables(std::string& input,
-								 const std::string& var,
-								 const std::string& value);
+
+	static std::string findValidRandomTheme(const std::string &set);
+	static void replaceVariables(std::string &input,
+								 const std::string &var,
+								 const std::string &value);
 
 
 	/* Server functions */
 	/* Server functions */
 	int StartServer();
 	int StartServer();
@@ -76,11 +76,11 @@ private:
 
 
 	/* Private data */
 	/* Private data */
 	Window Root;
 	Window Root;
-	Display* Dpy;
+	Display *Dpy;
 	int Scr;
 	int Scr;
-	Panel* LoginPanel;
+	Panel *LoginPanel;
 	int ServerPID;
 	int ServerPID;
-	const char* DisplayName;
+	const char *DisplayName;
 	bool serverStarted;
 	bool serverStarted;
 
 
 #ifdef USE_PAM
 #ifdef USE_PAM
@@ -91,23 +91,23 @@ private:
 #endif
 #endif
 
 
 	/* Options */
 	/* Options */
-	char* DispName;
+	char *DispName;
 
 
 	Cfg *cfg;
 	Cfg *cfg;
 
 
 	Pixmap BackgroundPixmap;
 	Pixmap BackgroundPixmap;
 
 
 	void blankScreen();
 	void blankScreen();
-	Image* image;
-	void setBackground(const std::string& themedir);
+	Image *image;
+	void setBackground(const std::string &themedir);
 
 
 	bool firstlogin;
 	bool firstlogin;
 	bool daemonmode;
 	bool daemonmode;
 	bool force_nodaemon;
 	bool force_nodaemon;
 	/* For testing themes */
 	/* For testing themes */
-	char* testtheme;
+	char *testtheme;
 	bool testing;
 	bool testing;
-	
+
 	std::string themeName;
 	std::string themeName;
 	std::string mcookie;
 	std::string mcookie;
 
 

+ 5 - 6
cfg.cpp

@@ -24,7 +24,7 @@ using namespace std;
 
 
 typedef pair<string,string> option;
 typedef pair<string,string> option;
 
 
-Cfg::Cfg() 
+Cfg::Cfg()
 	: currentSession(-1)
 	: currentSession(-1)
 {
 {
 	/* Configuration options */
 	/* Configuration options */
@@ -110,7 +110,6 @@ Cfg::Cfg()
 	options.insert(option("msg_shadow_xoffset", "0"));
 	options.insert(option("msg_shadow_xoffset", "0"));
 	options.insert(option("msg_shadow_yoffset", "0"));
 	options.insert(option("msg_shadow_yoffset", "0"));
 	options.insert(option("msg_shadow_color","#FFFFFF"));
 	options.insert(option("msg_shadow_color","#FFFFFF"));
-	
 
 
 	options.insert(option("session_color","#FFFFFF"));
 	options.insert(option("session_color","#FFFFFF"));
 	options.insert(option("session_font","Verdana:size=16:bold"));
 	options.insert(option("session_font","Verdana:size=16:bold"));
@@ -285,16 +284,16 @@ void Cfg::fillSessionList(){
 
 
 				struct stat oFileStat;
 				struct stat oFileStat;
 
 
-				if (stat(strFile.c_str( ), &oFileStat) == 0){
-					if (S_ISREG(oFileStat.st_mode) && 
-						access(strFile.c_str(), R_OK | X_OK) == 0){
+				if (stat(strFile.c_str(), &oFileStat) == 0) {
+					if (S_ISREG(oFileStat.st_mode) &&
+						access(strFile.c_str(), R_OK | X_OK) == 0) {
 						sessions.push_back(string(pDirent->d_name));
 						sessions.push_back(string(pDirent->d_name));
 					}
 					}
 				}
 				}
 			}
 			}
 			closedir(pDir);
 			closedir(pDir);
 		}
 		}
-	} 
+	}
 
 
 	if (sessions.empty()){
 	if (sessions.empty()){
 		split(sessions, strSessionList, ',', false);
 		split(sessions, strSessionList, ',', false);

+ 5 - 5
cfg.h

@@ -27,6 +27,7 @@ class Cfg {
 public:
 public:
 	Cfg();
 	Cfg();
 	~Cfg();
 	~Cfg();
+
 	bool readConf(std::string configfile);
 	bool readConf(std::string configfile);
 	std::string parseOption(std::string line, std::string option);
 	std::string parseOption(std::string line, std::string option);
 	const std::string& getError() const;
 	const std::string& getError() const;
@@ -34,11 +35,11 @@ public:
 	int getIntOption(std::string option);
 	int getIntOption(std::string option);
 	std::string getWelcomeMessage();
 	std::string getWelcomeMessage();
 
 
-	static int absolutepos(const std::string& position, int max, int width);
-	static int string2int(const char* string, bool* ok = 0);
-	static void split(std::vector<std::string>& v, const std::string& str, 
+	static int absolutepos(const std::string &position, int max, int width);
+	static int string2int(const char *string, bool *ok = 0);
+	static void split(std::vector<std::string> &v, const std::string &str, 
 					  char c, bool useEmpty=true);
 					  char c, bool useEmpty=true);
-	static std::string Trim(const std::string& s);
+	static std::string Trim(const std::string &s);
 
 
 	std::string nextSession(std::string current);
 	std::string nextSession(std::string current);
 
 
@@ -50,7 +51,6 @@ private:
 	std::vector<std::string> sessions;
 	std::vector<std::string> sessions;
 	int currentSession;
 	int currentSession;
 	std::string error;
 	std::string error;
-
 };
 };
 
 
 #endif /* _CFG_H_ */
 #endif /* _CFG_H_ */

+ 14 - 15
image.cpp

@@ -2,12 +2,12 @@
    Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
    Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
    Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
    Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
    Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
    Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-	  
+
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    (at your option) any later version.
-   
+
    The following code has been adapted and extended from
    The following code has been adapted and extended from
    xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
    xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
 */
 */
@@ -69,7 +69,7 @@ Image::Read(const char *filename) {
 	fread(buf, 1, 4, file);
 	fread(buf, 1, 4, file);
 	fclose(file);
 	fclose(file);
 
 
-	if ((ubuf[0] == 0x89) && !strncmp("PNG", buf+1, 3)) 
+	if ((ubuf[0] == 0x89) && !strncmp("PNG", buf+1, 3))
 		success = readPng(filename, &width, &height, &rgb_data, &png_alpha);
 		success = readPng(filename, &width, &height, &rgb_data, &png_alpha);
 	else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8))
 	else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8))
 		success = readJpeg(filename, &width, &height, &rgb_data);
 		success = readJpeg(filename, &width, &height, &rgb_data);
@@ -131,7 +131,7 @@ Image::Reduce(const int factor) {
 
 
 void
 void
 Image::Resize(const int w, const int h) {
 Image::Resize(const int w, const int h) {
-	
+
 	if (width==w && height==h){
 	if (width==w && height==h){
 		return;
 		return;
 	}
 	}
@@ -244,7 +244,7 @@ Image::getPixel(double x, double y, unsigned char *pixel, unsigned char *alpha)
  */
  */
 void Image::Merge(Image* background, const int x, const int y) {
 void Image::Merge(Image* background, const int x, const int y) {
 
 
-	if (x + width > background->Width()|| y + height > background->Height()) 
+	if (x + width > background->Width()|| y + height > background->Height())
 		return;
 		return;
 
 
 	if (background->Width()*background->Height() != width*height)
 	if (background->Width()*background->Height() != width*height)
@@ -254,7 +254,7 @@ void Image::Merge(Image* background, const int x, const int y) {
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * width * height);
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * width * height);
 	memset(new_rgb, 0, 3 * width * height);
 	memset(new_rgb, 0, 3 * width * height);
 	const unsigned char *bg_rgb = background->getRGBData();
 	const unsigned char *bg_rgb = background->getRGBData();
-	
+
 	int ipos = 0;
 	int ipos = 0;
 	if (png_alpha != NULL){
 	if (png_alpha != NULL){
 		for (int j = 0; j < height; j++) {
 		for (int j = 0; j < height; j++) {
@@ -305,7 +305,7 @@ void Image::Tile(const int w, const int h) {
 
 
 	int newwidth = nx*width;
 	int newwidth = nx*width;
 	int newheight=ny*height;
 	int newheight=ny*height;
-		
+
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * newwidth * newheight);
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * newwidth * newheight);
 	memset(new_rgb, 0, 3 * width * height * nx * ny);
 	memset(new_rgb, 0, 3 * width * height * nx * ny);
 
 
@@ -390,18 +390,18 @@ void Image::Crop(const int x, const int y, const int w, const int h) {
 void Image::Center(const int w, const int h, const char *hex) {
 void Image::Center(const int w, const int h, const char *hex) {
 
 
 	unsigned long packed_rgb;
 	unsigned long packed_rgb;
-	sscanf(hex, "%lx", &packed_rgb);  
+	sscanf(hex, "%lx", &packed_rgb);
 
 
 	unsigned long r = packed_rgb>>16;
 	unsigned long r = packed_rgb>>16;
 	unsigned long g = packed_rgb>>8 & 0xff;
 	unsigned long g = packed_rgb>>8 & 0xff;
-	unsigned long b = packed_rgb & 0xff;	
+	unsigned long b = packed_rgb & 0xff;
 
 
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
 
 
 	int x = (w - width) / 2;
 	int x = (w - width) / 2;
 	int y = (h - height) / 2;
 	int y = (h - height) / 2;
-	
+
 	if (x<0) {
 	if (x<0) {
 		Crop((width - w)/2,0,w,height);
 		Crop((width - w)/2,0,w,height);
 		x = 0;
 		x = 0;
@@ -454,14 +454,14 @@ void Image::Center(const int w, const int h, const char *hex) {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	free(rgb_data);
 	free(rgb_data);
 	free(png_alpha);
 	free(png_alpha);
 	rgb_data = new_rgb;
 	rgb_data = new_rgb;
 	png_alpha = NULL;
 	png_alpha = NULL;
 	width = w;
 	width = w;
 	height = h;
 	height = h;
-	
+
 }
 }
 
 
 /* Fill the image with the given color and adjust its dimensions
 /* Fill the image with the given color and adjust its dimensions
@@ -470,11 +470,11 @@ void Image::Center(const int w, const int h, const char *hex) {
 void Image::Plain(const int w, const int h, const char *hex) {
 void Image::Plain(const int w, const int h, const char *hex) {
 
 
 	unsigned long packed_rgb;
 	unsigned long packed_rgb;
-	sscanf(hex, "%lx", &packed_rgb);  
+	sscanf(hex, "%lx", &packed_rgb);
 
 
 	unsigned long r = packed_rgb>>16;
 	unsigned long r = packed_rgb>>16;
 	unsigned long g = packed_rgb>>8 & 0xff;
 	unsigned long g = packed_rgb>>8 & 0xff;
-	unsigned long b = packed_rgb & 0xff;	
+	unsigned long b = packed_rgb & 0xff;
 
 
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
@@ -492,7 +492,6 @@ void Image::Plain(const int w, const int h, const char *hex) {
 	png_alpha = NULL;
 	png_alpha = NULL;
 	width = w;
 	width = w;
 	height = h;
 	height = h;
-	
 }
 }
 
 
 void
 void

+ 20 - 20
image.h

@@ -1,15 +1,15 @@
 /* SLiM - Simple Login Manager
 /* SLiM - Simple Login Manager
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-   Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-	  
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-   
-   The following code has been adapted and extended from
-   xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
+	 Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	 Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+	 Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+
+	 This program is free software; you can redistribute it and/or modify
+	 it under the terms of the GNU General Public License as published by
+	 the Free Software Foundation; either version 2 of the License, or
+	 (at your option) any later version.
+
+	 The following code has been adapted and extended from
+	 xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
 */
 */
 
 
 #ifndef _IMAGE_H_
 #ifndef _IMAGE_H_
@@ -23,22 +23,22 @@ class Image {
 public:
 public:
 	Image();
 	Image();
 	Image(const int w, const int h, const unsigned char *rgb,
 	Image(const int w, const int h, const unsigned char *rgb,
-		  const unsigned char *alpha);
+			const unsigned char *alpha);
 
 
 	~Image();
 	~Image();
 
 
-	const unsigned char * getPNGAlpha() const {
+	const unsigned char *getPNGAlpha() const {
 		return(png_alpha);
 		return(png_alpha);
 	};
 	};
-	const unsigned char * getRGBData() const {
+	const unsigned char *getRGBData() const {
 		return(rgb_data);
 		return(rgb_data);
 	};
 	};
 
 
 	void getPixel(double px, double py, unsigned char *pixel);
 	void getPixel(double px, double py, unsigned char *pixel);
 	void getPixel(double px, double py, unsigned char *pixel,
 	void getPixel(double px, double py, unsigned char *pixel,
-				  unsigned char *alpha);
+					unsigned char *alpha);
 
 
-	int Width() const  {
+	int Width() const {
 		return(width);
 		return(width);
 	};
 	};
 	int Height() const {
 	int Height() const {
@@ -52,16 +52,16 @@ public:
 
 
 	void Reduce(const int factor);
 	void Reduce(const int factor);
 	void Resize(const int w, const int h);
 	void Resize(const int w, const int h);
-	void Merge(Image* background, const int x, const int y);
+	void Merge(Image *background, const int x, const int y);
 	void Crop(const int x, const int y, const int w, const int h);
 	void Crop(const int x, const int y, const int w, const int h);
 	void Tile(const int w, const int h);
 	void Tile(const int w, const int h);
 	void Center(const int w, const int h, const char *hex);
 	void Center(const int w, const int h, const char *hex);
 	void Plain(const int w, const int h, const char *hex);
 	void Plain(const int w, const int h, const char *hex);
-	
+
 	void computeShift(unsigned long mask, unsigned char &left_shift,
 	void computeShift(unsigned long mask, unsigned char &left_shift,
-					  unsigned char &right_shift);
+				unsigned char &right_shift);
 
 
-	Pixmap createPixmap(Display* dpy, int scr, Window win);
+	Pixmap createPixmap(Display *dpy, int scr, Window win);
 
 
 private:
 private:
 	int width, height, area;
 	int width, height, area;

+ 1 - 1
log.cpp

@@ -5,7 +5,7 @@ bool
 LogUnit::openLog(const char * filename)
 LogUnit::openLog(const char * filename)
 {
 {
 	if (logFile.is_open()) {
 	if (logFile.is_open()) {
-		cerr << APPNAME 
+		cerr << APPNAME
 			<< ": opening a new Log file, while another is already open"
 			<< ": opening a new Log file, while another is already open"
 			<< endl;
 			<< endl;
 		logFile.close();
 		logFile.close();

+ 8 - 8
main.cpp

@@ -1,12 +1,12 @@
 /* SLiM - Simple Login Manager
 /* SLiM - Simple Login Manager
-   Copyright (C) 1997, 1998 Per Liden
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-	  
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+	Copyright (C) 1997, 1998 Per Liden
+	Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
 */
 */
 
 
 #include "app.h"
 #include "app.h"

+ 3 - 3
numlock.cpp

@@ -28,7 +28,7 @@ int NumLock::xkb_init(Display* dpy) {
 		&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
 		&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
 				   &xkb_lmaj, &xkb_lmin );
 				   &xkb_lmaj, &xkb_lmin );
 }
 }
-	
+
 unsigned int NumLock::xkb_mask_modifier( XkbDescPtr xkb, const char *name ) {
 unsigned int NumLock::xkb_mask_modifier( XkbDescPtr xkb, const char *name ) {
 	int i;
 	int i;
 	if( !xkb || !xkb->names )
 	if( !xkb || !xkb->names )
@@ -59,7 +59,7 @@ unsigned int NumLock::xkb_numlock_mask(Display* dpy) {
 
 
 void NumLock::control_numlock(Display *dpy, bool flag) {
 void NumLock::control_numlock(Display *dpy, bool flag) {
 	unsigned int mask;
 	unsigned int mask;
-	
+
 	if( !xkb_init(dpy) )
 	if( !xkb_init(dpy) )
 		return;
 		return;
 
 
@@ -81,7 +81,7 @@ void NumLock::setOff(Display *dpy) {
 	control_numlock(dpy, false);
 	control_numlock(dpy, false);
 }
 }
 
 
-/* 
+/*
  Copyright (C) 2000-2001 Lubos Lunak		<l.lunak@kde.org>
  Copyright (C) 2000-2001 Lubos Lunak		<l.lunak@kde.org>
  Copyright (C) 2001	  Oswald Buddenhagen <ossi@kde.org>
  Copyright (C) 2001	  Oswald Buddenhagen <ossi@kde.org>
 
 

+ 14 - 14
numlock.h

@@ -1,12 +1,12 @@
 /* SLiM - Simple Login Manager
 /* SLiM - Simple Login Manager
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-   Copyright (C) 2012    Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+	Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+	Copyright (C) 2012		Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
 */
 */
 
 
 #ifndef _NUMLOCK_H_
 #ifndef _NUMLOCK_H_
@@ -19,15 +19,15 @@
 class NumLock {
 class NumLock {
 
 
 public:
 public:
-    NumLock();
-    static void setOn(Display *dpy);
-    static void setOff(Display *dpy);
+	NumLock();
+	static void setOn(Display *dpy);
+	static void setOff(Display *dpy);
 
 
 private:
 private:
-    static int xkb_init(Display* dpy);
-    static unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name );
-    static unsigned int xkb_numlock_mask(Display* dpy);
-    static void control_numlock(Display *dpy, bool flag);
+	static int xkb_init(Display *dpy);
+	static unsigned int xkb_mask_modifier(XkbDescPtr xkb, const char *name);
+	static unsigned int xkb_numlock_mask(Display *dpy);
+	static void control_numlock(Display *dpy, bool flag);
 };
 };
 
 
 #endif /* _NUMLOCK_H_ */
 #endif /* _NUMLOCK_H_ */

+ 5 - 5
panel.cpp

@@ -353,7 +353,7 @@ bool Panel::OnKeyPress(XEvent& event) {
 	int yy;
 	int yy;
 	string text;
 	string text;
 	string formerString = "";
 	string formerString = "";
-	
+
 	XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus);
 	XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus);
 	switch(keysym){
 	switch(keysym){
 		case XK_F1:
 		case XK_F1:
@@ -429,7 +429,7 @@ bool Panel::OnKeyPress(XEvent& event) {
 				break;
 				break;
 			}
 			}
 			/* Deliberate fall-through */
 			/* Deliberate fall-through */
-		
+
 		default:
 		default:
 			if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){
 			if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){
 				switch(field) {
 				switch(field) {
@@ -575,9 +575,9 @@ void Panel::ShowSession() {
 	XClearWindow(Dpy, Root);
 	XClearWindow(Dpy, Root);
 	string currsession = cfg->getOption("session_msg") + " " + session;
 	string currsession = cfg->getOption("session_msg") + " " + session;
 	XGlyphInfo extents;
 	XGlyphInfo extents;
-	
+
 	sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
 	sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
-	
+
 	XftDraw *draw = XftDrawCreate(Dpy, Root,
 	XftDraw *draw = XftDrawCreate(Dpy, Root,
 								  DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
 								  DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
 	XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
 	XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
@@ -590,7 +590,7 @@ void Panel::ShowSession() {
 	int shadowYOffset = cfg->getIntOption("session_shadow_yoffset");
 	int shadowYOffset = cfg->getIntOption("session_shadow_yoffset");
 
 
 	SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
 	SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
-					currsession, 
+					currsession,
 					&sessionshadowcolor,
 					&sessionshadowcolor,
 					shadowXOffset, shadowYOffset);
 					shadowXOffset, shadowYOffset);
 	XFlush(Dpy);
 	XFlush(Dpy);

+ 18 - 18
panel.h

@@ -41,34 +41,35 @@ public:
 		Exit,
 		Exit,
 		Suspend
 		Suspend
 	};
 	};
+
 	enum FieldType {
 	enum FieldType {
 		Get_Name,
 		Get_Name,
 		Get_Passwd
 		Get_Passwd
 	};
 	};
 
 
 
 
-	Panel(Display* dpy, int scr, Window root, Cfg* config,
+	Panel(Display *dpy, int scr, Window root, Cfg *config,
 		  const std::string& themed);
 		  const std::string& themed);
 	~Panel();
 	~Panel();
 	void OpenPanel();
 	void OpenPanel();
 	void ClosePanel();
 	void ClosePanel();
 	void ClearPanel();
 	void ClearPanel();
-	void Message(const std::string& text);
-	void Error(const std::string& text);
-	void EventHandler(const FieldType& curfield);
+	void Message(const std::string &text);
+	void Error(const std::string &text);
+	void EventHandler(const FieldType &curfield);
 	std::string getSession();
 	std::string getSession();
 	ActionType getAction(void) const;
 	ActionType getAction(void) const;
 
 
 	void Reset(void);
 	void Reset(void);
 	void ResetName(void);
 	void ResetName(void);
 	void ResetPasswd(void);
 	void ResetPasswd(void);
-	void SetName(const std::string& name);
+	void SetName(const std::string &name);
 	const std::string& GetName(void) const;
 	const std::string& GetName(void) const;
 	const std::string& GetPasswd(void) const;
 	const std::string& GetPasswd(void) const;
 private:
 private:
 	Panel();
 	Panel();
 	void Cursor(int visible);
 	void Cursor(int visible);
-	unsigned long GetColor(const char* colorname);
+	unsigned long GetColor(const char *colorname);
 	void OnExpose(void);
 	void OnExpose(void);
 	bool OnKeyPress(XEvent& event);
 	bool OnKeyPress(XEvent& event);
 	void ShowText();
 	void ShowText();
@@ -76,34 +77,34 @@ private:
 	void ShowSession();
 	void ShowSession();
 
 
 	void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
 	void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
-							int x, int y, const std::string& str,
-							XftColor* shadowColor,
+							int x, int y, const std::string &str,
+							XftColor *shadowColor,
 							int xOffset, int yOffset);
 							int xOffset, int yOffset);
 
 
-	Cfg* cfg;
+	Cfg *cfg;
 
 
 	/* Private data */
 	/* Private data */
 	Window Win;
 	Window Win;
 	Window Root;
 	Window Root;
-	Display* Dpy;
+	Display *Dpy;
 	int Scr;
 	int Scr;
 	int X, Y;
 	int X, Y;
 	GC TextGC;
 	GC TextGC;
-	XftFont* font;
+	XftFont *font;
 	XftColor inputshadowcolor;
 	XftColor inputshadowcolor;
 	XftColor inputcolor;
 	XftColor inputcolor;
 	XftColor msgcolor;
 	XftColor msgcolor;
 	XftColor msgshadowcolor;
 	XftColor msgshadowcolor;
-	XftFont* msgfont;
+	XftFont *msgfont;
 	XftColor introcolor;
 	XftColor introcolor;
-	XftFont* introfont;
-	XftFont* welcomefont;
+	XftFont *introfont;
+	XftFont *welcomefont;
 	XftColor welcomecolor;
 	XftColor welcomecolor;
-	XftFont* sessionfont;
+	XftFont *sessionfont;
 	XftColor sessioncolor;
 	XftColor sessioncolor;
 	XftColor sessionshadowcolor;
 	XftColor sessionshadowcolor;
 	XftColor welcomeshadowcolor;
 	XftColor welcomeshadowcolor;
-	XftFont* enterfont;
+	XftFont *enterfont;
 	XftColor entercolor;
 	XftColor entercolor;
 	XftColor entershadowcolor;
 	XftColor entershadowcolor;
 	ActionType action;
 	ActionType action;
@@ -142,7 +143,7 @@ private:
 	/* Pixmap data */
 	/* Pixmap data */
 	Pixmap PanelPixmap;
 	Pixmap PanelPixmap;
 
 
-	Image* image;
+	Image *image;
 
 
 	/* For thesting themes */
 	/* For thesting themes */
 	bool testing;
 	bool testing;
@@ -150,7 +151,6 @@ private:
 
 
 	/* Session handling */
 	/* Session handling */
 	std::string session;
 	std::string session;
-
 };
 };
 
 
 #endif /* _PANEL_H_ */
 #endif /* _PANEL_H_ */

+ 28 - 26
png.c

@@ -25,7 +25,7 @@
 #include "const.h"
 #include "const.h"
 
 
 int
 int
-read_png(const char *filename, int *width, int *height, unsigned char **rgb, 
+read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	 unsigned char **alpha)
 	 unsigned char **alpha)
 {
 {
 	int ret = 0;
 	int ret = 0;
@@ -41,21 +41,22 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 
 
 	FILE *infile = fopen(filename, "rb");
 	FILE *infile = fopen(filename, "rb");
 	if (infile == NULL) {
 	if (infile == NULL) {
-		fprintf(stderr, "Can not fopen file: %s\n",filename);
+		fprintf(stderr, "Can not fopen file: %s\n", filename);
 		return ret;
 		return ret;
 	}
 	}
 
 
-	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 
-									 (png_voidp) NULL, 
-									 (png_error_ptr) NULL, 
-									 (png_error_ptr) NULL);
+	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+						(png_voidp)NULL,
+						(png_error_ptr)NULL,
+						(png_error_ptr)NULL);
 	if (!png_ptr)
 	if (!png_ptr)
 		goto file_close;
 		goto file_close;
-  
+
 	info_ptr = png_create_info_struct(png_ptr);
 	info_ptr = png_create_info_struct(png_ptr);
 	if (!info_ptr) {
 	if (!info_ptr) {
-		png_destroy_read_struct(&png_ptr, (png_infopp) NULL, 
-								(png_infopp) NULL);
+		png_destroy_read_struct(&png_ptr,
+						(png_infopp)NULL,
+						(png_infopp)NULL);
 	}
 	}
 
 
 #if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
 #if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
@@ -64,7 +65,7 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	if (setjmp(png_ptr->jmpbuf))
 	if (setjmp(png_ptr->jmpbuf))
 #endif
 #endif
 		goto png_destroy;
 		goto png_destroy;
-  
+
 	png_init_io(png_ptr, infile);
 	png_init_io(png_ptr, infile);
 	png_read_info(png_ptr, info_ptr);
 	png_read_info(png_ptr, info_ptr);
 
 
@@ -72,31 +73,32 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 				 &interlace_type, (int *) NULL, (int *) NULL);
 				 &interlace_type, (int *) NULL, (int *) NULL);
 
 
 	/* Prevent against integer overflow */
 	/* Prevent against integer overflow */
-	if(w >= MAX_DIMENSION || h >= MAX_DIMENSION) {
-		fprintf(stderr, "Unreasonable dimension found in file: %s\n",filename);
+	if (w >= MAX_DIMENSION || h >= MAX_DIMENSION) {
+		fprintf(stderr,
+			"Unreasonable dimension found in file: %s\n", filename);
 		goto png_destroy;
 		goto png_destroy;
 	}
 	}
 
 
 	*width = (int) w;
 	*width = (int) w;
 	*height = (int) h;
 	*height = (int) h;
-	
+
 	if (color_type == PNG_COLOR_TYPE_RGB_ALPHA
 	if (color_type == PNG_COLOR_TYPE_RGB_ALPHA
 		|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
 		|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
 		alpha[0] = malloc(*width * *height);
 		alpha[0] = malloc(*width * *height);
-		if (alpha[0] == NULL)
-		{
-			fprintf(stderr, "Can't allocate memory for alpha channel in PNG file.\n");
+		if (alpha[0] == NULL) {
+			fprintf(stderr,
+				"Can't allocate memory for alpha channel in PNG file.\n");
 			goto png_destroy;
 			goto png_destroy;
 		}
 		}
 	}
 	}
 
 
 	/* Change a paletted/grayscale image to RGB */
 	/* Change a paletted/grayscale image to RGB */
-	if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8) 
+	if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8)
 		png_set_expand(png_ptr);
 		png_set_expand(png_ptr);
 
 
 	/* Change a grayscale image to RGB */
 	/* Change a grayscale image to RGB */
-	if (color_type == PNG_COLOR_TYPE_GRAY 
-		|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+	if (color_type == PNG_COLOR_TYPE_GRAY ||
+		color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
 		png_set_gray_to_rgb(png_ptr);
 		png_set_gray_to_rgb(png_ptr);
 
 
 	/* If the PNG file has 16 bits per channel, strip them down to 8 */
 	/* If the PNG file has 16 bits per channel, strip them down to 8 */
@@ -115,7 +117,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	for (i = 0; i < *height; i++) {
 	for (i = 0; i < *height; i++) {
 		row_pointers[i] = malloc(4 * *width);
 		row_pointers[i] = malloc(4 * *width);
 		if (row_pointers == NULL) {
 		if (row_pointers == NULL) {
-			fprintf(stderr, "Can't allocate memory for PNG line.\n");
+			fprintf(stderr,
+				"Can't allocate memory for PNG line.\n");
 			goto rows_free;
 			goto rows_free;
 		}
 		}
 	}
 	}
@@ -128,8 +131,7 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 		goto rows_free;
 		goto rows_free;
 	}
 	}
 
 
-	if (alpha[0] == NULL)
-	{
+	if (alpha[0] == NULL) {
 		ptr = rgb[0];
 		ptr = rgb[0];
 		for (i = 0; i < *height; i++) {
 		for (i = 0; i < *height; i++) {
 			memcpy(ptr, row_pointers[i], 3 * *width);
 			memcpy(ptr, row_pointers[i], 3 * *width);
@@ -144,7 +146,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
-				alpha[0][i * *width + j] = row_pointers[i][ipos++];
+				alpha[0][i * *width + j]
+					= row_pointers[i][ipos++];
 			}
 			}
 		}
 		}
 	}
 	}
@@ -153,9 +156,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 
 
 rows_free:
 rows_free:
 	for (i = 0; i < *height; i++) {
 	for (i = 0; i < *height; i++) {
-		if (row_pointers[i] != NULL ) {
+		if (row_pointers[i] != NULL)
 			free(row_pointers[i]);
 			free(row_pointers[i]);
-		}
 	}
 	}
 
 
 	free(row_pointers);
 	free(row_pointers);
@@ -165,5 +167,5 @@ png_destroy:
 
 
 file_close:
 file_close:
 	fclose(infile);
 	fclose(infile);
-	return(ret);
+	return ret;
 }
 }