client: move floating_placement_set()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-23 11:41:16 +02:00
parent 9071cb1332
commit c67c237bba
4 changed files with 42 additions and 38 deletions

View File

@ -42,6 +42,7 @@
#include "common/xscreen.h" #include "common/xscreen.h"
extern awesome_t globalconf; extern awesome_t globalconf;
extern const name_func_link_t FloatingPlacementList[];
/** Create a new client userdata. /** Create a new client userdata.
* \param L The Lua VM state. * \param L The Lua VM state.
@ -378,21 +379,6 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
if(rettrans || c->isfixed) if(rettrans || c->isfixed)
client_setfloating(c, true, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT); client_setfloating(c, true, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
if(globalconf.floating_placement
&& !retloadprops
&& u_size_hints
&& !(xcb_size_hints_get_flags(u_size_hints) & (XCB_SIZE_US_POSITION_HINT |
XCB_SIZE_P_POSITION_HINT)))
{
if(c->isfloating)
client_resize(c, globalconf.floating_placement(c), false);
else
c->f_geometry = globalconf.floating_placement(c);
}
if(u_size_hints)
xcb_free_size_hints(u_size_hints);
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK,
select_input_val); select_input_val);
@ -412,6 +398,22 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
/* call hook */ /* call hook */
luaA_client_userdata_new(globalconf.L, c); luaA_client_userdata_new(globalconf.L, c);
luaA_dofunction(globalconf.L, globalconf.hooks.manage, 1); luaA_dofunction(globalconf.L, globalconf.hooks.manage, 1);
if(c->floating_placement
&& !retloadprops
&& u_size_hints
&& !(xcb_size_hints_get_flags(u_size_hints) & (XCB_SIZE_US_POSITION_HINT |
XCB_SIZE_P_POSITION_HINT)))
{
if(c->isfloating)
client_resize(c, c->floating_placement(c), false);
else
c->f_geometry = c->floating_placement(c);
}
if(u_size_hints)
xcb_free_size_hints(u_size_hints);
} }
/** Compute client geometry with respect to its geometry hints. /** Compute client geometry with respect to its geometry hints.
@ -1302,7 +1304,7 @@ luaA_client_titlebar_set(lua_State *L)
{ {
client_t **c = luaA_checkudata(L, 1, "client"); client_t **c = luaA_checkudata(L, 1, "client");
titlebar_t **t = NULL; titlebar_t **t = NULL;
if(lua_gettop(L) == 2 && !lua_isnil(L, 2)) if(lua_gettop(L) == 2 && !lua_isnil(L, 2))
{ {
t = luaA_checkudata(L, 2, "titlebar"); t = luaA_checkudata(L, 2, "titlebar");
@ -1411,6 +1413,24 @@ luaA_client_ishidden(lua_State *L)
return 1; return 1;
} }
/** Set the floating placement algorithm. This will be used to compute the
* initial floating position of the window then floating.
* \param L The Lua VM state.
*
* \luastack
* \lvalue A client.
* \lparam An algorith name, either `none', `smart' or `mouse'.
*/
static int
luaA_client_floating_placement_set(lua_State *L)
{
client_t **c = luaA_checkudata(L, 1, "client");
const char *pl = luaL_checkstring(L, 2);
(*c)->floating_placement = name_func_lookup(pl, FloatingPlacementList);
return 0;
}
const struct luaL_reg awesome_client_methods[] = const struct luaL_reg awesome_client_methods[] =
{ {
{ "get", luaA_client_get }, { "get", luaA_client_get },
@ -1420,6 +1440,7 @@ const struct luaL_reg awesome_client_methods[] =
}; };
const struct luaL_reg awesome_client_meta[] = const struct luaL_reg awesome_client_meta[] =
{ {
{ "floating_placement_set", luaA_client_floating_placement_set },
{ "titlebar_set", luaA_client_titlebar_set }, { "titlebar_set", luaA_client_titlebar_set },
{ "titlebar_get", luaA_client_titlebar_get }, { "titlebar_get", luaA_client_titlebar_get },
{ "name_get", luaA_client_name_get }, { "name_get", luaA_client_name_get },

18
lua.c
View File

@ -49,8 +49,6 @@
extern awesome_t globalconf; extern awesome_t globalconf;
extern const name_func_link_t FloatingPlacementList[];
extern const struct luaL_reg awesome_keygrabber_lib[]; extern const struct luaL_reg awesome_keygrabber_lib[];
extern const struct luaL_reg awesome_mouse_methods[]; extern const struct luaL_reg awesome_mouse_methods[];
extern const struct luaL_reg awesome_mouse_meta[]; extern const struct luaL_reg awesome_mouse_meta[];
@ -88,21 +86,6 @@ luaA_mouse_add(lua_State *L)
return 0; return 0;
} }
/** Set the floating placement algorithm. This will be used to compute the
* initial floating position of floating windows.
* \param L The Lua VM state.
*
* \luastack
* \lparam An algorith name, either `none', `smart' or `mouse'.
*/
static int
luaA_floating_placement_set(lua_State *L)
{
const char *pl = luaL_checkstring(L, 1);
globalconf.floating_placement = name_func_lookup(pl, FloatingPlacementList);
return 0;
}
/** Quit awesome. /** Quit awesome.
*/ */
static int static int
@ -474,7 +457,6 @@ luaA_init(void)
{ "quit", luaA_quit }, { "quit", luaA_quit },
{ "exec", luaA_exec }, { "exec", luaA_exec },
{ "restart", luaA_restart }, { "restart", luaA_restart },
{ "floating_placement_set", luaA_floating_placement_set },
{ "padding_set", luaA_padding_set }, { "padding_set", luaA_padding_set },
{ "mouse_add", luaA_mouse_add }, { "mouse_add", luaA_mouse_add },
{ "resizehints_set", luaA_resizehints_set }, { "resizehints_set", luaA_resizehints_set },

View File

@ -30,7 +30,7 @@
extern awesome_t globalconf; extern awesome_t globalconf;
name_func_link_t FloatingPlacementList[] = const name_func_link_t FloatingPlacementList[] =
{ {
{ "smart", placement_smart }, { "smart", placement_smart },
{ "under_mouse", placement_under_mouse }, { "under_mouse", placement_under_mouse },

View File

@ -313,6 +313,8 @@ struct client_t
titlebar_t *titlebar; titlebar_t *titlebar;
/** Button bindings */ /** Button bindings */
button_t *buttons; button_t *buttons;
/** Floating window placement algo */
floating_placement_t *floating_placement;
/** Next and previous clients */ /** Next and previous clients */
client_t *prev, *next; client_t *prev, *next;
}; };
@ -381,7 +383,8 @@ typedef struct
/** Padding */ /** Padding */
padding_t padding; padding_t padding;
/** Window that contains the systray */ /** Window that contains the systray */
struct { struct
{
xcb_window_t window; xcb_window_t window;
bool has_systray_widget; bool has_systray_widget;
} systray; } systray;
@ -425,8 +428,6 @@ struct awesome_t
xembed_window_t *embedded; xembed_window_t *embedded;
/** Path to config file */ /** Path to config file */
char *configpath; char *configpath;
/** Floating window placement algo */
floating_placement_t *floating_placement;
/** Selected clients history */ /** Selected clients history */
client_node_t *focus; client_node_t *focus;
/** Stack client history */ /** Stack client history */