Fix wrong pointer -replace
and small cleanup.
This commit is contained in:
@@ -583,7 +583,7 @@ int create_pid_file(const char *pidfile, gboolean kill_running) {
|
|||||||
char buffer[64] = {
|
char buffer[64] = {
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
ssize_t l = read(fd, &buffer, 63);
|
ssize_t l = read(fd, &(buffer[0]), 63);
|
||||||
if (l > 1) {
|
if (l > 1) {
|
||||||
buffer[l] = 0;
|
buffer[l] = 0;
|
||||||
pid_t pid = g_ascii_strtoll(buffer, NULL, 0);
|
pid_t pid = g_ascii_strtoll(buffer, NULL, 0);
|
||||||
|
@@ -286,8 +286,8 @@ static gpointer read_input_thread(gpointer userdata) {
|
|||||||
if (FD_ISSET(fd, &rfds)) {
|
if (FD_ISSET(fd, &rfds)) {
|
||||||
ssize_t readbytes = 0;
|
ssize_t readbytes = 0;
|
||||||
if ((nread + 1024) > len) {
|
if ((nread + 1024) > len) {
|
||||||
line = g_realloc(line, (nread + 1024));
|
line = g_realloc(line, (len + 2048));
|
||||||
len = nread + 1024;
|
len = len + 2048;
|
||||||
}
|
}
|
||||||
readbytes = read(fd, &line[nread], 1023);
|
readbytes = read(fd, &line[nread], 1023);
|
||||||
if (readbytes > 0) {
|
if (readbytes > 0) {
|
||||||
|
@@ -251,10 +251,10 @@ textbox *textbox_create(widget *parent, WidgetType type, const char *name,
|
|||||||
tb->placeholder = g_markup_escape_text(placeholder, -1);
|
tb->placeholder = g_markup_escape_text(placeholder, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *password_mask_char =
|
const char *password_mask_char =
|
||||||
rofi_theme_get_string(WIDGET(tb), "password-mask", NULL);
|
rofi_theme_get_string(WIDGET(tb), "password-mask", NULL);
|
||||||
if (password_mask_char == NULL || (*password_mask_char) == '\0'){
|
if (password_mask_char == NULL || (*password_mask_char) == '\0') {
|
||||||
tb->password_mask_char = "*";
|
tb->password_mask_char = "*";
|
||||||
} else {
|
} else {
|
||||||
tb->password_mask_char = password_mask_char;
|
tb->password_mask_char = password_mask_char;
|
||||||
@@ -350,7 +350,7 @@ static void __textbox_update_pango_text(textbox *tb) {
|
|||||||
size_t mask_len = strlen(tb->password_mask_char);
|
size_t mask_len = strlen(tb->password_mask_char);
|
||||||
char string[text_len * mask_len + 1];
|
char string[text_len * mask_len + 1];
|
||||||
for (size_t offset = 0; offset < text_len * mask_len; offset += mask_len) {
|
for (size_t offset = 0; offset < text_len * mask_len; offset += mask_len) {
|
||||||
memcpy(string + offset, tb->password_mask_char, mask_len);
|
memcpy(string + offset, tb->password_mask_char, mask_len);
|
||||||
}
|
}
|
||||||
string[text_len * mask_len] = '\0';
|
string[text_len * mask_len] = '\0';
|
||||||
pango_layout_set_text(tb->layout, string, -1);
|
pango_layout_set_text(tb->layout, string, -1);
|
||||||
@@ -501,7 +501,6 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
textbox *tb = (textbox *)wid;
|
textbox *tb = (textbox *)wid;
|
||||||
int dot_offset = 0;
|
|
||||||
|
|
||||||
if (tb->changed) {
|
if (tb->changed) {
|
||||||
__textbox_update_pango_text(tb);
|
__textbox_update_pango_text(tb);
|
||||||
@@ -534,7 +533,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||||||
{
|
{
|
||||||
int rem =
|
int rem =
|
||||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||||
line_width - dot_offset);
|
line_width);
|
||||||
switch (pango_layout_get_alignment(tb->layout)) {
|
switch (pango_layout_get_alignment(tb->layout)) {
|
||||||
case PANGO_ALIGN_CENTER:
|
case PANGO_ALIGN_CENTER:
|
||||||
x = rem * (tb->xalign - 0.5);
|
x = rem * (tb->xalign - 0.5);
|
||||||
@@ -543,7 +542,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||||||
x = rem * (tb->xalign - 1.0);
|
x = rem * (tb->xalign - 1.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
x = rem * tb->xalign + dot_offset;
|
x = rem * tb->xalign;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x += widget_padding_get_left(WIDGET(tb));
|
x += widget_padding_get_left(WIDGET(tb));
|
||||||
|
Reference in New Issue
Block a user