Пример #1
0
int c_get_window_role(lua_State *lua)
{
	int top = lua_gettop(lua);

	if (top != 0) {
		luaL_error(lua, "get_window_role: %s", no_indata_expected_error);
		return 0;
	}

	WnckWindow *window = get_current_window();

	gchar *result = NULL;

	if (window) {
		result = my_wnck_get_string_property_latin1(wnck_window_get_xid(window),
		         my_wnck_atom_get("WM_WINDOW_ROLE"));
	}

	if (result) {
		lua_pushstring(lua, result);
	} else {
		lua_pushstring(lua, "");
	}

	g_free(result);

	return 1;
}
Пример #2
0
void
my_wnck_change_state (Screen  *screen,
                      Window   xwindow,
                      gboolean add,
                      Atom     state1,
                      Atom     state2)
{
    XEvent xev;

#define _NET_WM_STATE_REMOVE        0    /* remove/unset property */
#define _NET_WM_STATE_ADD           1    /* add/set property */
#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */

    xev.xclient.type = ClientMessage;
    xev.xclient.serial = 0;
    xev.xclient.send_event = True;
    xev.xclient.display = gdk_x11_get_default_xdisplay ();
    xev.xclient.window = xwindow;
    xev.xclient.message_type = my_wnck_atom_get ("_NET_WM_STATE");
    xev.xclient.format = 32;
    xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
    xev.xclient.data.l[1] = state1;
    xev.xclient.data.l[2] = state2;

    XSendEvent (gdk_x11_get_default_xdisplay (),
                RootWindowOfScreen (screen),
                False,
                SubstructureRedirectMask | SubstructureNotifyMask,
                &xev);
}
Пример #3
0
int c_get_window_property(lua_State *lua)
{
	int top = lua_gettop(lua);

	if (top != 1) {
		luaL_error(lua, "get_window_property: %s", one_indata_expected_error);
		return 0;
	}

	//	gchar *property=
	int type = lua_type(lua, 1);

	if (type != LUA_TSTRING) {
		luaL_error(lua, "get_window_property: %s", string_expected_as_indata_error);
		return 0;
	}

	const gchar *value = lua_tostring(lua, 1);

	WnckWindow *window = get_current_window();

	gchar *result = NULL;

	if (window) {
		result = my_wnck_get_string_property_latin1(wnck_window_get_xid(window),
		         my_wnck_atom_get(value));
	} else {
		result = g_strdup_printf("NO RESULT");
	}

	if (result) {
		lua_pushstring(lua, result);
	} else {
		lua_pushstring(lua, "");
	}

	g_free(result);

	return 1;
}
Пример #4
0
int c_set_window_below(lua_State *lua)
{
	int top = lua_gettop(lua);
	gboolean set_below;

	if (top > 1) {
		luaL_error(lua, "set_window_below: %s", one_indata_expected_error);
		return 0;
	}
	else if (top == 1) {
		int type = lua_type(lua, 1);

		if (type != LUA_TBOOLEAN) {
			luaL_error(lua, "set_window_below: %s", boolean_expected_as_indata_error);
			return 0;
		}

		int value = lua_toboolean(lua, 1);
		set_below = (gboolean)(value);
	}
	else {
		set_below = TRUE;
	}

	WnckWindow *window = get_current_window();
	if (!devilspie2_emulate) {

		Window xid = wnck_window_get_xid(window);
		devilspie2_change_state(devilspie2_window_get_xscreen(xid),
		                        xid,
		                        set_below,
		                        my_wnck_atom_get("_NET_WM_STATE_BELOW"),
		                        0);
	}

	return 0;
}