drawin: Don't cause X11 errors during allocation
We were only creating an X11 window for a new drawin after we handled all the options that were passed in. However, this means that drawin({ height = 4 }) would try to resize the window before we created a window, which caused an X11 error. Fix this by moving our initialization before of the handling of construction arguments. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
c2ea920ca0
commit
e40bfedd30
|
@ -333,6 +333,24 @@ drawin_set_visible(lua_State *L, int udx, bool v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static drawin_t *
|
||||||
|
drawin_allocator(lua_State *L)
|
||||||
|
{
|
||||||
|
drawin_t *w = drawin_new(L);
|
||||||
|
|
||||||
|
w->visible = false;
|
||||||
|
|
||||||
|
w->opacity = -1;
|
||||||
|
w->cursor = a_strdup("left_ptr");
|
||||||
|
w->geometry.width = 1;
|
||||||
|
w->geometry.height = 1;
|
||||||
|
w->type = _NET_WM_WINDOW_TYPE_NORMAL;
|
||||||
|
|
||||||
|
drawin_init(w);
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
/** Create a new drawin.
|
/** Create a new drawin.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
|
@ -342,27 +360,6 @@ luaA_drawin_new(lua_State *L)
|
||||||
{
|
{
|
||||||
luaA_class_new(L, &drawin_class);
|
luaA_class_new(L, &drawin_class);
|
||||||
|
|
||||||
drawin_t *w = luaA_checkudata(L, -1, &drawin_class);
|
|
||||||
|
|
||||||
w->visible = false;
|
|
||||||
|
|
||||||
if(!w->opacity)
|
|
||||||
w->opacity = -1;
|
|
||||||
|
|
||||||
if(!w->cursor)
|
|
||||||
w->cursor = a_strdup("left_ptr");
|
|
||||||
|
|
||||||
if(!w->geometry.width)
|
|
||||||
w->geometry.width = 1;
|
|
||||||
|
|
||||||
if(!w->geometry.height)
|
|
||||||
w->geometry.height = 1;
|
|
||||||
|
|
||||||
if(w->type == 0)
|
|
||||||
w->type = _NET_WM_WINDOW_TYPE_NORMAL;
|
|
||||||
|
|
||||||
drawin_init(w);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +593,7 @@ drawin_class_setup(lua_State *L)
|
||||||
};
|
};
|
||||||
|
|
||||||
luaA_class_setup(L, &drawin_class, "drawin", &window_class,
|
luaA_class_setup(L, &drawin_class, "drawin", &window_class,
|
||||||
(lua_class_allocator_t) drawin_new,
|
(lua_class_allocator_t) drawin_allocator,
|
||||||
(lua_class_collector_t) drawin_wipe,
|
(lua_class_collector_t) drawin_wipe,
|
||||||
NULL,
|
NULL,
|
||||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||||
|
|
Loading…
Reference in New Issue