Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Window Minimised #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ information:

*(Available from version 0.45.)*

* `get_window_is_minimised`
<a name="user-content-get-window-is-minimised"></a>

Returns `true` if the window is minimised, `false` otherwise.

*(Available from version 0.46; -`ized` from 0.46)*

* `get_window_is_maximised`
<a name="user-content-get-window-is-maximised`
<a name="user-content-get-window-is-maximised"></a>

Returns `true` if the window is maximised, `false` otherwise.

Expand Down
2 changes: 2 additions & 0 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ register_cfunctions(lua_State *lua)
DP2_REGISTER(lua, set_skip_tasklist);
DP2_REGISTER(lua, set_skip_pager);

DP2_REGISTER(lua, get_window_is_minimized);
lua_register(lua, "get_window_is_minimised", c_get_window_is_minimized);
DP2_REGISTER(lua, get_window_is_maximized);
lua_register(lua, "get_window_is_maximised", c_get_window_is_maximized);

Expand Down
17 changes: 15 additions & 2 deletions src/script_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ int c_minimize(lua_State *lua)
if (!devilspie2_emulate) {
WnckWindow *window = get_current_window();

if (window) {
if (window && FALSE == wnck_window_is_minimized(window)) {
wnck_window_minimize(window);
}
}
Expand All @@ -802,7 +802,7 @@ int c_unminimize(lua_State *lua)
if (!devilspie2_emulate) {
WnckWindow *window = get_current_window();

if (window) {
if (window && TRUE == wnck_window_is_minimized(window)) {
wnck_window_unminimize (window, current_time());
}
}
Expand Down Expand Up @@ -1406,6 +1406,19 @@ int c_set_skip_pager(lua_State *lua)
return 0;
}

int c_get_window_is_minimized(lua_State *lua)
{
if (!check_param_count(lua, "get_window_is_minimized", 0)) {
return 0;
}

WnckWindow *window = get_current_window();
gboolean is_minimized = window ? wnck_window_is_minimized(window) : FALSE;

lua_pushboolean(lua, is_minimized);

return 1;
}

/**
*
Expand Down
1 change: 1 addition & 0 deletions src/script_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ int c_get_window_frame_extents(lua_State *lua);
int c_set_skip_tasklist(lua_State *lua);
int c_set_skip_pager(lua_State *lua);

int c_get_window_is_minimized(lua_State *lua);
int c_get_window_is_maximized(lua_State *lua);
int c_get_window_is_maximized_vertically(lua_State *lua);
int c_get_window_is_maximized_horisontally(lua_State *lua); // deprecated
Expand Down