18
18
19
19
using namespace std ;
20
20
21
- Panel::Panel (Display * dpy, int scr, Window root, Cfg * config,
21
+ Panel::Panel (Display * dpy, int scr, Window root, Cfg & config,
22
22
const string & themedir, PanelType panel_mode)
23
23
: Dpy(dpy), Scr(scr), Root(root), cfg(config), mode(panel_mode),
24
24
session_name(" " ), session_exec(" " )
@@ -50,47 +50,47 @@ Panel::Panel(Display * dpy, int scr, Window root, Cfg * config,
50
50
}
51
51
}
52
52
53
- font = XftFontOpenName (Dpy, Scr, cfg-> getOption (" input_font" ).c_str ());
53
+ font = XftFontOpenName (Dpy, Scr, cfg. getOption (" input_font" ).c_str ());
54
54
welcomefont =
55
- XftFontOpenName (Dpy, Scr, cfg-> getOption (" welcome_font" ).c_str ());
56
- introfont = XftFontOpenName (Dpy, Scr, cfg-> getOption (" intro_font" ).c_str ());
55
+ XftFontOpenName (Dpy, Scr, cfg. getOption (" welcome_font" ).c_str ());
56
+ introfont = XftFontOpenName (Dpy, Scr, cfg. getOption (" intro_font" ).c_str ());
57
57
enterfont =
58
- XftFontOpenName (Dpy, Scr, cfg-> getOption (" username_font" ).c_str ());
59
- msgfont = XftFontOpenName (Dpy, Scr, cfg-> getOption (" msg_font" ).c_str ());
58
+ XftFontOpenName (Dpy, Scr, cfg. getOption (" username_font" ).c_str ());
59
+ msgfont = XftFontOpenName (Dpy, Scr, cfg. getOption (" msg_font" ).c_str ());
60
60
61
61
Visual * visual = DefaultVisual (Dpy, Scr);
62
62
Colormap colormap = DefaultColormap (Dpy, Scr);
63
63
/* NOTE: using XftColorAllocValue() would be a better solution. Lazy me. */
64
64
XftColorAllocName (Dpy, visual, colormap,
65
- cfg-> getOption (" input_color" ).c_str (), &inputcolor);
65
+ cfg. getOption (" input_color" ).c_str (), &inputcolor);
66
66
XftColorAllocName (Dpy, visual, colormap,
67
- cfg-> getOption (" input_shadow_color" ).c_str (), &inputshadowcolor);
67
+ cfg. getOption (" input_shadow_color" ).c_str (), &inputshadowcolor);
68
68
XftColorAllocName (Dpy, visual, colormap,
69
- cfg-> getOption (" welcome_color" ).c_str (), &welcomecolor);
69
+ cfg. getOption (" welcome_color" ).c_str (), &welcomecolor);
70
70
XftColorAllocName (Dpy, visual, colormap,
71
- cfg-> getOption (" welcome_shadow_color" ).c_str (), &welcomeshadowcolor);
71
+ cfg. getOption (" welcome_shadow_color" ).c_str (), &welcomeshadowcolor);
72
72
XftColorAllocName (Dpy, visual, colormap,
73
- cfg-> getOption (" username_color" ).c_str (), &entercolor);
73
+ cfg. getOption (" username_color" ).c_str (), &entercolor);
74
74
XftColorAllocName (Dpy, visual, colormap,
75
- cfg-> getOption (" username_shadow_color" ).c_str (), &entershadowcolor);
75
+ cfg. getOption (" username_shadow_color" ).c_str (), &entershadowcolor);
76
76
XftColorAllocName (
77
- Dpy, visual, colormap, cfg-> getOption (" msg_color" ).c_str (), &msgcolor);
77
+ Dpy, visual, colormap, cfg. getOption (" msg_color" ).c_str (), &msgcolor);
78
78
XftColorAllocName (Dpy, visual, colormap,
79
- cfg-> getOption (" msg_shadow_color" ).c_str (), &msgshadowcolor);
79
+ cfg. getOption (" msg_shadow_color" ).c_str (), &msgshadowcolor);
80
80
XftColorAllocName (Dpy, visual, colormap,
81
- cfg-> getOption (" intro_color" ).c_str (), &introcolor);
81
+ cfg. getOption (" intro_color" ).c_str (), &introcolor);
82
82
XftColorAllocName (Dpy, visual, colormap,
83
- cfg-> getOption (" session_color" ).c_str (), &sessioncolor);
83
+ cfg. getOption (" session_color" ).c_str (), &sessioncolor);
84
84
XftColorAllocName (Dpy, visual, colormap,
85
- cfg-> getOption (" session_shadow_color" ).c_str (), &sessionshadowcolor);
85
+ cfg. getOption (" session_shadow_color" ).c_str (), &sessionshadowcolor);
86
86
87
87
/* Load properties from config / theme */
88
- input_name_x = cfg-> getIntOption (" input_name_x" );
89
- input_name_y = cfg-> getIntOption (" input_name_y" );
90
- input_pass_x = cfg-> getIntOption (" input_pass_x" );
91
- input_pass_y = cfg-> getIntOption (" input_pass_y" );
92
- inputShadowXOffset = cfg-> getIntOption (" input_shadow_xoffset" );
93
- inputShadowYOffset = cfg-> getIntOption (" input_shadow_yoffset" );
88
+ input_name_x = cfg. getIntOption (" input_name_x" );
89
+ input_name_y = cfg. getIntOption (" input_name_y" );
90
+ input_pass_x = cfg. getIntOption (" input_pass_x" );
91
+ input_pass_y = cfg. getIntOption (" input_pass_y" );
92
+ inputShadowXOffset = cfg. getIntOption (" input_shadow_xoffset" );
93
+ inputShadowYOffset = cfg. getIntOption (" input_shadow_yoffset" );
94
94
95
95
if (input_pass_x < 0 || input_pass_y < 0 ) { /* single inputbox mode */
96
96
input_pass_x = input_name_x;
@@ -113,7 +113,7 @@ Panel::Panel(Display * dpy, int scr, Window root, Cfg * config,
113
113
}
114
114
115
115
Image * bg = new Image ();
116
- string bgstyle = cfg-> getOption (" background_style" );
116
+ string bgstyle = cfg. getOption (" background_style" );
117
117
if (bgstyle != " color" ) {
118
118
panelpng = themedir + " /background.png" ;
119
119
loaded = bg->Read (panelpng.c_str ());
@@ -137,11 +137,11 @@ Panel::Panel(Display * dpy, int scr, Window root, Cfg * config,
137
137
else if (bgstyle == " tile" )
138
138
bg->Tile (viewport.width , viewport.height );
139
139
else if (bgstyle == " center" ) {
140
- string hexvalue = cfg-> getOption (" background_color" );
140
+ string hexvalue = cfg. getOption (" background_color" );
141
141
hexvalue = hexvalue.substr (1 , 6 );
142
142
bg->Center (viewport.width , viewport.height , hexvalue.c_str ());
143
143
} else { // plain color or error
144
- string hexvalue = cfg-> getOption (" background_color" );
144
+ string hexvalue = cfg. getOption (" background_color" );
145
145
hexvalue = hexvalue.substr (1 , 6 );
146
146
bg->Center (viewport.width , viewport.height , hexvalue.c_str ());
147
147
}
@@ -153,20 +153,20 @@ Panel::Panel(Display * dpy, int scr, Window root, Cfg * config,
153
153
bg->Tile (XWidthOfScreen (ScreenOfDisplay (Dpy, Scr)),
154
154
XHeightOfScreen (ScreenOfDisplay (Dpy, Scr)));
155
155
} else if (bgstyle == " center" ) {
156
- string hexvalue = cfg-> getOption (" background_color" );
156
+ string hexvalue = cfg. getOption (" background_color" );
157
157
hexvalue = hexvalue.substr (1 , 6 );
158
158
bg->Center (XWidthOfScreen (ScreenOfDisplay (Dpy, Scr)),
159
159
XHeightOfScreen (ScreenOfDisplay (Dpy, Scr)), hexvalue.c_str ());
160
160
} else { /* plain color or error */
161
- string hexvalue = cfg-> getOption (" background_color" );
161
+ string hexvalue = cfg. getOption (" background_color" );
162
162
hexvalue = hexvalue.substr (1 , 6 );
163
163
bg->Center (XWidthOfScreen (ScreenOfDisplay (Dpy, Scr)),
164
164
XHeightOfScreen (ScreenOfDisplay (Dpy, Scr)), hexvalue.c_str ());
165
165
}
166
166
}
167
167
168
- string cfgX = cfg-> getOption (" input_panel_x" );
169
- string cfgY = cfg-> getOption (" input_panel_y" );
168
+ string cfgX = cfg. getOption (" input_panel_x" );
169
+ string cfgY = cfg. getOption (" input_panel_y" );
170
170
171
171
if (mode == Mode_Lock) {
172
172
X = Cfg::absolutepos (cfgX, viewport.width , image->Width ());
@@ -195,8 +195,8 @@ Panel::Panel(Display * dpy, int scr, Window root, Cfg * config,
195
195
delete bg;
196
196
197
197
/* Read (and substitute vars in) the welcome message */
198
- welcome_message = cfg-> getWelcomeMessage ();
199
- intro_message = cfg-> getOption (" intro_msg" );
198
+ welcome_message = cfg. getWelcomeMessage ();
199
+ intro_message = cfg. getOption (" intro_msg" );
200
200
201
201
if (mode == Mode_Lock) {
202
202
SetName (getenv (" USER" ));
@@ -284,21 +284,21 @@ void Panel::WrongPassword(int timeout)
284
284
285
285
#if 0
286
286
if (CapsLockOn)
287
- message = cfg-> getOption("passwd_feedback_capslock");
287
+ message = cfg. getOption("passwd_feedback_capslock");
288
288
else
289
289
#endif
290
- message = cfg-> getOption (" passwd_feedback_msg" );
290
+ message = cfg. getOption (" passwd_feedback_msg" );
291
291
292
292
XftDraw * draw = XftDrawCreate (
293
293
Dpy, Win, DefaultVisual (Dpy, Scr), DefaultColormap (Dpy, Scr));
294
294
XftTextExtentsUtf8 (Dpy, msgfont,
295
295
reinterpret_cast <const XftChar8 *>(message.c_str ()), message.length (),
296
296
&extents);
297
297
298
- string cfgX = cfg-> getOption (" passwd_feedback_x" );
299
- string cfgY = cfg-> getOption (" passwd_feedback_y" );
300
- int shadowXOffset = cfg-> getIntOption (" msg_shadow_xoffset" );
301
- int shadowYOffset = cfg-> getIntOption (" msg_shadow_yoffset" );
298
+ string cfgX = cfg. getOption (" passwd_feedback_x" );
299
+ string cfgY = cfg. getOption (" passwd_feedback_y" );
300
+ int shadowXOffset = cfg. getIntOption (" msg_shadow_xoffset" );
301
+ int shadowYOffset = cfg. getIntOption (" msg_shadow_yoffset" );
302
302
int msg_x = Cfg::absolutepos (
303
303
cfgX, XWidthOfScreen (ScreenOfDisplay (Dpy, Scr)), extents.width );
304
304
int msg_y = Cfg::absolutepos (
@@ -308,7 +308,7 @@ void Panel::WrongPassword(int timeout)
308
308
SlimDrawString8 (draw, &msgcolor, msgfont, msg_x, msg_y, message,
309
309
&msgshadowcolor, shadowXOffset, shadowYOffset);
310
310
311
- if (cfg-> getOption (" bell" ) == " 1" )
311
+ if (cfg. getOption (" bell" ) == " 1" )
312
312
XBell (Dpy, 100 );
313
313
314
314
XFlush (Dpy);
@@ -339,10 +339,10 @@ void Panel::Message(const string & text)
339
339
XftTextExtentsUtf8 (Dpy, msgfont,
340
340
reinterpret_cast <const XftChar8 *>(text.c_str ()), text.length (),
341
341
&extents);
342
- cfgX = cfg-> getOption (" msg_x" );
343
- cfgY = cfg-> getOption (" msg_y" );
344
- int shadowXOffset = cfg-> getIntOption (" msg_shadow_xoffset" );
345
- int shadowYOffset = cfg-> getIntOption (" msg_shadow_yoffset" );
342
+ cfgX = cfg. getOption (" msg_x" );
343
+ cfgY = cfg. getOption (" msg_y" );
344
+ int shadowXOffset = cfg. getIntOption (" msg_shadow_xoffset" );
345
+ int shadowYOffset = cfg. getIntOption (" msg_shadow_yoffset" );
346
346
int msg_x, msg_y;
347
347
348
348
if (mode == Mode_Lock) {
@@ -430,7 +430,7 @@ void Panel::Cursor(int visible)
430
430
y2 += viewport.y ;
431
431
}
432
432
XSetForeground (
433
- Dpy, TextGC, GetColor (cfg-> getOption (" input_color" ).c_str ()));
433
+ Dpy, TextGC, GetColor (cfg. getOption (" input_color" ).c_str ()));
434
434
435
435
XDrawLine (Dpy, Win, TextGC, xx + 1 , yy - cheight, xx + 1 , y2);
436
436
} else {
@@ -551,7 +551,7 @@ bool Panel::OnKeyPress(XEvent & event)
551
551
552
552
case XK_F11:
553
553
/* Take a screenshot */
554
- system (cfg-> getOption (" screenshot_cmd" ).c_str ());
554
+ system (cfg. getOption (" screenshot_cmd" ).c_str ());
555
555
return true ;
556
556
557
557
case XK_Return:
@@ -697,10 +697,10 @@ void Panel::ShowText()
697
697
/* welcome message */
698
698
XftTextExtentsUtf8 (Dpy, welcomefont, (XftChar8 *)welcome_message.c_str (),
699
699
strlen (welcome_message.c_str ()), &extents);
700
- cfgX = cfg-> getOption (" welcome_x" );
701
- cfgY = cfg-> getOption (" welcome_y" );
702
- int shadowXOffset = cfg-> getIntOption (" welcome_shadow_xoffset" );
703
- int shadowYOffset = cfg-> getIntOption (" welcome_shadow_yoffset" );
700
+ cfgX = cfg. getOption (" welcome_x" );
701
+ cfgY = cfg. getOption (" welcome_y" );
702
+ int shadowXOffset = cfg. getIntOption (" welcome_shadow_xoffset" );
703
+ int shadowYOffset = cfg. getIntOption (" welcome_shadow_yoffset" );
704
704
705
705
welcome_x = Cfg::absolutepos (cfgX, image->Width (), extents.width );
706
706
welcome_y = Cfg::absolutepos (cfgY, image->Height (), extents.height );
@@ -712,13 +712,13 @@ void Panel::ShowText()
712
712
/* Enter username-password message */
713
713
string msg;
714
714
if ((!singleInputMode || field == Get_Passwd) && mode == Mode_DM) {
715
- msg = cfg-> getOption (" password_msg" );
715
+ msg = cfg. getOption (" password_msg" );
716
716
XftTextExtentsUtf8 (Dpy, enterfont, (XftChar8 *)msg.c_str (),
717
717
strlen (msg.c_str ()), &extents);
718
- cfgX = cfg-> getOption (" password_x" );
719
- cfgY = cfg-> getOption (" password_y" );
720
- int shadowXOffset = cfg-> getIntOption (" username_shadow_xoffset" );
721
- int shadowYOffset = cfg-> getIntOption (" username_shadow_yoffset" );
718
+ cfgX = cfg. getOption (" password_x" );
719
+ cfgY = cfg. getOption (" password_y" );
720
+ int shadowXOffset = cfg. getIntOption (" username_shadow_xoffset" );
721
+ int shadowYOffset = cfg. getIntOption (" username_shadow_yoffset" );
722
722
password_x = Cfg::absolutepos (cfgX, image->Width (), extents.width );
723
723
password_y = Cfg::absolutepos (cfgY, image->Height (), extents.height );
724
724
if (password_x >= 0 && password_y >= 0 ) {
@@ -729,13 +729,13 @@ void Panel::ShowText()
729
729
}
730
730
731
731
if (!singleInputMode || field == Get_Name) {
732
- msg = cfg-> getOption (" username_msg" );
732
+ msg = cfg. getOption (" username_msg" );
733
733
XftTextExtentsUtf8 (Dpy, enterfont, (XftChar8 *)msg.c_str (),
734
734
strlen (msg.c_str ()), &extents);
735
- cfgX = cfg-> getOption (" username_x" );
736
- cfgY = cfg-> getOption (" username_y" );
737
- int shadowXOffset = cfg-> getIntOption (" username_shadow_xoffset" );
738
- int shadowYOffset = cfg-> getIntOption (" username_shadow_yoffset" );
735
+ cfgX = cfg. getOption (" username_x" );
736
+ cfgY = cfg. getOption (" username_y" );
737
+ int shadowXOffset = cfg. getIntOption (" username_shadow_xoffset" );
738
+ int shadowYOffset = cfg. getIntOption (" username_shadow_yoffset" );
739
739
username_x = Cfg::absolutepos (cfgX, image->Width (), extents.width );
740
740
username_y = Cfg::absolutepos (cfgY, image->Height (), extents.height );
741
741
if (username_x >= 0 && username_y >= 0 ) {
@@ -749,7 +749,7 @@ void Panel::ShowText()
749
749
if (mode == Mode_Lock) {
750
750
// If only the password box is visible, draw the user name somewhere too
751
751
string user_msg = " User: " + GetName ();
752
- int show_username = cfg-> getIntOption (" show_username" );
752
+ int show_username = cfg. getIntOption (" show_username" );
753
753
if (singleInputMode && show_username) {
754
754
Message (user_msg);
755
755
}
@@ -761,7 +761,7 @@ string Panel::getSession() { return session_exec; }
761
761
/* choose next available session type */
762
762
void Panel::SwitchSession ()
763
763
{
764
- pair<string, string> ses = cfg-> nextSession ();
764
+ pair<string, string> ses = cfg. nextSession ();
765
765
session_name = ses.first ;
766
766
session_exec = ses.second ;
767
767
if (session_name.size () > 0 ) {
@@ -774,25 +774,25 @@ void Panel::ShowSession()
774
774
{
775
775
string msg_x, msg_y;
776
776
XClearWindow (Dpy, Root);
777
- string currsession = cfg-> getOption (" session_msg" ) + " " + session_name;
777
+ string currsession = cfg. getOption (" session_msg" ) + " " + session_name;
778
778
XGlyphInfo extents;
779
779
780
780
sessionfont =
781
- XftFontOpenName (Dpy, Scr, cfg-> getOption (" session_font" ).c_str ());
781
+ XftFontOpenName (Dpy, Scr, cfg. getOption (" session_font" ).c_str ());
782
782
783
783
XftDraw * draw = XftDrawCreate (
784
784
Dpy, Root, DefaultVisual (Dpy, Scr), DefaultColormap (Dpy, Scr));
785
785
XftTextExtentsUtf8 (Dpy, sessionfont,
786
786
reinterpret_cast <const XftChar8 *>(currsession.c_str ()),
787
787
currsession.length (), &extents);
788
- msg_x = cfg-> getOption (" session_x" );
789
- msg_y = cfg-> getOption (" session_y" );
788
+ msg_x = cfg. getOption (" session_x" );
789
+ msg_y = cfg. getOption (" session_y" );
790
790
int x = Cfg::absolutepos (
791
791
msg_x, XWidthOfScreen (ScreenOfDisplay (Dpy, Scr)), extents.width );
792
792
int y = Cfg::absolutepos (
793
793
msg_y, XHeightOfScreen (ScreenOfDisplay (Dpy, Scr)), extents.height );
794
- int shadowXOffset = cfg-> getIntOption (" session_shadow_xoffset" );
795
- int shadowYOffset = cfg-> getIntOption (" session_shadow_yoffset" );
794
+ int shadowXOffset = cfg. getIntOption (" session_shadow_xoffset" );
795
+ int shadowYOffset = cfg. getIntOption (" session_shadow_yoffset" );
796
796
797
797
SlimDrawString8 (draw, &sessioncolor, sessionfont, x, y, currsession,
798
798
&sessionshadowcolor, shadowXOffset, shadowYOffset);
0 commit comments