LUA: !DesktopClick Thread last updated on 2006-08-23 19:05:20

Posted by member 7223 on 2006-08-22 02:18:29

;------------------------------------------------------------------------------
; DesktopClick.rc
; © Smurth 2006 ( smurth@free.fr )
;------------------------------------------------------------------------------

; A simple but powerfull widget to extend the power of your mouse\'s left button.
; It supports clicks and double-clicks on desktop, on borders and on edges.
;
; Note:
; - On double-clicks, single click\'s action is performed, too
; - So, DesktoClick (single click) better should be set to \"!none\" or some non-intrusive action.
; - DesktopClickDelay specify the maximum time between two clicks to be considered as a double-click.
; - DesktopBorder[borders] specifies the area for a click to be considered as a border/corner-click.
;
; All the values below are optional and some defaults are set.
; DesktopClick !none
; DesktopDoubleClick $DesktopClick$
; Desktop[border]Click $DesktopClick$
; Desktop[border]DoubleClick $Desktop[border]Click$ or $DesktopDoubleClick$ (if Desktop[border]Click is not define)
; Desktop[corner]Click $DesktopClick$
; Desktop[corner]DoubleClick $Desktop[corner]Click$ or $DesktopDoubleClick$ (if Desktop[corner]Click is not define)
;
; [border] should be \"Left\", \"Right\", \"Top\" or \"Bottom\"
; [corner] should be \"TopLeft\", \"TopRight\", \"BottomLeft\" or \"BottomRight\"



; change the path according to your system
*LuaFile \"$WidgetsDir$DesktopClick.lua\"

jDeskDisableDoubleClick

; Choose what\'s better for you: action on button-down or button-up
;*jDeskMButton1 [ .none ; !DesktopClick ; !none ]
*jDeskMButton1 [ .none ; !none ; !DesktopClick ]



DesktopClickDelay 500
DesktopClickBorderLeft 4
DesktopClickBorderRight $ResolutionX-4$
DesktopClickBorderTop 4
DesktopClickBorderBottom $ResolutionY-4$

DesktopClick !none
DesktopDoubleClick \'!alert \"Double click !\"\'

DesktopLeftClick !VWMLeft
DesktopLeftDoubleClick \"!VWMMoveApp left\"
DesktopRightClick !VWMRight
DesktopRightDoubleClick \"!VWMMoveApp right\"

DesktopTopClick \'!alert \"Top\"\'
DesktopTopDoubleClick \'!alert \"Top double\"\'
DesktopTopLeftClick \'!alert \"Top-left\"\'
DesktopTopLeftDoubleClick \'!alert \"Top-left double\"\'
DesktopTopRightClick \'!alert \"Top-right\"\'
DesktopTopRightDoubleClick \'!alert \"Top-right double\"\'

DesktopBottomClick \'!alert \"Bottom\"\'
DesktopBottomDoubleClick \'!alert \"Bottom double\"\'
DesktopBottomLeftClick \'!alert \"Bottom-left\"\'
DesktopBottomLeftDoubleClick \'!alert \"Bottom-left double\"\'
DesktopBottomRightClick \'!alert \"Bottom-right\"\'
DesktopBottomRightDoubleClick \'!alert \"Bottom-right double\"\'


--[[
DESKTOP CLICK

© Smurth 2006 ( smurth@free.fr )

]]
local GetEvar = lslua.get_evar

