Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #403610

Re: window grouping updates

From owl <owl@rooftop.invalid>
Newsgroups comp.os.linux.advocacy
Subject Re: window grouping updates
Date 2017-03-26 20:28 +0000
Organization O.W.L.
Message-ID <zhv03ba.y0b@rooftop.invalid> (permalink)
References (7 earlier) <D4FBFB50.973D1%usenet@gallopinginsanity.com> <hjxzu003.bu4@rooftop.invalid> <D4FC2240.97418%usenet@gallopinginsanity.com> <lhjvu003ga.buu4h@rooftop.invalid> <D4FD5B7D.9763B%usenet@gallopinginsanity.com>

Show all headers | View raw


Snit <usenet@gallopinginsanity.com> wrote:
> On 3/26/17, 11:46 AM, in article lhjvu003ga.buu4h@rooftop.invalid, "owl"
> <owl@rooftop.invalid> wrote:
> 
>> Snit <usenet@gallopinginsanity.com> wrote:
>>> On 3/25/17, 1:12 PM, in article hjxzu003.bu4@rooftop.invalid, "owl"
>>> <owl@rooftop.invalid> wrote:
>>> 
>>>> Snit <usenet@gallopinginsanity.com> wrote:
>>>>> On 3/25/17, 1:06 AM, in article shjvoz93.g@rooftop.invalid, "owl"
>>>>> <owl@rooftop.invalid> wrote:
>>>>> 
>> ...
>> 
>>>>>> Got the auto-setting of the "on-top" fixed now using a previous approach,
>>>>>> but with the code repositioned.  Trying it with various apps shows that
>>>>>> a few don't obey the "Raise Window," but that's a matter for casual
>>>>>> investigation later.
>>>>> 
>>>>> I would be curious which ones do not work... wonder if there is a pattern.
>>>>> 
>>>> 
>>>> So far, as for obeying the "Raise Window":
>>>> 
>>>> Yes:
>>>> pluma, gnumeric, stellarium, xterm, abiword, evince, xabacus,
>>>> gnome-calculator, galculator, xpdf, xfig, pitivi, urxvt, devhelp,
>>>> ipython3, glade, anjuta, nemiver, nautilus-actions-config-tool, gv,
>>>> sqlitebrowser.
>>>> 
>>>> No:
>>>> LibreOffice, caja, gimp, gperiodic, RedNotebook, xscreensaver,
>>>> chromium, iceweasel, pan, scribus, mate-terminal, mate-system-log,
>>>> mate-system-monitor, atril, icedove, pcb designer, R commander, geeqie,
>>>> gpick, audacity, pcmfm, eom, gcolor2, okular, dolphin.
>>> 
>>> I certainly do not know much about most of those, but nothing obvious like
>>> being tied to a given DE or the like. I know GIMP and LO do not work with
>>> standard system tools well on macOS... maybe they do not on Linux either?
>>> Just shooting in the dark here -- you are working with their windowing and
>>> all should use X, right?
>>> 
>>> So, in short, no clue. :)
>>> 
>> 
>> All is fixed now.  Tested with all the apps that would not raise,
>> and they now raise.
>> 
>> Having been unable to get xdotool's windowraise command to work with
>> anything, I had substituted a click on the windows to raise them.
> 
> Oh no, GUI scripting! :)
> 

IKR.  But technically most of it is GUI scripting anyway.

>> I went back to using windowraise, but after a doing windowactivate first, and
>> now it works.  After some reading online, it seems that metacity (of which my
>> window manager, marco, is a fork) does not allow a XRaiseWindow() call unless
>> the window is active.  Why the click solution only worked part of the time is
>> a mystery I won't worry about.
>> 
>> The other thing is I found out that my solution to keeping the leader
>> window on top was unnecessary, and I can just put a "wm attributes
>> . -topmost 1" in the leader script.  The neat part though is that method
>> 
>> I had used for that is applicable to refocusing the leader window after
>> the windowactivate/ windowraise calls on the grouped windows.  So no
>> work wasted.
>> 
>> Current source:
> 
> Ah, my client shows that as an attachment. I will look through it (not that
> I will understand much of it I am sure).
> 

I'll put it at the bottom here raw.

> Have a video of the current state of it running?


https://vid.me/3osc
Those are all apps that refused to obey my orders earlier.


> Also, without even opening
> the attachment, any tips on getting it to work? Will it work for pretty much
> any desktop Linux environment?

It should work on any X11 setup, assuming you have installed the dependencies
I mentioned earlier (bash, tcl/tk, xdotool, xwininfo, etc.).

> If so I will play with it myself (perhaps not
> today... will be running in and out quite a bit).
>  

-------------- begin leader ---------------
#!/usr/bin/wish

