lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 28 March 2012 12:48, Ralf Van Bogaert <ralf.vanbogaert@gmail.com> wrote:
>
> I'm developing a desktop environment intended for use on Linux/X11, using LuaJIT and Qt (through lqt).
> To prevent maximized windows overlapping my any toolbars, I need to set struts for window managers to respect.
> Qt does not support this directly, it appears I need to talk to X11 to achieve this.


You can write a small Lua module in C, which would bind the necessary functions. Seeing that you are planning to use LuaJIT, you do not even have to do that - just use the FFI to call the necessary X11 functions.

In order to get the window ID from Qt, you have to call QWidget::winId() [1], which returns the X11 handle of the given widget. This function is not bound by Lqt, because (until now) it was useless for Lua (and the Lqt generator does not know how to handle the WId type).

To bind it, try changing generator/qtypes.lua and add the following definitions (untested, not sure it will work):

qt_types['WId'] = {
  get = function(i) return 'lua_touserdata(L, '..i..')', 1, 'QByteArray' end,
  push = function(i) return 'lua_pushlightuserdata(L, '..i..')', 1 end,
  test = function(i) return 'lua_islightuserdata(L, '..i..')', 1 end,
  _onstack_ = 'userdata,',
}

This should make it possible to get the X11 window handle as lightuserdata, which LuaJIT can then use to call the necessary functions.

[1] http://qt-project.org/doc/qt-4.8/qwidget.html#winId