local clicktime = tonumber( GetEvar( \"DesktopClickDelay\" ) ) or 500
local borderleft = tonumber( GetEvar( \"DesktopClickBorderLeft\" ) ) or 4
local borderright = tonumber( GetEvar( \"DesktopClickBorderRight\" ) ) or ( lslua.res().x - 4 )
local bordertop = tonumber( GetEvar( \"DesktopClickBorderTop\" ) ) or 4
local borderbottom = tonumber( GetEvar( \"DesktopClickBorderBottom\" ) ) or ( lslua.res().y - 4 )

local desktopclick = { Main = GetEvar( \"DesktopClick\" ) or \"!none\" }

desktopclick.Left = GetEvar( \"DesktopLeftClick\" ) or desktopclick.Main
desktopclick.Right = GetEvar( \"DesktopRightClick\" ) or desktopclick.Main
desktopclick.Top = GetEvar( \"DesktopTopClick\" ) or desktopclick.Main
desktopclick.Bottom = GetEvar( \"DesktopBottomClick\" ) or desktopclick.Main

desktopclick.Double = GetEvar( \"DesktopDoubleClick\" ) or desktopclick.Main
desktopclick.LeftDouble = GetEvar( \"DesktopLeftDoubleClick\" ) or GetEvar( \"DesktopLeftClick\" ) or desktopclick.Double
desktopclick.RightDouble = GetEvar( \"DesktopRightDoubleClick\" ) or GetEvar( \"DesktopRightClick\" ) or desktopclick.Double
desktopclick.TopDouble = GetEvar( \"DesktopTopDoubleClick\" ) or GetEvar( \"DesktopTopClick\" ) or desktopclick.Double
desktopclick.BottomDouble = GetEvar( \"DesktopBottomDoubleClick\" ) or GetEvar( \"DesktopBottomClick\" ) or desktopclick.Double

desktopclick.TopLeft = GetEvar( \"DesktopTopLeftClick\" ) or desktopclick.Main
desktopclick.TopRight = GetEvar( \"DesktopTopRightClick\" ) or desktopclick.Main
desktopclick.BottomLeft = GetEvar( \"DesktopBottomLeftClick\" ) or desktopclick.Main
desktopclick.BottomRight = GetEvar( \"DesktopBottomRightClick\" ) or desktopclick.Main

desktopclick.TopLeftDouble = GetEvar( \"DesktopTopLeftDoubleClick\" ) or GetEvar( \"DesktopTopLeftClick\" ) or desktopclick.Double
desktopclick.TopRightDouble = GetEvar( \"DesktopTopRightDoubleClick\" ) or GetEvar( \"DesktopTopRightClick\" ) or desktopclick.Double
desktopclick.BottomLeftDouble = GetEvar( \"DesktopBottomLeftDoubleClick\" ) or GetEvar( \"DesktopBottomLeftClick\" ) or desktopclick.Double
desktopclick.BottomRightDouble = GetEvar( \"DesktopBottomRightDoubleClick\" ) or GetEvar( \"DesktopBottomRightClick\" ) or desktopclick.Double

local lastclick = lslua.milli()
lastclick = os.time() .. string.rep( \"0\" , 3 - string.len( lastclick ) ) .. lastclick



--[[
!DesktopClick

]]
function bang_DesktopClick()

local eventx , eventy , action = \"\" , \"\" , \"\"
local x , y = lslua.mouse().x , lslua.mouse().y
local click = lslua.milli()
click = os.time() .. string.rep( \"0\" , 3 - string.len( click ) ) .. click
click , lastclick = click - lastclick , click

if x < borderleft then eventx = \"Left\" end
if x > borderright then eventx = \"Right\" end
if y < bordertop then eventy = \"Top\" end
if y > borderbottom then eventy = \"Bottom\" end

if click > clicktime
then action = eventy .. eventx .. \"\"
else action = eventy .. eventx .. \"Double\"
end

if action == \"\" then action = \"Main\" end

lslua.exec( desktopclick[action] )

end

Posted by member 248213 on 2006-08-22 04:41:58 link

I dont get the use of this? can you explain?

Posted by member 1885 on 2006-08-22 04:46:05 link

Hey, that was my line! :P

Posted by member 7223 on 2006-08-22 10:32:50 link

It supports clicks and double-clicks on desktop, on borders and on edges.

What to say more ?

Posted by member 248213 on 2006-08-22 19:03:32 link

what borders? borders of what? borders of the desktop? what are desktop borders?
replace borders with edges, and ask all the same questions

Whats the usage?
Can you give us an example? some reality/circumstance where this is used.

Why use this instead of jDesk? (although I see you use jdesk here) what added benefit?


The best thing would be some examples of how it is used, it makes our job of de-cyphering/de-coding wtf its used for a whole lot easier ;)

Posted by member 7223 on 2006-08-22 21:03:27 link

borders = desktop borders
edges = corners

examples are in desktopclick.rc

don't play the fool :)

Posted by member 5575 on 2006-08-22 21:06:47 link

Aw c'mon, we all have to utilize our strengths.

Posted by member 248213 on 2006-08-23 19:05:20 link

oh I see now, so its like label "Region" support for jDesk.

Cool :)