Add slimlock and add some function for this · data-modul/slim@fccae89 · GitHub
Skip to content

Commit fccae89

Browse files
committed
Add slimlock and add some function for this
I received a request to be included slimlock[0] in the slim slimlock from Diego Principe. This is first step to import the source code of slimlock. [0]: http://joelburget.com/slimlock/ Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
1 parent ea681f0 commit fccae89

11 files changed

Lines changed: 927 additions & 53 deletions

File tree

CMakeLists.txt

Lines changed: 29 additions & 1 deletion

app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void App::Run() {
315315
HideCursor();
316316

317317
/* Create panel */
318-
LoginPanel = new Panel(Dpy, Scr, Root, cfg, themedir);
318+
LoginPanel = new Panel(Dpy, Scr, Root, cfg, themedir, Panel::Mode_DM);
319319
bool firstloop = true; /* 1st time panel is shown (for automatic username) */
320320
bool focuspass = cfg->getOption("focus_password")=="yes";
321321
bool autologin = cfg->getOption("auto_login")=="yes";

cfg.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ Cfg::Cfg()
120120
options.insert(option("session_shadow_yoffset", "0"));
121121
options.insert(option("session_shadow_color","#FFFFFF"));
122122

123+
// slimlock-specific options
124+
options.insert(option("dpms_standby_timeout", "60"));
125+
options.insert(option("dpms_off_timeout", "600"));
126+
options.insert(option("wrong_passwd_timeout", "2"));
127+
options.insert(option("passwd_feedback_x", "50%"));
128+
options.insert(option("passwd_feedback_y", "10%"));
129+
options.insert(option("passwd_feedback_msg", "Authentication failed"));
130+
options.insert(option("passwd_feedback_capslock", "Authentication failed (CapsLock is on)"));
131+
options.insert(option("show_username", "1"));
132+
options.insert(option("show_welcome_msg", "0"));
133+
options.insert(option("tty_lock", "1"));
134+
options.insert(option("bell", "1"));
135+
123136
error = "";
124137
}
125138

image.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,60 @@ void Image::Merge(Image* background, const int x, const int y) {
286286

287287
}
288288

289+
/* Merge the image with a background, taking care of the
290+
* image Alpha transparency. (background alpha is ignored).
291+
* The images is merged on position (x, y) on the
292+
* background, the background must contain the image.
293+
*/
294+
#define IMG_POS_RGB(p, x) (3 * p + x)
295+
void Image::Merge_non_crop(Image* background, const int x, const int y)
296+
{
297+
int bg_w = background->Width();
298+
int bg_h = background->Height();
299+
300+
if (x + width > bg_w || y + height > bg_h)
301+
return;
302+
303+
double tmp;
304+
unsigned char *new_rgb = (unsigned char *)malloc(3 * bg_w * bg_h);
305+
memset(new_rgb, 0, 3 * bg_w * bg_h);
306+
const unsigned char *bg_rgb = background->getRGBData();
307+
int pnl_pos = 0;
308+
int bg_pos = 0;
309+
int pnl_w_end = x + width;
310+
int pnl_h_end = y + height;
311+
312+
memcpy(new_rgb, bg_rgb, 3 * bg_w * bg_h);
313+
314+
for (int j = 0; j < bg_h; j++) {
315+
for (int i = 0; i < bg_w; i++) {
316+
if (j >= y && i >= x && j < pnl_h_end && i < pnl_w_end ) {
317+
for (int k = 0; k < 3; k++) {
318+
if (png_alpha != NULL)
319+
tmp = rgb_data[IMG_POS_RGB(pnl_pos, k)]
320+
* png_alpha[pnl_pos]/255.0
321+
+ bg_rgb[IMG_POS_RGB(bg_pos, k)]
322+
* (1 - png_alpha[pnl_pos]/255.0);
323+
else
324+
tmp = rgb_data[IMG_POS_RGB(pnl_pos, k)];
325+
326+
new_rgb[IMG_POS_RGB(bg_pos, k)] = static_cast<unsigned char>(tmp);
327+
}
328+
pnl_pos++;
329+
}
330+
bg_pos++;
331+
}
332+
}
333+
334+
width = bg_w;
335+
height = bg_h;
336+
337+
free(rgb_data);
338+
free(png_alpha);
339+
rgb_data = new_rgb;
340+
png_alpha = NULL;
341+
}
342+
289343
/* Tile the image growing its size to the minimum entire
290344
* multiple of w * h.
291345
* The new dimensions should be > of the current ones.
@@ -895,3 +949,4 @@ Image::readPng(const char *filename, int *width, int *height,
895949
fclose(infile);
896950
return(ret);
897951
}
952+

image.h

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)