diff options
Diffstat (limited to 'urgent.tcl')
-rw-r--r-- | urgent.tcl | 49 |
1 files changed, 33 insertions, 16 deletions
@@ -2,8 +2,16 @@ namespace eval urgent { variable options + variable state - custom::defgroup Urgent [::msgcat::mc "Urgency hinting."] -group Plugins + custom::defgroup Urgent \ + [::msgcat::mc "Urgency hinting.\ + This plugin provides an ability to set the so called\ + \"urgency flag\" as a special hint to the window manager\ + on Tkabber's chat windows when new messages arrive.\ + ICCCM compliant window managers may use this hint\ + to somehow draw the user's attention to such a window."] \ + -group Plugins custom::defvar options(enabled) 1 \ [::msgcat::mc "Set the urgency hint on Tkabber's chat\ @@ -23,7 +31,7 @@ namespace eval urgent { -group Urgent custom::defvar options(handle_server_messages) 0 \ - [::msgcat::mc "React on messages generated by the server"] \ + [::msgcat::mc "React on messages generated by the server."] \ -type boolean \ -group Urgent } @@ -77,7 +85,7 @@ proc urgent::chat_message_notify {chatid from type body extras} { } proc urgent::xclientwinid {tkwin} { - # Parent window id: 0x2e0001e "Tkabber" + tkwait visibility $tkwin ;# seems to be needed by xwininfo set data [exec xwininfo -children -id [winfo id $tkwin]] if {[regexp {Parent window id: (\S+)} $data -> id]} { return $id @@ -92,34 +100,43 @@ proc urgent::root_xwinid {xwinid _chatid} { } proc urgent::chat_xwinid {chatid} { - #xclientwinid [chat::winid $chatid] - winfo id [chat::winid $chatid] + xclientwinid [chat::winid $chatid] } proc urgent::record_xwinid {chatid _type} { - variable xwinids - set xwinids($chatid) [xwinid $chatid] + variable state + set state(xwinid,$chatid) [xwinid $chatid] + set state(active,$chatid) false } proc urgent::forget_xwinid {chatid} { - variable xwinids - unset xwinids($chatid) + variable state + + unset state(xwinid,$chatid) + unset state(active,$chatid) } proc urgent::set_urgency_hint {chatid} { variable options - variable xwinids + variable state - exec $options(program) -set $xwinids($chatid) + if {!$state(active,$chatid)} { + exec $options(program) -set $state(xwinid,$chatid) & + set state(active,$chatid) true + } } proc urgent::clear_urgency_hint {winid} { - variable options - variable xwinids - set chatid [chat::winid_to_chatid $winid] + if {$chatid == ""} return + + variable options + variable state - exec $options(program) -clear $xwinids($chatid) + if {$state(active,$chatid)} { + set state(active,$chatid) false + exec $options(program) -clear $state(xwinid,$chatid) & + } } namespace eval urgent { @@ -132,7 +149,7 @@ namespace eval urgent { if {![file executable $options(program)]} { puts stderr [::msgcat::mc "Urgency hint setting program \"%s\"\ is not available or not executable by the current user.\ - The \"urgent\" plugin is disabled. Consult its README file." + The \"urgent\" plugin is disabled. Consult its README file." \ $options(program)] set options(enabled) 0 } |