Mouse click events always return relative to the top left of a computer's native display. They don't care whether you've redirected to some other terminal object, such as a window.
To deal with this, you'd need to either change the code used for pulling events, or change the code used for
pushing events. Multishell, for example, goes with the latter solution - if a script that it's running in one of its windows wants to pull a mouse click event, then it may modify that event before pushing it to that script.
I'll assume you're using the parallel API to handle your processes. Taking the "push" approach, you'd instead write your own coroutine manager.
The other option, "pulling", would best be done by overriding os.pullEventRaw(), so that it checks whether it's about to return a mouse click event and modifies it before doing so. Assuming you never move your windows, and aren't interested in infoBar clicks, this is a lot simpler - you just add a bit to the mouse's location before returning, eg:
local infoBarLines = 1
local oldPER = os.pullEventRaw
function os.pullEventRaw(filter)
local result
repeat
result = {oldPER(filter)}
if result[1] == "mouse_click" then -- If the event we're pulling is a mouse click,
if result[4] < infoBarLines + 1 then
result = nil -- Discard it if it was on the infoBar.
else
result[4] = result[4] -- infoBarLines -- Or modify it if it wasn't.
end
end
until result
return unpack(result)
end
-- Rest of your script here.
os.pullEventRaw = oldPER
If you're moving windows around, or redirecting to windows which are defined within windows, etc, it becomes significantly more complex - but odds are this'll suit your purposes.
Edited by Bomb Bloke, 20 June 2015 - 09:23 AM.