|
@@ -76,9 +76,10 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
|
|
|
panelpng = themedir + "/panel.jpg";
|
|
|
loaded = image->Read(panelpng.c_str());
|
|
|
if (!loaded) {
|
|
|
- cerr << APPNAME << ": could not load panel image for theme '"
|
|
|
- << basename((char*)themedir.c_str()) << "'"
|
|
|
- << endl;
|
|
|
+ cerr << APPNAME
|
|
|
+ << ": could not load panel image for theme '"
|
|
|
+ << basename((char*)themedir.c_str()) << "'"
|
|
|
+ << endl;
|
|
|
exit(ERR_EXIT);
|
|
|
}
|
|
|
}
|
|
@@ -92,9 +93,10 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
|
|
|
panelpng = themedir + "/background.jpg";
|
|
|
loaded = bg->Read(panelpng.c_str());
|
|
|
if (!loaded){
|
|
|
- cerr << APPNAME << ": could not load background image for theme '"
|
|
|
- << basename((char*)themedir.c_str()) << "'"
|
|
|
- << endl;
|
|
|
+ cerr << APPNAME
|
|
|
+ << ": could not load background image for theme '"
|
|
|
+ << basename((char*)themedir.c_str()) << "'"
|
|
|
+ << endl;
|
|
|
exit(ERR_EXIT);
|
|
|
}
|
|
|
}
|
|
@@ -104,15 +106,17 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
|
|
|
} else if (bgstyle == "tile") {
|
|
|
bg->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
|
|
|
} else if (bgstyle == "center") {
|
|
|
- string hexvalue = cfg->getOption("background_color");
|
|
|
+ string hexvalue = cfg->getOption("background_color");
|
|
|
hexvalue = hexvalue.substr(1,6);
|
|
|
- bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
- hexvalue.c_str());
|
|
|
+ bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
+ XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
+ hexvalue.c_str());
|
|
|
} else { // plain color or error
|
|
|
- string hexvalue = cfg->getOption("background_color");
|
|
|
+ string hexvalue = cfg->getOption("background_color");
|
|
|
hexvalue = hexvalue.substr(1,6);
|
|
|
- bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
- hexvalue.c_str());
|
|
|
+ bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
+ XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
|
|
|
+ hexvalue.c_str());
|
|
|
}
|
|
|
|
|
|
string cfgX = cfg->getOption("input_panel_x");
|
|
@@ -128,9 +132,6 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
|
|
|
// Read (and substitute vars in) the welcome message
|
|
|
welcome_message = cfg->getWelcomeMessage();
|
|
|
intro_message = cfg->getOption("intro_msg");
|
|
|
-
|
|
|
- // Init In
|
|
|
- In = new Input(cfg);
|
|
|
}
|
|
|
|
|
|
Panel::~Panel() {
|
|
@@ -144,7 +145,6 @@ Panel::~Panel() {
|
|
|
XftFontClose(Dpy, introfont);
|
|
|
XftFontClose(Dpy, welcomefont);
|
|
|
XftFontClose(Dpy, enterfont);
|
|
|
- delete In;
|
|
|
delete image;
|
|
|
|
|
|
}
|
|
@@ -182,7 +182,7 @@ void Panel::ClosePanel() {
|
|
|
|
|
|
void Panel::ClearPanel() {
|
|
|
session = "";
|
|
|
- In->Reset();
|
|
|
+ Reset();
|
|
|
XClearWindow(Dpy, Root);
|
|
|
XClearWindow(Dpy, Win);
|
|
|
Cursor(SHOW);
|
|
@@ -190,13 +190,13 @@ void Panel::ClearPanel() {
|
|
|
XFlush(Dpy);
|
|
|
}
|
|
|
|
|
|
-void Panel::Message(const char* text) {
|
|
|
+void Panel::Message(const string& text) {
|
|
|
string cfgX, cfgY;
|
|
|
XGlyphInfo extents;
|
|
|
XftDraw *draw = XftDrawCreate(Dpy, Root,
|
|
|
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
|
|
|
- XftTextExtents8(Dpy, msgfont, (XftChar8*)text,
|
|
|
- strlen(text), &extents);
|
|
|
+ XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(text.c_str()),
|
|
|
+ text.length(), &extents);
|
|
|
cfgX = cfg->getOption("msg_x");
|
|
|
cfgY = cfg->getOption("msg_y");
|
|
|
int shadowXOffset =
|
|
@@ -208,14 +208,14 @@ void Panel::Message(const char* text) {
|
|
|
int msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
|
|
|
|
|
|
SlimDrawString8 (draw, &msgcolor, msgfont, msg_x, msg_y,
|
|
|
- (XftChar8*)text, strlen(text),
|
|
|
+ text,
|
|
|
&msgshadowcolor,
|
|
|
shadowXOffset, shadowYOffset);
|
|
|
XFlush(Dpy);
|
|
|
XftDrawDestroy(draw);
|
|
|
}
|
|
|
|
|
|
-void Panel::Error(const char* text) {
|
|
|
+void Panel::Error(const string& text) {
|
|
|
ClosePanel();
|
|
|
Message(text);
|
|
|
sleep(ERROR_DURATION);
|
|
@@ -224,10 +224,6 @@ void Panel::Error(const char* text) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-Input* Panel::GetInput() {
|
|
|
- return In;
|
|
|
-}
|
|
|
-
|
|
|
unsigned long Panel::GetColor(const char* colorname) {
|
|
|
XColor color;
|
|
|
XWindowAttributes attributes;
|
|
@@ -244,31 +240,24 @@ unsigned long Panel::GetColor(const char* colorname) {
|
|
|
}
|
|
|
|
|
|
void Panel::Cursor(int visible) {
|
|
|
- char* text;
|
|
|
+ const char* text;
|
|
|
int xx, yy, y2, cheight;
|
|
|
char* txth = "Wj"; // used to get cursor height
|
|
|
|
|
|
- switch(In->GetField()) {
|
|
|
- case GET_PASSWD:
|
|
|
- text = In->GetHiddenPasswd();
|
|
|
+ switch(field) {
|
|
|
+ case Get_Passwd:
|
|
|
+ text = HiddenPasswdBuffer.c_str();
|
|
|
xx = input_pass_x;
|
|
|
yy = input_pass_y;
|
|
|
break;
|
|
|
|
|
|
- case GET_NAME:
|
|
|
- text = In->GetName();
|
|
|
+ case Get_Name:
|
|
|
+ text = NameBuffer.c_str();
|
|
|
xx = input_name_x;
|
|
|
yy = input_name_y;
|
|
|
break;
|
|
|
-
|
|
|
- default: /* Origin & NULL string as default values. */
|
|
|
- text = (char *)NULL;
|
|
|
- xx = (int)0;
|
|
|
- yy = (int)0;
|
|
|
- break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
XGlyphInfo extents;
|
|
|
XftTextExtents8(Dpy, font, (XftChar8*)txth, strlen(txth), &extents);
|
|
|
cheight = extents.height;
|
|
@@ -288,49 +277,53 @@ void Panel::Cursor(int visible) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-int Panel::EventHandler(XEvent* event) {
|
|
|
- Action = WAIT;
|
|
|
-
|
|
|
- switch(event->type) {
|
|
|
- case Expose:
|
|
|
- OnExpose(event);
|
|
|
- break;
|
|
|
+void Panel::EventHandler(const Panel::FieldType& curfield) {
|
|
|
+ XEvent event;
|
|
|
+ field=curfield;
|
|
|
+ bool loop = true;
|
|
|
+ OnExpose();
|
|
|
+ while(loop) {
|
|
|
+ XNextEvent(Dpy, &event);
|
|
|
+ switch(event.type) {
|
|
|
+ case Expose:
|
|
|
+ OnExpose();
|
|
|
+ break;
|
|
|
|
|
|
- case KeyPress:
|
|
|
- OnKeyPress(event);
|
|
|
- break;
|
|
|
+ case KeyPress:
|
|
|
+ loop=OnKeyPress(event);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return Action;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
-void Panel::OnExpose(XEvent* event) {
|
|
|
- char* name = In->GetName();
|
|
|
- char* passwd = In->GetHiddenPasswd();
|
|
|
+void Panel::OnExpose(void) {
|
|
|
XftDraw *draw = XftDrawCreate(Dpy, Win,
|
|
|
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
|
|
|
+ XClearWindow(Dpy, Win);
|
|
|
if (input_pass_x != input_name_x || input_pass_y != input_name_y){
|
|
|
SlimDrawString8 (draw, &inputcolor, font, input_name_x, input_name_y,
|
|
|
- (XftChar8*)name, strlen(name),
|
|
|
+ NameBuffer,
|
|
|
&inputshadowcolor,
|
|
|
inputShadowXOffset, inputShadowYOffset);
|
|
|
SlimDrawString8 (draw, &inputcolor, font, input_pass_x, input_pass_y,
|
|
|
- (XftChar8*)passwd, strlen(passwd),
|
|
|
+ HiddenPasswdBuffer,
|
|
|
&inputshadowcolor,
|
|
|
inputShadowXOffset, inputShadowYOffset);
|
|
|
} else { //single input mode
|
|
|
- switch(In->GetField()) {
|
|
|
- case GET_PASSWD:
|
|
|
+ switch(field) {
|
|
|
+ case Get_Passwd:
|
|
|
SlimDrawString8 (draw, &inputcolor, font,
|
|
|
input_pass_x, input_pass_y,
|
|
|
- (XftChar8*)passwd, strlen(passwd),
|
|
|
+ HiddenPasswdBuffer,
|
|
|
&inputshadowcolor,
|
|
|
inputShadowXOffset, inputShadowYOffset);
|
|
|
break;
|
|
|
- case GET_NAME:
|
|
|
+ case Get_Name:
|
|
|
SlimDrawString8 (draw, &inputcolor, font,
|
|
|
input_name_x, input_name_y,
|
|
|
- (XftChar8*)name, strlen(name),
|
|
|
+ NameBuffer,
|
|
|
&inputshadowcolor,
|
|
|
inputShadowXOffset, inputShadowYOffset);
|
|
|
break;
|
|
@@ -342,108 +335,153 @@ void Panel::OnExpose(XEvent* event) {
|
|
|
ShowText();
|
|
|
}
|
|
|
|
|
|
-void Panel::OnKeyPress(XEvent* event) {
|
|
|
- char del;
|
|
|
- char buffer;
|
|
|
+bool Panel::OnKeyPress(XEvent& event) {
|
|
|
+ char ascii;
|
|
|
KeySym keysym;
|
|
|
XComposeStatus compstatus;
|
|
|
int xx;
|
|
|
int yy;
|
|
|
- char* text;
|
|
|
+ string text;
|
|
|
+ string formerString = "";
|
|
|
+
|
|
|
+ XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus);
|
|
|
+ switch(keysym){
|
|
|
+ case XK_F1:
|
|
|
+ SwitchSession();
|
|
|
+ return true;
|
|
|
+
|
|
|
+ case XK_F11:
|
|
|
+ // Take a screenshot
|
|
|
+ system(cfg->getOption("screenshot_cmd").c_str());
|
|
|
+ return true;
|
|
|
+
|
|
|
+ case XK_Return:
|
|
|
+ case XK_KP_Enter:
|
|
|
+ if (field==Get_Name){
|
|
|
+ // Don't allow an empty username
|
|
|
+ if (NameBuffer.empty()) return true;
|
|
|
+
|
|
|
+ if (NameBuffer==CONSOLE_STR){
|
|
|
+ action = Console;
|
|
|
+ } else if (NameBuffer==HALT_STR){
|
|
|
+ action = Halt;
|
|
|
+ } else if (NameBuffer==REBOOT_STR){
|
|
|
+ action = Reboot;
|
|
|
+ } else if (NameBuffer==SUSPEND_STR){
|
|
|
+ action = Suspend;
|
|
|
+ } else if (NameBuffer==EXIT_STR){
|
|
|
+ action = Exit;
|
|
|
+ } else{
|
|
|
+ action = Login;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return false;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ };
|
|
|
|
|
|
- bool singleInputMode =
|
|
|
- input_name_x == input_pass_x &&
|
|
|
- input_name_y == input_pass_y;
|
|
|
Cursor(HIDE);
|
|
|
- XLookupString(&event->xkey, &buffer, 1, &keysym, &compstatus);
|
|
|
- del = In->Key(buffer, keysym, singleInputMode);
|
|
|
- Action = In->GetAction();
|
|
|
+ switch(keysym){
|
|
|
+ case XK_Delete:
|
|
|
+ case XK_BackSpace:
|
|
|
+ switch(field) {
|
|
|
+ case GET_NAME:
|
|
|
+ if (! NameBuffer.empty()){
|
|
|
+ formerString=NameBuffer;
|
|
|
+ NameBuffer.erase(--NameBuffer.end());
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case GET_PASSWD:
|
|
|
+ if (! PasswdBuffer.empty()){
|
|
|
+ formerString=HiddenPasswdBuffer;
|
|
|
+ PasswdBuffer.erase(--PasswdBuffer.end());
|
|
|
+ HiddenPasswdBuffer.erase(--HiddenPasswdBuffer.end());
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ break;
|
|
|
+
|
|
|
+ case XK_w:
|
|
|
+ case XK_u:
|
|
|
+ if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) {
|
|
|
+ switch(field) {
|
|
|
+ case Get_Passwd:
|
|
|
+ formerString = HiddenPasswdBuffer;
|
|
|
+ HiddenPasswdBuffer.clear();
|
|
|
+ PasswdBuffer.clear();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Get_Name:
|
|
|
+ formerString = NameBuffer;
|
|
|
+ NameBuffer.clear();
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // Deliberate fall-through
|
|
|
+
|
|
|
+ default:
|
|
|
+ if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){
|
|
|
+ switch(field) {
|
|
|
+ case GET_NAME:
|
|
|
+ formerString=NameBuffer;
|
|
|
+ if (NameBuffer.length() < INPUT_MAXLENGTH_NAME-1){
|
|
|
+ NameBuffer.append(&ascii,1);
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case GET_PASSWD:
|
|
|
+ formerString=HiddenPasswdBuffer;
|
|
|
+ if (PasswdBuffer.length() < INPUT_MAXLENGTH_NAME-1){
|
|
|
+ PasswdBuffer.append(&ascii,1);
|
|
|
+ HiddenPasswdBuffer.append("*");
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ };
|
|
|
|
|
|
XGlyphInfo extents;
|
|
|
XftDraw *draw = XftDrawCreate(Dpy, Win,
|
|
|
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
|
|
|
|
|
|
- if (keysym == XK_F1) {
|
|
|
- SwitchSession();
|
|
|
- }
|
|
|
-
|
|
|
- bool clearField = false;
|
|
|
- string formerString = "";
|
|
|
- if ((((XKeyEvent*)event)->state & ControlMask)) {
|
|
|
- if (keysym == XK_w || keysym == XK_u) {
|
|
|
- clearField = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- switch(In->GetField()) {
|
|
|
- case GET_PASSWD:
|
|
|
- if (strlen(In->GetHiddenPasswd()) == 0){
|
|
|
- // clear name and welcome label if we just entered the
|
|
|
- // password field
|
|
|
- if (singleInputMode) {
|
|
|
- xx = input_name_x;
|
|
|
- yy = input_name_y;
|
|
|
- text = In->GetName();
|
|
|
- XftTextExtents8(Dpy, font, (XftChar8*)text,
|
|
|
- strlen(text), &extents);
|
|
|
- XClearWindow(Dpy, Win);
|
|
|
- ShowText();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (clearField) {
|
|
|
- formerString = In->GetHiddenPasswd();
|
|
|
- In->ResetPassword();
|
|
|
- }
|
|
|
- text = In->GetHiddenPasswd();
|
|
|
- xx = input_pass_x;
|
|
|
- yy = input_pass_y;
|
|
|
- break;
|
|
|
-
|
|
|
- case GET_NAME:
|
|
|
- if (clearField) {
|
|
|
- formerString = In->GetName();
|
|
|
- In->ResetName();
|
|
|
- }
|
|
|
- text = In->GetName();
|
|
|
+ switch(field) {
|
|
|
+ case Get_Name:
|
|
|
+ text = NameBuffer;
|
|
|
xx = input_name_x;
|
|
|
yy = input_name_y;
|
|
|
break;
|
|
|
|
|
|
- default: /* Origin & NULL string as default values. */
|
|
|
- text = (char *)NULL;
|
|
|
- xx = (int)0;
|
|
|
- yy = (int)0;
|
|
|
- break;
|
|
|
+ case Get_Passwd:
|
|
|
+ text = HiddenPasswdBuffer;
|
|
|
+ xx = input_pass_x;
|
|
|
+ yy = input_pass_y;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- char* txth = "Wj"; // get proper maximum height ?
|
|
|
- XftTextExtents8(Dpy, font, (XftChar8*)txth, strlen(txth), &extents);
|
|
|
- int maxHeight = extents.height;
|
|
|
+ if (!formerString.empty()){
|
|
|
+ char* txth = "Wj"; // get proper maximum height ?
|
|
|
+ XftTextExtents8(Dpy, font, reinterpret_cast<const XftChar8*>(txth), strlen(txth), &extents);
|
|
|
+ int maxHeight = extents.height;
|
|
|
|
|
|
- string tmp = "";
|
|
|
- if (clearField) {
|
|
|
- tmp = formerString;
|
|
|
- } else {
|
|
|
- tmp = text;
|
|
|
- tmp = tmp + del;
|
|
|
- }
|
|
|
- XftTextExtents8(Dpy, font, (XftChar8*)tmp.c_str(),
|
|
|
- strlen(tmp.c_str()), &extents);
|
|
|
- int maxLength = extents.width;
|
|
|
+ XftTextExtents8(Dpy, font, reinterpret_cast<const XftChar8*>(formerString.c_str()),
|
|
|
+ formerString.length(), &extents);
|
|
|
+ int maxLength = extents.width;
|
|
|
|
|
|
- XClearArea(Dpy, Win, xx-3, yy-maxHeight-3,
|
|
|
- maxLength+6, maxHeight+6, false);
|
|
|
+ XClearArea(Dpy, Win, xx-3, yy-maxHeight-3,
|
|
|
+ maxLength+6, maxHeight+6, false);
|
|
|
+ }
|
|
|
|
|
|
- if (!clearField) {
|
|
|
+ if (!text.empty()) {
|
|
|
SlimDrawString8 (draw, &inputcolor, font, xx, yy,
|
|
|
- (XftChar8*)text, strlen(text),
|
|
|
+ text,
|
|
|
&inputshadowcolor,
|
|
|
inputShadowXOffset, inputShadowYOffset);
|
|
|
}
|
|
|
|
|
|
XftDrawDestroy (draw);
|
|
|
Cursor(SHOW);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
// Draw welcome and "enter username" message
|
|
@@ -471,14 +509,13 @@ void Panel::ShowText(){
|
|
|
if (welcome_x >= 0 && welcome_y >= 0) {
|
|
|
SlimDrawString8 (draw, &welcomecolor, welcomefont,
|
|
|
welcome_x, welcome_y,
|
|
|
- (XftChar8*)welcome_message.c_str(),
|
|
|
- strlen(welcome_message.c_str()),
|
|
|
+ welcome_message,
|
|
|
&welcomeshadowcolor, shadowXOffset, shadowYOffset);
|
|
|
}
|
|
|
|
|
|
/* Enter username-password message */
|
|
|
string msg;
|
|
|
- if (!singleInputMode|| In->GetField() == GET_PASSWD ) {
|
|
|
+ if (!singleInputMode|| field == Get_Passwd ) {
|
|
|
msg = cfg->getOption("password_msg");
|
|
|
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(),
|
|
|
strlen(msg.c_str()), &extents);
|
|
@@ -492,11 +529,10 @@ void Panel::ShowText(){
|
|
|
password_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
|
|
|
if (password_x >= 0 && password_y >= 0){
|
|
|
SlimDrawString8 (draw, &entercolor, enterfont, password_x, password_y,
|
|
|
- (XftChar8*)msg.c_str(), strlen(msg.c_str()),
|
|
|
- &entershadowcolor, shadowXOffset, shadowYOffset);
|
|
|
+ msg, &entershadowcolor, shadowXOffset, shadowYOffset);
|
|
|
}
|
|
|
}
|
|
|
- if (!singleInputMode|| In->GetField() == GET_NAME ) {
|
|
|
+ if (!singleInputMode|| field == Get_Name ) {
|
|
|
msg = cfg->getOption("username_msg");
|
|
|
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(),
|
|
|
strlen(msg.c_str()), &extents);
|
|
@@ -510,8 +546,7 @@ void Panel::ShowText(){
|
|
|
username_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
|
|
|
if (username_x >= 0 && username_y >= 0){
|
|
|
SlimDrawString8 (draw, &entercolor, enterfont, username_x, username_y,
|
|
|
- (XftChar8*)msg.c_str(), strlen(msg.c_str()),
|
|
|
- &entershadowcolor, shadowXOffset, shadowYOffset);
|
|
|
+ msg, &entershadowcolor, shadowXOffset, shadowYOffset);
|
|
|
}
|
|
|
}
|
|
|
XftDrawDestroy(draw);
|
|
@@ -533,12 +568,11 @@ void Panel::SwitchSession() {
|
|
|
void Panel::ShowSession() {
|
|
|
XClearWindow(Dpy, Root);
|
|
|
string currsession = "Session: " + session;
|
|
|
- char* text = (char*) currsession.c_str();
|
|
|
XGlyphInfo extents;
|
|
|
XftDraw *draw = XftDrawCreate(Dpy, Root,
|
|
|
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
|
|
|
- XftTextExtents8(Dpy, msgfont, (XftChar8*)text,
|
|
|
- strlen(text), &extents);
|
|
|
+ XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
|
|
|
+ currsession.length(), &extents);
|
|
|
int msg_x = Cfg::absolutepos("50%", XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
|
|
|
int msg_y = XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - extents.height -100;
|
|
|
int shadowXOffset =
|
|
@@ -547,7 +581,7 @@ void Panel::ShowSession() {
|
|
|
Cfg::string2int(cfg->getOption("msg_shadow_yoffset").c_str());
|
|
|
|
|
|
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y,
|
|
|
- (XftChar8*)text, strlen(text),
|
|
|
+ currsession,
|
|
|
&msgshadowcolor,
|
|
|
shadowXOffset, shadowYOffset);
|
|
|
XFlush(Dpy);
|
|
@@ -556,13 +590,44 @@ void Panel::ShowSession() {
|
|
|
|
|
|
|
|
|
void Panel::SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
|
|
|
- int x, int y, XftChar8 *string, int len,
|
|
|
+ int x, int y, const string& str,
|
|
|
XftColor* shadowColor,
|
|
|
int xOffset, int yOffset)
|
|
|
{
|
|
|
if (xOffset && yOffset) {
|
|
|
XftDrawString8(d, shadowColor, font, x+xOffset, y+yOffset,
|
|
|
- string, len);
|
|
|
+ reinterpret_cast<const FcChar8*>(str.c_str()), str.length());
|
|
|
}
|
|
|
- XftDrawString8(d, color, font, x, y, string, len);
|
|
|
+ XftDrawString8(d, color, font, x, y, reinterpret_cast<const FcChar8*>(str.c_str()), str.length());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+Panel::ActionType Panel::getAction(void) const{
|
|
|
+ return action;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+void Panel::Reset(void){
|
|
|
+ ResetName();
|
|
|
+ ResetPasswd();
|
|
|
+};
|
|
|
+
|
|
|
+void Panel::ResetName(void){
|
|
|
+ NameBuffer.clear();
|
|
|
+};
|
|
|
+
|
|
|
+void Panel::ResetPasswd(void){
|
|
|
+ PasswdBuffer.clear();
|
|
|
+ HiddenPasswdBuffer.clear();
|
|
|
+};
|
|
|
+
|
|
|
+void Panel::SetName(const string& name){
|
|
|
+ NameBuffer=name;
|
|
|
+ return;
|
|
|
+};
|
|
|
+const string& Panel::GetName(void) const{
|
|
|
+ return NameBuffer;
|
|
|
+};
|
|
|
+const string& Panel::GetPasswd(void) const{
|
|
|
+ return PasswdBuffer;
|
|
|
+};
|