1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Small cleanups.

This commit is contained in:
Dave Davenport 2022-01-22 10:21:35 +01:00
parent 8817b6a602
commit faa360041e
2 changed files with 35 additions and 13 deletions

View file

@ -202,20 +202,22 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
actual_size += 256; actual_size += 256;
retv = g_realloc(retv, (actual_size) * sizeof(DmenuScriptEntry)); retv = g_realloc(retv, (actual_size) * sizeof(DmenuScriptEntry));
} }
size_t buf_length = strlen(buffer) + 1; if (retv) {
retv[(*length)].entry = g_memdup(buffer, buf_length); size_t buf_length = strlen(buffer) + 1;
retv[(*length)].icon_name = NULL; retv[(*length)].entry = g_memdup(buffer, buf_length);
retv[(*length)].meta = NULL; retv[(*length)].icon_name = NULL;
retv[(*length)].info = NULL; retv[(*length)].meta = NULL;
retv[(*length)].icon_fetch_uid = 0; retv[(*length)].info = NULL;
retv[(*length)].nonselectable = FALSE; retv[(*length)].icon_fetch_uid = 0;
if (buf_length > 0 && (read_length > (ssize_t)buf_length)) { retv[(*length)].nonselectable = FALSE;
dmenuscript_parse_entry_extras(sw, &(retv[(*length)]), if (buf_length > 0 && (read_length > (ssize_t)buf_length)) {
buffer + buf_length, dmenuscript_parse_entry_extras(sw, &(retv[(*length)]),
read_length - buf_length); buffer + buf_length,
read_length - buf_length);
}
retv[(*length) + 1].entry = NULL;
(*length)++;
} }
retv[(*length) + 1].entry = NULL;
(*length)++;
} }
} }
if (buffer) { if (buffer) {

View file

@ -747,6 +747,10 @@ static int monitor_get_dimension(int monitor_id, workarea *mon) {
} }
// find the dimensions of the monitor displaying point x,y // find the dimensions of the monitor displaying point x,y
static void monitor_dimensions(int x, int y, workarea *mon) { static void monitor_dimensions(int x, int y, workarea *mon) {
if (mon == NULL) {
g_error("%s: mon == NULL", __FUNCTION__);
return;
}
memset(mon, 0, sizeof(workarea)); memset(mon, 0, sizeof(workarea));
mon->w = xcb->screen->width_in_pixels; mon->w = xcb->screen->width_in_pixels;
mon->h = xcb->screen->height_in_pixels; mon->h = xcb->screen->height_in_pixels;
@ -786,6 +790,10 @@ static int pointer_get(xcb_window_t root, int *x, int *y) {
} }
static int monitor_active_from_winid(xcb_drawable_t id, workarea *mon) { static int monitor_active_from_winid(xcb_drawable_t id, workarea *mon) {
if (mon == NULL) {
g_error("%s: mon == NULL", __FUNCTION__);
return FALSE;
}
xcb_window_t root = xcb->screen->root; xcb_window_t root = xcb->screen->root;
xcb_get_geometry_cookie_t c = xcb_get_geometry(xcb->connection, id); xcb_get_geometry_cookie_t c = xcb_get_geometry(xcb->connection, id);
xcb_get_geometry_reply_t *r = xcb_get_geometry_reply_t *r =
@ -815,6 +823,10 @@ static int monitor_active_from_id_focused(int mon_id, workarea *mon) {
int retv = FALSE; int retv = FALSE;
xcb_window_t active_window; xcb_window_t active_window;
xcb_get_property_cookie_t awc; xcb_get_property_cookie_t awc;
if (mon == NULL) {
g_error("%s: mon == NULL", __FUNCTION__);
return retv;
}
awc = xcb_ewmh_get_active_window(&xcb->ewmh, xcb->screen_nbr); awc = xcb_ewmh_get_active_window(&xcb->ewmh, xcb->screen_nbr);
if (!xcb_ewmh_get_active_window_reply(&xcb->ewmh, awc, &active_window, if (!xcb_ewmh_get_active_window_reply(&xcb->ewmh, awc, &active_window,
NULL)) { NULL)) {
@ -880,6 +892,10 @@ static int monitor_active_from_id_focused(int mon_id, workarea *mon) {
static int monitor_active_from_id(int mon_id, workarea *mon) { static int monitor_active_from_id(int mon_id, workarea *mon) {
xcb_window_t root = xcb->screen->root; xcb_window_t root = xcb->screen->root;
int x, y; int x, y;
if (mon == NULL) {
g_error("%s: mon == NULL", __FUNCTION__);
return FALSE;
}
g_debug("Monitor id: %d", mon_id); g_debug("Monitor id: %d", mon_id);
// At mouse position. // At mouse position.
if (mon_id == -3) { if (mon_id == -3) {
@ -955,6 +971,10 @@ workarea mon_cache = {
0, 0,
}; };
int monitor_active(workarea *mon) { int monitor_active(workarea *mon) {
if (mon == NULL) {
g_error("%s: mon == NULL", __FUNCTION__);
return FALSE;
}
g_debug("Monitor active"); g_debug("Monitor active");
if (mon_set) { if (mon_set) {
if (mon) { if (mon) {