Esempio n. 1
0
void mouse_init() {
    g_numlockmask_ptr = get_numlockmask_ptr();
    g_snap_distance = &(settings_find("snap_distance")->value.i);
    g_snap_gap = &(settings_find("snap_gap")->value.i);
    /* set cursor theme */
    g_cursor = XCreateFontCursor(g_display, XC_left_ptr);
    XDefineCursor(g_display, g_root, g_cursor);
}
Esempio n. 2
0
// toggle integer-like values
int settings_toggle(int argc, char** argv, GString* output) {
    if (argc < 2) {
        return HERBST_NEED_MORE_ARGS;
    }
    SettingsPair* pair = settings_find(argv[1]);
    if (!pair) {
        g_string_append_printf(output,
            "%s: Setting \"%s\" not found\n", argv[0], argv[1]);
        return HERBST_SETTING_NOT_FOUND;
    }
    if (pair->type == HS_Int) {
        if (pair->value.i) {
            /* store old value */
            pair->old_value_i = pair->value.i;
            pair->value.i = 0;
        } else {
            /* recover old value */
            pair->value.i = pair->old_value_i;
        }
    } else {
        // only toggle numbers
        g_string_append_printf(output,
            "%s: Only numbers can be toggled\n", argv[0]);
        return HERBST_INVALID_ARGUMENT;
    }
    // on successful change, call callback
    if (pair->on_change) {
        pair->on_change();
    }
    return 0;
}
Esempio n. 3
0
char* settings_find_string(const char* name) {
    SettingsPair* sp = settings_find(name);
    if (!sp) return NULL;
    HSWeakAssert(sp->type == HS_String);
    if (sp->type != HS_String) return NULL;
    return sp->value.str->str;
}
Esempio n. 4
0
static void fetch_colors() {
    g_window_border_width = &(settings_find("window_border_width")->value.i);
    g_window_border_inner_width = &(settings_find("window_border_inner_width")->value.i);
    g_window_gap = &(settings_find("window_gap")->value.i);
    g_snap_gap = &(settings_find("snap_gap")->value.i);
    g_smart_window_surroundings = &(settings_find("smart_window_surroundings")->value.i);
    g_raise_on_focus = &(settings_find("raise_on_focus")->value.i);
    char* str = settings_find("window_border_normal_color")->value.s;
    g_window_border_normal_color = getcolor(str);
    str = settings_find("window_border_active_color")->value.s;
    g_window_border_active_color = getcolor(str);
    str = settings_find("window_border_urgent_color")->value.s;
    g_window_border_urgent_color = getcolor(str);
    str = settings_find("window_border_inner_color")->value.s;
    g_window_border_inner_color = getcolor(str);
}
Esempio n. 5
0
File: main.c Progetto: xiaq/hlwm
void configurenotify(XEvent* event) {
    if (event->xconfigure.window == g_root &&
        settings_find("auto_detect_monitors")->value.i) {
        char* args[] = { "detect_monitors" };
        detect_monitors_command(LENGTH(args), args, NULL);
    }
    // HSDebug("name is: ConfigureNotify\n");
}
Esempio n. 6
0
void ewmh_init() {
    /* init globals */
    g_focus_stealing_prevention =
        &(settings_find("focus_stealing_prevention")->value.i);

    /* init ewmh net atoms */
    for (int i = 0; i < NetCOUNT; i++) {
        if (g_netatom_names[i] == NULL) {
            g_warning("no name specified in g_netatom_names "
                      "for atom number %d\n", i);
            continue;
        }
        g_netatom[i] = XInternAtom(g_display, g_netatom_names[i], False);
    }

    /* tell which ewmh atoms are supported */
    XChangeProperty(g_display, g_root, g_netatom[NetSupported], XA_ATOM, 32,
        PropModeReplace, (unsigned char *) g_netatom, NetCOUNT);

    /* init some globals */
    g_windows = NULL;
    g_window_count = 0;
    if (!ewmh_read_client_list(&g_original_clients, &g_original_clients_count))
    {
        g_original_clients = NULL;
        g_original_clients_count = 0;
    }

    /* init other atoms */
    WM_STATE = XInternAtom(g_display, "WM_STATE", False);

    /* init for the supporting wm check */
    g_wm_window = XCreateSimpleWindow(g_display, g_root,
                                      42, 42, 42, 42, 0, 0, 0);
    XChangeProperty(g_display, g_root, g_netatom[NetSupportingWmCheck],
        XA_WINDOW, 32, PropModeReplace, (unsigned char*)&(g_wm_window), 1);
    XChangeProperty(g_display, g_wm_window, g_netatom[NetSupportingWmCheck],
        XA_WINDOW, 32, PropModeReplace, (unsigned char*)&(g_wm_window), 1);
    ewmh_update_wmname();

    /* init atoms that never change */
    int buf[] = { 0, 0 };
    XChangeProperty(g_display, g_root, g_netatom[NetDesktopViewport],
        XA_CARDINAL, 32, PropModeReplace, (unsigned char *) buf, LENGTH(buf));
}
Esempio n. 7
0
static SETTINGS_REC *settings_get(const char *key, SettingType type)
{
	SETTINGS_REC *rec;

	g_return_val_if_fail(key != NULL, NULL);

	rec = settings_find(key);
	if (rec == NULL) {
		g_warning("settings_get(%s) : not found", key);
		return NULL;
	}
	if (type != -1 && rec->type != type) {
		g_warning("settings_get(%s) : invalid type", key);
		return NULL;
	}

	return rec;
}
Esempio n. 8
0
int settings_set_command(int argc, const char** argv, GString* output) {
    if (argc < 3) {
        return HERBST_NEED_MORE_ARGS;
    }
    SettingsPair* pair = settings_find(argv[1]);
    if (!pair) {
        if (output != NULL) {
            g_string_append_printf(output,
                "%s: Setting \"%s\" not found\n", argv[0], argv[1]);
        }
        return HERBST_SETTING_NOT_FOUND;
    }
    int ret = settings_set(pair, argv[2]);
    if (ret == HERBST_INVALID_ARGUMENT) {
        g_string_append_printf(output,
            "%s: Invalid value for setting \"%s\"\n", argv[0], argv[1]);
    }
    return ret;
}
Esempio n. 9
0
int settings_get(int argc, char** argv, GString* output) {
    if (argc < 2) {
        return HERBST_NEED_MORE_ARGS;
    }
    SettingsPair* pair = settings_find(argv[1]);
    if (!pair) {
        g_string_append_printf(output,
            "%s: Setting \"%s\" not found\n", argv[0], argv[1]);
        return HERBST_SETTING_NOT_FOUND;
    }
    if (pair->type == HS_Int) {
        g_string_append_printf(output, "%d", pair->value.i);
    } else if (pair->type == HS_String) {
        g_string_append(output, pair->value.str->str);
    } else if (pair->type == HS_Compatiblity) {
        HSAttribute* attr = hsattribute_parse_path(pair->value.compat.read);
        GString* str = hsattribute_to_string(attr);
        g_string_append(output, str->str);
        g_string_free(str, true);
    }
    return 0;
}
Esempio n. 10
0
void settings_init() {
    // recreate all strings -> move them to heap
    for (int i = 0; i < LENGTH(g_settings); i++) {
        if (g_settings[i].type == HS_String) {
            g_settings[i].value.str = g_string_new(g_settings[i].value.s_init);
        }
        if (g_settings[i].type == HS_Int) {
            g_settings[i].old_value_i = 1;
        }
    }
    settings_find("monitors_locked")->value.i = g_initial_monitors_locked;

    // create a settings object
    g_settings_object = hsobject_create_and_link(hsobject_root(), "settings");
    // ensure everything is nulled that is not explicitely initialized
    HSAttribute* attributes = g_new0(HSAttribute, LENGTH(g_settings)+1);
    HSAttribute last = ATTRIBUTE_LAST;
    attributes[LENGTH(g_settings)] = last;
    for (int i = 0; i < LENGTH(g_settings); i++) {
        SettingsPair* sp = g_settings + i;
        if (sp->type == HS_String) {
            HSAttribute cur =
                ATTRIBUTE(sp->name, sp->value.str, cb_on_change);
            attributes[i] = cur;
        } else if (sp->type == HS_Int) {
            HSAttribute cur =
                ATTRIBUTE(sp->name, sp->value.i, cb_on_change);
            attributes[i] = cur;
        } else if (sp->type == HS_Compatiblity) {
            HSAttribute cur =
                ATTRIBUTE_CUSTOM(sp->name, (HSAttributeCustom)cb_read_compat, cb_write_compat);
            cur.data = sp;
            attributes[i] = cur;
        }
    }
    hsobject_set_attributes(g_settings_object, attributes);
    g_free(attributes);
}
Esempio n. 11
0
int settings_cycle_value(int argc, char** argv, GString* output) {
    if (argc < 3) {
        return HERBST_NEED_MORE_ARGS;
    }
    char* cmd_name = argv[0];
    char* setting_name = argv[1]; // save this before shifting
    SettingsPair* pair = settings_find(argv[1]);
    if (!pair) {
        g_string_append_printf(output,
            "%s: Setting \"%s\" not found\n", argv[0], argv[1]);
        return HERBST_SETTING_NOT_FOUND;
    }
    (void)SHIFT(argc, argv);
    (void)SHIFT(argc, argv);
    char** pcurrent = (char**)table_find(argv, sizeof(*argv), argc, 0,
                                 memberequals_settingspair, pair);
    int i = pcurrent ? ((INDEX_OF(argv, pcurrent) + 1) % argc) : 0;
    int ret = settings_set(pair, argv[i]);
    if (ret == HERBST_INVALID_ARGUMENT) {
        g_string_append_printf(output,
            "%s: Invalid value for setting \"%s\"\n", cmd_name, setting_name);
    }
    return ret;
}
Esempio n. 12
0
File: ewmh.c Progetto: xiaq/hlwm
void ewmh_update_wmname() {
    ewmh_set_wmname(settings_find("wmname")->value.s);
}
Esempio n. 13
0
File: main.c Progetto: xiaq/hlwm
static void fetch_settings() {
    // fetch settings only for this main.c file from settings table
    g_focus_follows_mouse = &(settings_find("focus_follows_mouse")->value.i);
    g_raise_on_click = &(settings_find("raise_on_click")->value.i);
}