set LINKEM /home/anon/code/groups/linkem
set wid [winfo id .]

wm attributes . -topmost 1 

wm protocol . WM_DELETE_WINDOW {
  stop
}

proc addwindow {} {
 set wid [winfo id .]
 global LINKEM
 exec $LINKEM -a $wid &
}

proc removewindow {} {
 set wid [winfo id .]
 global LINKEM
 exec $LINKEM -r $wid &
}

proc run {} {
 set wid [winfo id .]
 global LINKEM
 set channel [ open "|$LINKEM -l $wid" ]
 global PID
 set PID [pid $channel]
}

proc pause {} {
 global PID
 exec kill -9 $PID
}

proc stop {} {
 set wid [winfo id .]
  global PID
  exec rm /tmp/windowlist$wid
  exec kill -9 $PID
  exit
}

proc raisewindows {} {
 set wid [winfo id .]
 global LINKEM
 exec $LINKEM -u $wid &
}

proc screen {} {
 frame .top -borderwidth 10
 pack .top -fill x
 button .top.addwindow -text "Add Window" -command {
  addwindow
  .top.run config -state normal 
  .top.removewindow config -state normal 
 }
 pack .top.addwindow -side left 
 button .top.run -text "Run" -state disabled -command {
   run 
   .top.run config -state disabled
   .top.addwindow config -state disabled
   .top.removewindow config -state disabled
   .top.stop config -state normal 
   .top.pause config -state normal 
   .top.raisewindows config -state normal 
   }
 pack .top.run -side left 
 button .top.pause -text "Pause" -state disabled -command {
  pause
  .top.run config -state normal
  .top.addwindow config -state normal
  .top.removewindow config -state normal
  .top.stop config -state normal
  .top.raisewindows config -state normal
  }
 pack .top.pause -side left 
 button .top.stop -text "Stop" -state disabled -command stop
 pack .top.stop -side left 
 button .top.removewindow -text "Remove Window" -state disabled -command {
  removewindow 
 .top.run config -state normal
 }
 pack .top.removewindow -side left 
 button .top.raisewindows -text "Raise Windows" -state disabled -command {
  raisewindows
 }
 pack .top.raisewindows -side left 
 
}

screen 

;# exec $LINKEM -x $wid &

---------------- end leader ---------------

-------------- begin linkem ---------------
#!/bin/bash
declare -a followerids
declare -a followersax
declare -a followersay
declare -a followersrx
declare -a followersry
declare -a followersx
declare -a followersy
declare -a followersaxsoffset
declare -a followersaysoffset

# states: IsViewable, IsUnMapped

addwindow () {
touch /tmp/windowlist${1}
windowid=$(xwininfo |grep 'Window id:' |cut -f3 -d: |awk '{print $1}')
echo ${windowid} >> /tmp/windowlist${1}
}

removewindow () {
touch /tmp/windowlist${1}
windowid=$(xwininfo |grep 'Window id:' |cut -f3 -d: |awk '{print $1}')
sed -i "s/${windowid}//g" /tmp/windowlist${1}
}

linkem () {
leaderid=${1}

laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
|awk '{print $4}')
lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
|awk '{print $4}')

lrulx=$(xwininfo -id "${leaderid}" |grep "Relative upper-left X" \
|awk '{print $4}')
lruly=$(xwininfo -id "${leaderid}" |grep "Relative upper-left Y" \
|awk '{print $4}')

lulx=$(( laulx-lrulx ))
luly=$(( lauly-lruly ))

followerids+=($(cat /tmp/windowlist${1} |sort |uniq))

xdotool windowraise ${leaderid}

