Comments (4)
[11:30] <psychon> I wonder if we can come up with something that is "transparent" to uses in rc.lua
[11:31] <Elv1313> psychon: yes, but it will require being able to set custom metatables for client
[11:31] <Elv1313> that way we can use __index to hijack .border_width and __newindex for the setter. Then it wont break the API and just work
[11:31] <normalra> Exactly.
[11:31] <psychon> hm... might be a good idea to have
[11:32] <psychon> well, rather than setting the metatable, it might be easier to be able to set handlers for __index and __newindex for "property misses" (when the C code doesn't know how to handle things)
[11:32] <Elv1313> I tried to implement that the other day, but ran out of time without much results (I don't know the luac API that well)
[11:32] <Elv1313> psychon: yes, that would work
[11:35] <psychon> "just" requires patching luaA_class_newindex() and luaA_class_index()
[11:35] <psychon> instead of calling newindex_miss_property, they'd need to call into some lua function (that somehow lua must be able to set earlier...)
[11:38] <Elv1313> psychon: if you take care of the C side, I will implement the handlers. I already have the code in Radical to do just that
[11:38] <Elv1313> it also emulate :set_foo(x) -> object.foo = x
[11:41] <Elv1313> psychon: do you want me to create an issue for that?
[11:41] <psychon> yeah, feel free
[11:41] <psychon> and we need to come up with some API for lua to set the handlers
[11:41] <psychon> does it make sense to have them object-specific? or is it ok to have it just per-class?
[11:43] <Elv1313> I guess client, tag, screen, drawable, key and drawin should have the same API
[11:43] <psychon> looking forward to your feature requests which includes explanations on how the API might look like :-P
[11:47] <phryk> Do things like wibox or the widgets use lua classes and I just find lua confusing or are they implemented as just a bunch of functions?
[11:48] <Elv1313> psychon: https://github.com/awesomeWM/awesome/issues/163
[11:48] <psychon> phryk: lua doesn't have a built-in concept of a "class"
[11:48] <psychon> Elv1313: thanks, will take a look on saturday
from awesome.
See psychon@e091381 and the following code that can be added to the default config:
-- For experiments with the error handling:
local check_errors = false
if check_errors then
drawin.set_index_miss_handler(function(...) error("Nope") end)
drawin.set_newindex_miss_handler(function(...) error("Nope") end)
else
drawin.set_index_miss_handler(function(...) print("index miss", ...) return print, 42 end)
drawin.set_newindex_miss_handler(function(...) print("newindex miss", ...) return 42 end)
end
d = drawin({})
print("getting d.foo")
print(d.foo)
print("setting d.bar = 7")
d.bar = 7
-- This would call nil
if not check_errors then
print("calling foobar")
print(d:foobar("calling foobar"))
end
I used .set_index_miss_handler(func)
instead of .index_miss_handler = func
because this is easier on the C side. There is already support for adding functions to all objects (for the .instances()
and signal handling functions), but hijacking _index
and _newindex
on classes would be more complicated.
I didn't add a getter because I'm lazy and would rather have a single place in lua where something is implemented based on this instead of modules "chaining calls" to each other (get old handler, set your own which calls the old handler if it doesn't know what to do).
I didn't add this set_index_miss_handler
to individual objects, but only to classes (c
vs client
), since I'm lazy and this approach here is already complicated enough IMO.
Does this still seem ok? Anyone wants to experiment with this code?
from awesome.
See the discussion at #482 and especially #482 (comment).
from awesome.
from awesome.
Related Issues (20)
- awesomeWM workspaces and skippy-xd HOT 3
- `urgent = false` not working HOT 3
- BUG: `gears.timer {call_now=true}` doesn't pass `self` (`ret`) HOT 1
- Incorrect completion_callback usage example
- Errors returned with luajit but not lua 5.4 HOT 2
- Mouse events ignored by application only when managed by Awesome
- Lgi FFI error on startup HOT 1
- Multiple definition error while compiling on a 32bit machine. HOT 1
- GTK theme breaks if user's locale uses commas instead of dots as decimal separators HOT 11
- How to make new notifications update to existing notifications? HOT 2
- workaround for pystray python tray icon programs HOT 2
- Shell environment not correct while using `awful.spawn_with_shell`? HOT 4
- Stdout not working correctly for awful.spawn.with_line_callback but stderr does HOT 4
- awesomewm freezes occasionally with E: awesome: Failed to load 'userdata: (nil)' HOT 2
- Bluetooth pin accept notification doesn't appear with naughty. HOT 3
- codecov pipeline not responding in PRs HOT 9
- Error while trying to install awesome HOT 3
- What about monthly or quarterly release strategy for minor versions?
- [Feature Request] Vastly improve documentation HOT 1
- Unblocking root window's swapchain HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome.