Lines 13-18
Link Here
|
13 |
#include <poll.h> |
13 |
#include <poll.h> |
14 |
#include <X11/extensions/Xrandr.h> |
14 |
#include <X11/extensions/Xrandr.h> |
15 |
#include "panel.h" |
15 |
#include "panel.h" |
|
|
16 |
#include "util.h" |
16 |
|
17 |
|
17 |
using namespace std; |
18 |
using namespace std; |
18 |
|
19 |
|
Lines 78-83
Link Here
|
78 |
XftColorAllocName(Dpy, visual, colormap, |
79 |
XftColorAllocName(Dpy, visual, colormap, |
79 |
cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor); |
80 |
cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor); |
80 |
|
81 |
|
|
|
82 |
/* Build XIC and XIM to be able to get unicode string from keyboard events */ |
83 |
char classname = 0; |
84 |
displayIc = NULL; |
85 |
displayIm = XOpenIM(Dpy, NULL, &classname, &classname); |
86 |
if(displayIm) { |
87 |
displayIc = XCreateIC(displayIm, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
88 |
XNResourceName, &classname, |
89 |
XNResourceClass, &classname, NULL); |
90 |
} |
81 |
/* Load properties from config / theme */ |
91 |
/* Load properties from config / theme */ |
82 |
input_name_x = cfg->getIntOption("input_name_x"); |
92 |
input_name_x = cfg->getIntOption("input_name_x"); |
83 |
input_name_y = cfg->getIntOption("input_name_y"); |
93 |
input_name_y = cfg->getIntOption("input_name_y"); |
Lines 91-96
Link Here
|
91 |
input_pass_y = input_name_y; |
101 |
input_pass_y = input_name_y; |
92 |
} |
102 |
} |
93 |
|
103 |
|
|
|
104 |
Reset(); |
105 |
|
94 |
/* Load panel and background image */ |
106 |
/* Load panel and background image */ |
95 |
string panelpng = ""; |
107 |
string panelpng = ""; |
96 |
panelpng = panelpng + themedir +"/panel.png"; |
108 |
panelpng = panelpng + themedir +"/panel.png"; |
Lines 210-215
Link Here
|
210 |
Visual* visual = DefaultVisual(Dpy, Scr); |
222 |
Visual* visual = DefaultVisual(Dpy, Scr); |
211 |
Colormap colormap = DefaultColormap(Dpy, Scr); |
223 |
Colormap colormap = DefaultColormap(Dpy, Scr); |
212 |
|
224 |
|
|
|
225 |
if(displayIc) { |
226 |
XDestroyIC(displayIc); |
227 |
} |
228 |
if(displayIm) { |
229 |
XCloseIM(displayIm); |
230 |
} |
213 |
XftColorFree(Dpy, visual, colormap, &inputcolor); |
231 |
XftColorFree(Dpy, visual, colormap, &inputcolor); |
214 |
XftColorFree(Dpy, visual, colormap, &inputshadowcolor); |
232 |
XftColorFree(Dpy, visual, colormap, &inputshadowcolor); |
215 |
XftColorFree(Dpy, visual, colormap, &welcomecolor); |
233 |
XftColorFree(Dpy, visual, colormap, &welcomecolor); |
Lines 289-295
Link Here
|
289 |
|
307 |
|
290 |
XftDraw *draw = XftDrawCreate(Dpy, Win, |
308 |
XftDraw *draw = XftDrawCreate(Dpy, Win, |
291 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
309 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
292 |
XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(message.c_str()), |
310 |
|
|
|
311 |
XftTextExtentsUtf8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(message.c_str()), |
293 |
message.length(), &extents); |
312 |
message.length(), &extents); |
294 |
|
313 |
|
295 |
string cfgX = cfg->getOption("passwd_feedback_x"); |
314 |
string cfgX = cfg->getOption("passwd_feedback_x"); |
Lines 300-306
Link Here
|
300 |
int msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height); |
319 |
int msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height); |
301 |
|
320 |
|
302 |
OnExpose(); |
321 |
OnExpose(); |
303 |
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y, message, |
322 |
SlimDrawStringUtf8(draw, &msgcolor, msgfont, msg_x, msg_y, message, |
304 |
&msgshadowcolor, shadowXOffset, shadowYOffset); |
323 |
&msgshadowcolor, shadowXOffset, shadowYOffset); |
305 |
|
324 |
|
306 |
if (cfg->getOption("bell") == "1") |
325 |
if (cfg->getOption("bell") == "1") |
Lines 312-318
Link Here
|
312 |
OnExpose(); |
331 |
OnExpose(); |
313 |
// The message should stay on the screen even after the password field is |
332 |
// The message should stay on the screen even after the password field is |
314 |
// cleared, methinks. I don't like this solution, but it works. |
333 |
// cleared, methinks. I don't like this solution, but it works. |
315 |
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y, message, |
334 |
SlimDrawStringUtf8(draw, &msgcolor, msgfont, msg_x, msg_y, message, |
316 |
&msgshadowcolor, shadowXOffset, shadowYOffset); |
335 |
&msgshadowcolor, shadowXOffset, shadowYOffset); |
317 |
XSync(Dpy, True); |
336 |
XSync(Dpy, True); |
318 |
XftDrawDestroy(draw); |
337 |
XftDrawDestroy(draw); |
Lines 330-338
Link Here
|
330 |
draw = XftDrawCreate(Dpy, Root, |
349 |
draw = XftDrawCreate(Dpy, Root, |
331 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
350 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
332 |
|
351 |
|
333 |
XftTextExtents8(Dpy, msgfont, |
352 |
XftTextExtentsUtf8(Dpy, msgfont, |
334 |
reinterpret_cast<const XftChar8*>(text.c_str()), |
353 |
reinterpret_cast<const XftChar8*>(text.c_str()), text.length(), &extents); |
335 |
text.length(), &extents); |
|
|
336 |
cfgX = cfg->getOption("msg_x"); |
354 |
cfgX = cfg->getOption("msg_x"); |
337 |
cfgY = cfg->getOption("msg_y"); |
355 |
cfgY = cfg->getOption("msg_y"); |
338 |
int shadowXOffset = cfg->getIntOption("msg_shadow_xoffset"); |
356 |
int shadowXOffset = cfg->getIntOption("msg_shadow_xoffset"); |
Lines 347-355
Link Here
|
347 |
msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height); |
365 |
msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height); |
348 |
} |
366 |
} |
349 |
|
367 |
|
350 |
SlimDrawString8 (draw, &msgcolor, msgfont, msg_x, msg_y, |
368 |
SlimDrawStringUtf8(draw, &msgcolor, msgfont, msg_x, msg_y, |
351 |
text, |
369 |
text, &msgshadowcolor, |
352 |
&msgshadowcolor, |
|
|
353 |
shadowXOffset, shadowYOffset); |
370 |
shadowXOffset, shadowYOffset); |
354 |
XFlush(Dpy); |
371 |
XFlush(Dpy); |
355 |
XftDrawDestroy(draw); |
372 |
XftDrawDestroy(draw); |
Lines 383-406
Link Here
|
383 |
} |
400 |
} |
384 |
|
401 |
|
385 |
void Panel::Cursor(int visible) { |
402 |
void Panel::Cursor(int visible) { |
386 |
const char* text = NULL; |
403 |
const uint16_t* text = NULL; |
387 |
int xx = 0, yy = 0, y2 = 0, cheight = 0; |
404 |
int xx = 0, yy = 0, y2 = 0, cheight = 0, textLen = 0; |
388 |
const char* txth = "Wj"; /* used to get cursor height */ |
405 |
const char* txth = "Wj"; /* used to get cursor height */ |
389 |
|
406 |
|
390 |
if (mode == Mode_Lock) { |
407 |
if (mode == Mode_Lock) { |
391 |
text = HiddenPasswdBuffer.c_str(); |
408 |
text = hiddenPasswdBuffer; |
|
|
409 |
textLen = passwdBufferLen; |
392 |
xx = input_pass_x; |
410 |
xx = input_pass_x; |
393 |
yy = input_pass_y; |
411 |
yy = input_pass_y; |
394 |
} else { |
412 |
} else { |
395 |
switch(field) { |
413 |
switch(field) { |
396 |
case Get_Passwd: |
414 |
case Get_Passwd: |
397 |
text = HiddenPasswdBuffer.c_str(); |
415 |
text = hiddenPasswdBuffer; |
|
|
416 |
textLen = passwdBufferLen; |
398 |
xx = input_pass_x; |
417 |
xx = input_pass_x; |
399 |
yy = input_pass_y; |
418 |
yy = input_pass_y; |
400 |
break; |
419 |
break; |
401 |
|
420 |
|
402 |
case Get_Name: |
421 |
case Get_Name: |
403 |
text = NameBuffer.c_str(); |
422 |
text = nameBuffer; |
|
|
423 |
textLen = nameBufferLen; |
404 |
xx = input_name_x; |
424 |
xx = input_name_x; |
405 |
yy = input_name_y; |
425 |
yy = input_name_y; |
406 |
break; |
426 |
break; |
Lines 411-417
Link Here
|
411 |
XftTextExtents8(Dpy, font, (XftChar8*)txth, strlen(txth), &extents); |
431 |
XftTextExtents8(Dpy, font, (XftChar8*)txth, strlen(txth), &extents); |
412 |
cheight = extents.height; |
432 |
cheight = extents.height; |
413 |
y2 = yy - extents.y + extents.height; |
433 |
y2 = yy - extents.y + extents.height; |
414 |
XftTextExtents8(Dpy, font, (XftChar8*)text, strlen(text), &extents); |
434 |
XftTextExtents16(Dpy, font, (XftChar16*)text, textLen, &extents); |
415 |
xx += extents.width; |
435 |
xx += extents.width; |
416 |
|
436 |
|
417 |
if(visible == SHOW) { |
437 |
if(visible == SHOW) { |
Lines 478-504
Link Here
|
478 |
XClearWindow(Dpy, Win); |
498 |
XClearWindow(Dpy, Win); |
479 |
|
499 |
|
480 |
if (input_pass_x != input_name_x || input_pass_y != input_name_y){ |
500 |
if (input_pass_x != input_name_x || input_pass_y != input_name_y){ |
481 |
SlimDrawString8 (draw, &inputcolor, font, input_name_x, input_name_y, |
501 |
SlimDrawString16(draw, &inputcolor, font, input_name_x, input_name_y, |
482 |
NameBuffer, |
502 |
nameBuffer, nameBufferLen, &inputshadowcolor, |
483 |
&inputshadowcolor, |
|
|
484 |
inputShadowXOffset, inputShadowYOffset); |
503 |
inputShadowXOffset, inputShadowYOffset); |
485 |
SlimDrawString8 (draw, &inputcolor, font, input_pass_x, input_pass_y, |
504 |
SlimDrawString16(draw, &inputcolor, font, input_pass_x, input_pass_y, |
486 |
HiddenPasswdBuffer, |
505 |
hiddenPasswdBuffer, passwdBufferLen, &inputshadowcolor, |
487 |
&inputshadowcolor, |
|
|
488 |
inputShadowXOffset, inputShadowYOffset); |
506 |
inputShadowXOffset, inputShadowYOffset); |
489 |
} else { /*single input mode */ |
507 |
} else { /*single input mode */ |
490 |
switch(field) { |
508 |
switch(field) { |
491 |
case Get_Passwd: |
509 |
case Get_Passwd: |
492 |
SlimDrawString8 (draw, &inputcolor, font, |
510 |
SlimDrawString16(draw, &inputcolor, font, |
493 |
input_pass_x, input_pass_y, |
511 |
input_pass_x, input_pass_y, |
494 |
HiddenPasswdBuffer, |
512 |
hiddenPasswdBuffer, passwdBufferLen, |
495 |
&inputshadowcolor, |
513 |
&inputshadowcolor, |
496 |
inputShadowXOffset, inputShadowYOffset); |
514 |
inputShadowXOffset, inputShadowYOffset); |
497 |
break; |
515 |
break; |
498 |
case Get_Name: |
516 |
case Get_Name: |
499 |
SlimDrawString8 (draw, &inputcolor, font, |
517 |
SlimDrawString16(draw, &inputcolor, font, |
500 |
input_name_x, input_name_y, |
518 |
input_name_x, input_name_y, |
501 |
NameBuffer, |
519 |
nameBuffer, nameBufferLen, |
502 |
&inputshadowcolor, |
520 |
&inputshadowcolor, |
503 |
inputShadowXOffset, inputShadowYOffset); |
521 |
inputShadowXOffset, inputShadowYOffset); |
504 |
break; |
522 |
break; |
Lines 510-544
Link Here
|
510 |
ShowText(); |
528 |
ShowText(); |
511 |
} |
529 |
} |
512 |
|
530 |
|
513 |
void Panel::EraseLastChar(string &formerString) { |
531 |
int Panel::FieldEraseLastChar(const uint16_t **buf, int *len) { |
|
|
532 |
|
533 |
static const uint16_t emptyBuf = 0; |
534 |
int formerTextBufferLen = 0; |
535 |
|
514 |
switch(field) { |
536 |
switch(field) { |
515 |
case GET_NAME: |
537 |
case Get_Name: |
516 |
if (! NameBuffer.empty()) { |
538 |
formerTextBufferLen = nameBufferLen; |
517 |
formerString=NameBuffer; |
539 |
if (nameBufferLen > 0) { |
518 |
NameBuffer.erase(--NameBuffer.end()); |
540 |
nameBufferLen--; |
519 |
} |
541 |
} |
|
|
542 |
*buf = nameBuffer; |
543 |
*len = nameBufferLen; |
520 |
break; |
544 |
break; |
521 |
|
545 |
|
522 |
case GET_PASSWD: |
546 |
case Get_Passwd: |
523 |
if (!PasswdBuffer.empty()) { |
547 |
formerTextBufferLen = passwdBufferLen; |
524 |
formerString=HiddenPasswdBuffer; |
548 |
if (passwdBufferLen > 0) { |
525 |
PasswdBuffer.erase(--PasswdBuffer.end()); |
549 |
passwdBufferLen--; |
526 |
HiddenPasswdBuffer.erase(--HiddenPasswdBuffer.end()); |
550 |
passwdBuffer[passwdBufferLen] = 0; |
527 |
} |
551 |
} |
|
|
552 |
*buf = hiddenPasswdBuffer; |
553 |
*len = passwdBufferLen; |
554 |
break; |
555 |
|
556 |
default: |
557 |
*buf = &emptyBuf; |
558 |
*len = 0; |
528 |
break; |
559 |
break; |
529 |
} |
560 |
} |
|
|
561 |
return formerTextBufferLen; |
530 |
} |
562 |
} |
531 |
|
563 |
|
|
|
564 |
int Panel::FieldClear(const uint16_t **buf, int *len) { |
565 |
|
566 |
static const uint16_t emptyBuf = 0; |
567 |
int formerTextBufferLen = 0; |
568 |
|
569 |
switch(field) { |
570 |
case Get_Name: |
571 |
formerTextBufferLen = nameBufferLen; |
572 |
nameBufferLen = 0; |
573 |
*buf = nameBuffer; |
574 |
*len = nameBufferLen; |
575 |
break; |
576 |
|
577 |
case Get_Passwd: |
578 |
formerTextBufferLen = passwdBufferLen; |
579 |
memset(passwdBuffer, 0, sizeof(passwdBuffer)); |
580 |
passwdBufferLen = 0; |
581 |
*buf = hiddenPasswdBuffer; |
582 |
*len = passwdBufferLen; |
583 |
break; |
584 |
|
585 |
default: |
586 |
*buf = &emptyBuf; |
587 |
*len = 0; |
588 |
break; |
589 |
} |
590 |
return formerTextBufferLen; |
591 |
} |
592 |
|
593 |
/* Check if the input character is allowed */ |
594 |
bool Panel::isUtf16CharAllowed(uint16_t c) { |
595 |
return ((0x020 <= c && c <= 0x07E) || (0x0A0 <= c && c != 0x0AD)); |
596 |
} |
597 |
|
598 |
#define SIZE_BUFFER_KEY_PRESS 64 |
599 |
|
532 |
bool Panel::OnKeyPress(XEvent& event) { |
600 |
bool Panel::OnKeyPress(XEvent& event) { |
533 |
char ascii; |
601 |
int formerTextBufferLen = -1; |
|
|
602 |
int textBufferLen = -1; |
603 |
const uint16_t *textBuffer = NULL; |
534 |
KeySym keysym; |
604 |
KeySym keysym; |
|
|
605 |
int nbReadBuf = -1; |
606 |
uint16_t utf16buf[SIZE_BUFFER_KEY_PRESS]; |
607 |
if(displayIc) |
608 |
{ |
609 |
Status status; |
610 |
char databuf[SIZE_BUFFER_KEY_PRESS]; |
611 |
nbReadBuf = Xutf8LookupString(displayIc, &event.xkey, databuf, |
612 |
SIZE_BUFFER_KEY_PRESS, &keysym, &status); |
613 |
if(nbReadBuf > 0) { |
614 |
nbReadBuf = Util::utf8ToUtf16(databuf, nbReadBuf, |
615 |
utf16buf, SIZE_BUFFER_KEY_PRESS); |
616 |
} |
617 |
} |
618 |
else |
619 |
{ |
535 |
XComposeStatus compstatus; |
620 |
XComposeStatus compstatus; |
536 |
int xx = 0; |
621 |
char databuf[SIZE_BUFFER_KEY_PRESS]; |
537 |
int yy = 0; |
622 |
nbReadBuf = XLookupString(&event.xkey, databuf, |
538 |
string text; |
623 |
SIZE_BUFFER_KEY_PRESS, &keysym, &compstatus); |
539 |
string formerString = ""; |
624 |
if(nbReadBuf > 0) { |
|
|
625 |
nbReadBuf = Util::utf8ToUtf16(databuf, nbReadBuf, |
626 |
utf16buf, SIZE_BUFFER_KEY_PRESS); |
627 |
} |
628 |
} |
540 |
|
629 |
|
541 |
XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus); |
|
|
542 |
switch(keysym){ |
630 |
switch(keysym){ |
543 |
case XK_F1: |
631 |
case XK_F1: |
544 |
SwitchSession(); |
632 |
SwitchSession(); |
Lines 553-569
Link Here
|
553 |
case XK_KP_Enter: |
641 |
case XK_KP_Enter: |
554 |
if (field==Get_Name){ |
642 |
if (field==Get_Name){ |
555 |
/* Don't allow an empty username */ |
643 |
/* Don't allow an empty username */ |
556 |
if (NameBuffer.empty()) return true; |
644 |
if (nameBufferLen <= 0) return true; |
557 |
|
645 |
|
558 |
if (NameBuffer==CONSOLE_STR){ |
646 |
if (Util::utf16EqualToAscii(CONSOLE_STR, nameBuffer, nameBufferLen)) { |
559 |
action = Console; |
647 |
action = Console; |
560 |
} else if (NameBuffer==HALT_STR){ |
648 |
} else if (Util::utf16EqualToAscii(HALT_STR, nameBuffer, nameBufferLen)) { |
561 |
action = Halt; |
649 |
action = Halt; |
562 |
} else if (NameBuffer==REBOOT_STR){ |
650 |
} else if (Util::utf16EqualToAscii(REBOOT_STR, nameBuffer, nameBufferLen)) { |
563 |
action = Reboot; |
651 |
action = Reboot; |
564 |
} else if (NameBuffer==SUSPEND_STR){ |
652 |
} else if (Util::utf16EqualToAscii(SUSPEND_STR, nameBuffer, nameBufferLen)) { |
565 |
action = Suspend; |
653 |
action = Suspend; |
566 |
} else if (NameBuffer==EXIT_STR){ |
654 |
} else if (Util::utf16EqualToAscii(EXIT_STR, nameBuffer, nameBufferLen)) { |
567 |
action = Exit; |
655 |
action = Exit; |
568 |
} else{ |
656 |
} else{ |
569 |
if (mode == Mode_DM) |
657 |
if (mode == Mode_DM) |
Lines 581-660
Link Here
|
581 |
switch(keysym){ |
669 |
switch(keysym){ |
582 |
case XK_Delete: |
670 |
case XK_Delete: |
583 |
case XK_BackSpace: |
671 |
case XK_BackSpace: |
584 |
EraseLastChar(formerString); |
672 |
formerTextBufferLen = FieldEraseLastChar(&textBuffer, &textBufferLen); |
585 |
break; |
673 |
break; |
586 |
|
674 |
|
587 |
case XK_w: |
675 |
case XK_w: |
588 |
case XK_u: |
676 |
case XK_u: |
589 |
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) { |
677 |
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) { |
590 |
switch(field) { |
678 |
formerTextBufferLen = FieldClear(&textBuffer, &textBufferLen); |
591 |
case Get_Passwd: |
|
|
592 |
formerString = HiddenPasswdBuffer; |
593 |
HiddenPasswdBuffer.clear(); |
594 |
PasswdBuffer.clear(); |
595 |
break; |
596 |
case Get_Name: |
597 |
formerString = NameBuffer; |
598 |
NameBuffer.clear(); |
599 |
break; |
600 |
} |
601 |
break; |
679 |
break; |
602 |
} |
680 |
} |
603 |
case XK_h: |
681 |
case XK_h: |
604 |
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) { |
682 |
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) { |
605 |
EraseLastChar(formerString); |
683 |
formerTextBufferLen = FieldEraseLastChar(&textBuffer, &textBufferLen); |
606 |
break; |
684 |
break; |
607 |
} |
685 |
} |
608 |
/* Deliberate fall-through */ |
686 |
/* Deliberate fall-through */ |
609 |
|
687 |
|
610 |
default: |
688 |
default: |
611 |
if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){ |
689 |
if(nbReadBuf > 0) { |
612 |
switch(field) { |
690 |
switch(field) { |
613 |
case GET_NAME: |
691 |
case Get_Name: |
614 |
formerString=NameBuffer; |
692 |
formerTextBufferLen = nameBufferLen; |
615 |
if (NameBuffer.length() < INPUT_MAXLENGTH_NAME-1){ |
693 |
for(int i = 0; i < nbReadBuf && |
616 |
NameBuffer.append(&ascii,1); |
694 |
nameBufferLen < INPUT_MAXLENGTH_NAME; i++) { |
617 |
}; |
695 |
|
|
|
696 |
if(isUtf16CharAllowed(utf16buf[i])) { |
697 |
nameBuffer[nameBufferLen++] = utf16buf[i]; |
698 |
} |
699 |
} |
700 |
textBuffer = nameBuffer; |
701 |
textBufferLen = nameBufferLen; |
618 |
break; |
702 |
break; |
619 |
case GET_PASSWD: |
703 |
|
620 |
formerString=HiddenPasswdBuffer; |
704 |
case Get_Passwd: |
621 |
if (PasswdBuffer.length() < INPUT_MAXLENGTH_PASSWD-1){ |
705 |
formerTextBufferLen = passwdBufferLen; |
622 |
PasswdBuffer.append(&ascii,1); |
706 |
for(int i = 0; i < nbReadBuf && |
623 |
HiddenPasswdBuffer.append("*"); |
707 |
passwdBufferLen < INPUT_MAXLENGTH_PASSWD; i++) { |
624 |
}; |
708 |
|
|
|
709 |
if(isUtf16CharAllowed(utf16buf[i])) { |
710 |
passwdBuffer[passwdBufferLen] = utf16buf[i]; |
711 |
hiddenPasswdBuffer[passwdBufferLen++] = (uint16_t)'*'; |
712 |
} |
713 |
} |
714 |
textBuffer = hiddenPasswdBuffer; |
715 |
textBufferLen = passwdBufferLen; |
625 |
break; |
716 |
break; |
626 |
}; |
717 |
} |
627 |
}; |
718 |
} |
628 |
break; |
719 |
break; |
629 |
}; |
720 |
}; |
630 |
|
721 |
|
631 |
XGlyphInfo extents; |
722 |
int xx = 0, yy = 0; |
632 |
XftDraw *draw = XftDrawCreate(Dpy, Win, |
723 |
if (formerTextBufferLen > 0 || textBufferLen > 0) { |
633 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
|
|
634 |
|
724 |
|
635 |
switch(field) { |
725 |
switch(field) { |
636 |
case Get_Name: |
726 |
case Get_Name: |
637 |
text = NameBuffer; |
|
|
638 |
xx = input_name_x; |
727 |
xx = input_name_x; |
639 |
yy = input_name_y; |
728 |
yy = input_name_y; |
640 |
break; |
729 |
break; |
641 |
|
730 |
|
642 |
case Get_Passwd: |
731 |
case Get_Passwd: |
643 |
text = HiddenPasswdBuffer; |
|
|
644 |
xx = input_pass_x; |
732 |
xx = input_pass_x; |
645 |
yy = input_pass_y; |
733 |
yy = input_pass_y; |
646 |
break; |
734 |
break; |
647 |
} |
735 |
} |
|
|
736 |
} |
648 |
|
737 |
|
649 |
if (!formerString.empty()){ |
738 |
if (formerTextBufferLen > 0) { |
|
|
739 |
XGlyphInfo extents; |
650 |
const char* txth = "Wj"; /* get proper maximum height ? */ |
740 |
const char* txth = "Wj"; /* get proper maximum height ? */ |
651 |
XftTextExtents8(Dpy, font, |
741 |
XftTextExtents8(Dpy, font, |
652 |
reinterpret_cast<const XftChar8*>(txth), strlen(txth), &extents); |
742 |
reinterpret_cast<const XftChar8*>(txth), strlen(txth), &extents); |
653 |
int maxHeight = extents.height; |
743 |
int maxHeight = extents.height; |
654 |
|
744 |
|
655 |
XftTextExtents8(Dpy, font, |
745 |
XftTextExtents16(Dpy, font, (XftChar16*)textBuffer, formerTextBufferLen, &extents); |
656 |
reinterpret_cast<const XftChar8*>(formerString.c_str()), |
|
|
657 |
formerString.length(), &extents); |
658 |
int maxLength = extents.width; |
746 |
int maxLength = extents.width; |
659 |
|
747 |
|
660 |
if (mode == Mode_Lock) |
748 |
if (mode == Mode_Lock) |
Lines 666-679
Link Here
|
666 |
maxLength + 6, maxHeight + 6, false); |
754 |
maxLength + 6, maxHeight + 6, false); |
667 |
} |
755 |
} |
668 |
|
756 |
|
669 |
if (!text.empty()) { |
757 |
if(textBufferLen > 0) { |
670 |
SlimDrawString8 (draw, &inputcolor, font, xx, yy, |
758 |
XftDraw *draw = XftDrawCreate(Dpy, Win, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
671 |
text, |
759 |
if(draw != NULL) { |
672 |
&inputshadowcolor, |
760 |
SlimDrawString16(draw, &inputcolor, font, xx, yy, textBuffer, textBufferLen, |
673 |
inputShadowXOffset, inputShadowYOffset); |
761 |
&inputshadowcolor, inputShadowXOffset, inputShadowYOffset); |
|
|
762 |
XftDrawDestroy(draw); |
763 |
} |
674 |
} |
764 |
} |
675 |
|
765 |
|
676 |
XftDrawDestroy (draw); |
|
|
677 |
Cursor(SHOW); |
766 |
Cursor(SHOW); |
678 |
return true; |
767 |
return true; |
679 |
} |
768 |
} |
Lines 690-696
Link Here
|
690 |
XftDraw *draw = XftDrawCreate(Dpy, Win, |
779 |
XftDraw *draw = XftDrawCreate(Dpy, Win, |
691 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
780 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
692 |
/* welcome message */ |
781 |
/* welcome message */ |
693 |
XftTextExtents8(Dpy, welcomefont, (XftChar8*)welcome_message.c_str(), |
782 |
XftTextExtentsUtf8(Dpy, welcomefont, (XftChar8*)welcome_message.c_str(), |
694 |
strlen(welcome_message.c_str()), &extents); |
783 |
strlen(welcome_message.c_str()), &extents); |
695 |
cfgX = cfg->getOption("welcome_x"); |
784 |
cfgX = cfg->getOption("welcome_x"); |
696 |
cfgY = cfg->getOption("welcome_y"); |
785 |
cfgY = cfg->getOption("welcome_y"); |
Lines 700-708
Link Here
|
700 |
welcome_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
789 |
welcome_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
701 |
welcome_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
790 |
welcome_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
702 |
if (welcome_x >= 0 && welcome_y >= 0) { |
791 |
if (welcome_x >= 0 && welcome_y >= 0) { |
703 |
SlimDrawString8 (draw, &welcomecolor, welcomefont, |
792 |
SlimDrawStringUtf8(draw, &welcomecolor, welcomefont, |
704 |
welcome_x, welcome_y, |
793 |
welcome_x, welcome_y, welcome_message, |
705 |
welcome_message, |
|
|
706 |
&welcomeshadowcolor, shadowXOffset, shadowYOffset); |
794 |
&welcomeshadowcolor, shadowXOffset, shadowYOffset); |
707 |
} |
795 |
} |
708 |
|
796 |
|
Lines 710-716
Link Here
|
710 |
string msg; |
798 |
string msg; |
711 |
if ((!singleInputMode|| field == Get_Passwd) && mode == Mode_DM) { |
799 |
if ((!singleInputMode|| field == Get_Passwd) && mode == Mode_DM) { |
712 |
msg = cfg->getOption("password_msg"); |
800 |
msg = cfg->getOption("password_msg"); |
713 |
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(), |
801 |
XftTextExtentsUtf8(Dpy, enterfont, (XftChar8*)msg.c_str(), |
714 |
strlen(msg.c_str()), &extents); |
802 |
strlen(msg.c_str()), &extents); |
715 |
cfgX = cfg->getOption("password_x"); |
803 |
cfgX = cfg->getOption("password_x"); |
716 |
cfgY = cfg->getOption("password_y"); |
804 |
cfgY = cfg->getOption("password_y"); |
Lines 719-732
Link Here
|
719 |
password_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
807 |
password_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
720 |
password_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
808 |
password_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
721 |
if (password_x >= 0 && password_y >= 0){ |
809 |
if (password_x >= 0 && password_y >= 0){ |
722 |
SlimDrawString8 (draw, &entercolor, enterfont, password_x, password_y, |
810 |
SlimDrawStringUtf8(draw, &entercolor, enterfont, password_x, password_y, |
723 |
msg, &entershadowcolor, shadowXOffset, shadowYOffset); |
811 |
msg, &entershadowcolor, shadowXOffset, shadowYOffset); |
724 |
} |
812 |
} |
725 |
} |
813 |
} |
726 |
|
814 |
|
727 |
if (!singleInputMode|| field == Get_Name) { |
815 |
if (!singleInputMode|| field == Get_Name) { |
728 |
msg = cfg->getOption("username_msg"); |
816 |
msg = cfg->getOption("username_msg"); |
729 |
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(), |
817 |
XftTextExtentsUtf8(Dpy, enterfont, (XftChar8*)msg.c_str(), |
730 |
strlen(msg.c_str()), &extents); |
818 |
strlen(msg.c_str()), &extents); |
731 |
cfgX = cfg->getOption("username_x"); |
819 |
cfgX = cfg->getOption("username_x"); |
732 |
cfgY = cfg->getOption("username_y"); |
820 |
cfgY = cfg->getOption("username_y"); |
Lines 735-741
Link Here
|
735 |
username_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
823 |
username_x = Cfg::absolutepos(cfgX, image->Width(), extents.width); |
736 |
username_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
824 |
username_y = Cfg::absolutepos(cfgY, image->Height(), extents.height); |
737 |
if (username_x >= 0 && username_y >= 0){ |
825 |
if (username_x >= 0 && username_y >= 0){ |
738 |
SlimDrawString8 (draw, &entercolor, enterfont, username_x, username_y, |
826 |
SlimDrawStringUtf8(draw, &entercolor, enterfont, username_x, username_y, |
739 |
msg, &entershadowcolor, shadowXOffset, shadowYOffset); |
827 |
msg, &entershadowcolor, shadowXOffset, shadowYOffset); |
740 |
} |
828 |
} |
741 |
} |
829 |
} |
Lines 776-782
Link Here
|
776 |
|
864 |
|
777 |
XftDraw *draw = XftDrawCreate(Dpy, Root, |
865 |
XftDraw *draw = XftDrawCreate(Dpy, Root, |
778 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
866 |
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr)); |
779 |
XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()), |
867 |
XftTextExtentsUtf8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()), |
780 |
currsession.length(), &extents); |
868 |
currsession.length(), &extents); |
781 |
msg_x = cfg->getOption("session_x"); |
869 |
msg_x = cfg->getOption("session_x"); |
782 |
msg_y = cfg->getOption("session_y"); |
870 |
msg_y = cfg->getOption("session_y"); |
Lines 785-800
Link Here
|
785 |
int shadowXOffset = cfg->getIntOption("session_shadow_xoffset"); |
873 |
int shadowXOffset = cfg->getIntOption("session_shadow_xoffset"); |
786 |
int shadowYOffset = cfg->getIntOption("session_shadow_yoffset"); |
874 |
int shadowYOffset = cfg->getIntOption("session_shadow_yoffset"); |
787 |
|
875 |
|
788 |
SlimDrawString8(draw, &sessioncolor, sessionfont, x, y, |
876 |
SlimDrawStringUtf8(draw, &sessioncolor, sessionfont, x, y, |
789 |
currsession, |
877 |
currsession, &sessionshadowcolor, shadowXOffset, shadowYOffset); |
790 |
&sessionshadowcolor, |
|
|
791 |
shadowXOffset, shadowYOffset); |
792 |
XFlush(Dpy); |
878 |
XFlush(Dpy); |
793 |
XftDrawDestroy(draw); |
879 |
XftDrawDestroy(draw); |
794 |
} |
880 |
} |
795 |
|
881 |
|
|
|
882 |
void Panel::SlimDrawString16(XftDraw *d, XftColor *color, XftFont *font, |
883 |
int x, int y, const uint16_t *str, int strLen, |
884 |
XftColor* shadowColor, int xOffset, int yOffset) |
885 |
{ |
886 |
int calc_x = 0; |
887 |
int calc_y = 0; |
888 |
if (mode == Mode_Lock) { |
889 |
calc_x = viewport.x; |
890 |
calc_y = viewport.y; |
891 |
} |
892 |
|
893 |
if (xOffset && yOffset) { |
894 |
XftDrawString16(d, shadowColor, font, |
895 |
x + xOffset + calc_x, |
896 |
y + yOffset + calc_y, |
897 |
(XftChar16*)str, strLen); |
898 |
} |
899 |
|
900 |
XftDrawString16(d, color, font, |
901 |
x + calc_x, |
902 |
y + calc_y, |
903 |
(XftChar16*)str, strLen); |
904 |
} |
796 |
|
905 |
|
797 |
void Panel::SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font, |
906 |
void Panel::SlimDrawStringUtf8(XftDraw *d, XftColor *color, XftFont *font, |
798 |
int x, int y, const string& str, |
907 |
int x, int y, const string& str, |
799 |
XftColor* shadowColor, |
908 |
XftColor* shadowColor, |
800 |
int xOffset, int yOffset) |
909 |
int xOffset, int yOffset) |
Lines 831-858
Link Here
|
831 |
} |
940 |
} |
832 |
|
941 |
|
833 |
void Panel::ResetName(void){ |
942 |
void Panel::ResetName(void){ |
834 |
NameBuffer.clear(); |
943 |
nameBufferLen = 0; |
|
|
944 |
memset(nameBuffer, 0, sizeof(nameBuffer)); |
835 |
} |
945 |
} |
836 |
|
946 |
|
837 |
void Panel::ResetPasswd(void){ |
947 |
void Panel::ResetPasswd(void){ |
838 |
PasswdBuffer.clear(); |
948 |
passwdBufferLen = 0; |
839 |
HiddenPasswdBuffer.clear(); |
949 |
memset(passwdBuffer, 0, sizeof(passwdBuffer)); |
|
|
950 |
memset(hiddenPasswdBuffer, 0, sizeof(hiddenPasswdBuffer)); |
840 |
} |
951 |
} |
841 |
|
952 |
|
842 |
void Panel::SetName(const string& name){ |
953 |
void Panel::SetName(const string& name){ |
843 |
NameBuffer=name; |
954 |
nameBufferLen = Util::utf8ToUtf16(name.c_str(), name.length(), |
|
|
955 |
nameBuffer, INPUT_MAXLENGTH_NAME); |
844 |
if (mode == Mode_DM) |
956 |
if (mode == Mode_DM) |
845 |
action = Login; |
957 |
action = Login; |
846 |
else |
958 |
else |
847 |
action = Lock; |
959 |
action = Lock; |
848 |
} |
960 |
} |
849 |
|
961 |
|
850 |
const string& Panel::GetName(void) const{ |
962 |
const string Panel::GetName(void) const{ |
851 |
return NameBuffer; |
963 |
return Util::utf16BufToUtf8String(nameBuffer, nameBufferLen); |
852 |
} |
964 |
} |
853 |
|
965 |
|
854 |
const string& Panel::GetPasswd(void) const{ |
966 |
const string Panel::GetPasswd(void) const{ |
855 |
return PasswdBuffer; |
967 |
return Util::utf16BufToUtf8String(passwdBuffer, passwdBufferLen); |
856 |
} |
968 |
} |
857 |
|
969 |
|
858 |
Rectangle Panel::GetPrimaryViewport() { |
970 |
Rectangle Panel::GetPrimaryViewport() { |