for (( i=0;i<${#followerids[@]};i++ ));do
  followersax[${i}]=$(xwininfo -id "${followerids[${i}]}" \
|grep "Absolute upper-left X" |awk '{print $4}')
  followersay[${i}]=$(xwininfo -id "${followerids[${i}]}" \
|grep "Absolute upper-left Y" |awk '{print $4}')

followersrx[${i}]=$(xwininfo -id "${followerids[${i}]}" \
|grep "Relative upper-left X" |awk '{print $4}')
followersry[${i}]=$(xwininfo -id "${followerids[${i}]}" \
|grep "Relative upper-left Y" |awk '{print $4}')

followersx[${i}]=$(( followersax[${i}]-followersrx[${i}] ))
followersy[${i}]=$(( followersay[${i}]-followersry[${i}] ))
done

for (( i=0;i<${#followerids[@]};i++ ));do
  followersxoffset[${i}]=$(( ${laulx}-${followersx[${i}]} ))
  followersyoffset[${i}]=$(( ${lauly}-${followersy[${i}]} ))
done

while [ 1 ]; do

laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
|awk '{print $4}')

lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
|awk '{print $4}')


lrulx=$(xwininfo -id "${leaderid}" |grep "Relative upper-left X" \
|awk '{print $4}')
lruly=$(xwininfo -id "${leaderid}" |grep "Relative upper-left Y" \
|awk '{print $4}')

lulx=$(( laulx-lrulx ))
luly=$(( lauly-lruly ))

xdotool windowraise ${leaderid}

for (( i=0;i<${#followerids[@]};i++ ));do
xdotool windowmove ${followerids[${i}]} \
$((${laulx}-${followersxoffset[${i}]})) \
$((${lauly}-${followersyoffset[${i}]}))
done

   leaderstate=$(xwininfo -id ${leaderid} |grep "Map State:" \
|awk '{print $3}')
   
   if [ "${leaderstate}" = "IsViewable" ];then
      for (( i=0;i<${#followerids[@]};i++ ));do
         xdotool windowmap ${followerids[${i}]}
      done
   elif [ "${leaderstate}" = "IsUnMapped" ];then
      for (( i=0;i<${#followerids[@]};i++ ));do
         xdotool windowminimize ${followerids[${i}]}
      done
   fi

done
}

raisem () {
leaderid=${1}

laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
|awk '{print $4}')
lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
|awk '{print $4}')

lrulx=$(xwininfo -id "${leaderid}" |grep "Relative upper-left X" \
|awk '{print $4}')
lruly=$(xwininfo -id "${leaderid}" |grep "Relative upper-left Y" \
|awk '{print $4}')

lulx=$(( laulx-lrulx ))
luly=$(( lauly-lruly ))

followerids+=($(cat /tmp/windowlist${1} |sort |uniq))

# works:
#pat=$(for i in $(cat /tmp/windowlist0x6a0000d);do echo -n "${i} ";done |sed -e 's/ $//g' |sed -e 's/ /\\|/g');xwininfo -tree -root |grep ${pat} |awk '{print $1}'

followerlist=$(for (( i=0;i<${#followerids[@]};i++ ));do echo ${followerids[${i}]}; done)

pat=$(for i in $(echo ${followerlist});do echo -n "${i} ";done |sed -e 's/ $//g' |sed -e 's/ /\\|/g')

stack+=($(xwininfo -tree -root |grep ${pat} |awk '{print $1}'))

for (( i=${#stack[@]}-1;i>=0;i-- ));do 
 xdotool windowactivate ${stack[${i}]}
 xdotool windowraise ${stack[${i}]}
done

parent=$(xwininfo -tree -id ${1} |grep 'Parent window id:' |cut -f2 -d: |awk '{print $1}')
xdotool windowactivate ${parent}

}

touch /tmp/windowlist${2}


case ${1} in 
   -a)
      addwindow ${2}
      exit
    ;;
   -r)
      removewindow ${2}
      exit
    ;;
   -l)
      linkem ${2}
      exit
    ;;
   -u)
      raisem ${2}
      exit
    ;;
    *)
      exit
    ;; 
esac

---------------- end linkem ---------------

 

Back to comp.os.linux.advocacy | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-24 14:58 +0000
  Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 10:48 -0500
    Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-24 18:40 +0000
      Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 11:55 -0700
        Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 01:03 +0000
          Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 18:15 -0700
            Re: window grouping updates Tampon <letsplayfindthestring@bloody.net> - 2017-03-25 02:57 +0000
      Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 14:07 -0500
        Re: window grouping updates Steve Carroll <fretwizzer@gmail.com> - 2017-03-24 12:14 -0700
          Re: window grouping updates Steve Carroll <fretwizzer@gmail.com> - 2017-03-24 12:24 -0700
        Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 01:01 +0000
          Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 20:26 -0500
            Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 02:15 +0000
            Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 03:59 +0000
              Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 21:28 -0700
                Re: window grouping updates Tampon <letsplayfindthestring@bloody.net> - 2017-03-25 04:32 +0000
              Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 23:47 -0500
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 08:06 +0000
                Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-25 09:33 -0500
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 20:09 +0000
                Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-25 15:14 -0500
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-25 10:47 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-25 20:12 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-25 13:33 -0700
                Re: window grouping updates Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-03-25 22:04 +0100
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-25 14:30 -0700
                Re: window grouping updates Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-03-25 22:48 +0100
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-25 15:12 -0700
                Re: window grouping updates Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-03-25 23:34 +0100
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-25 17:13 -0700
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 11:50 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-26 20:28 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 13:59 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-26 21:52 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 15:49 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-26 22:59 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 16:07 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-26 23:25 +0000
                Re: window grouping updates Tampon <letsplayfindthestring@bloody.net> - 2017-03-26 23:35 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 16:38 -0700
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 16:43 -0700
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-26 19:16 -0700
                Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-27 13:36 +0000
                Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-27 10:43 -0700
  Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 10:38 -0700

csiph-web