edit:
oops. this problem may have always been the case. looks like the behavior described below is the same on the old system. i must have always run the script from a taskbar icon and never from the desktop icon. both systems work correctly from the taskbar icon and both systems also have the focus issue from the desktop icon. makes some sense when i think about it. would still be interesting to hear if it would be possible to make this work from the desktop icon. thanks and sorry.
end edit
i just rebuilt my system with a fresh install and a script (see below) i regularly use has started behaving oddly.
the script moves the active window to a specific position on a very large desktop. i have it because sometimes i will open a window while working and, depending on the application, the new window will open behind something. in this case, i just click a desktop or taskbar icon and the window is repositioned to a place where i can see and grab it.
since the rebuild, though, clicking the icon does not work. it just moves all of my desktop icons, as a group, slightly. running the script from a konsole window via command line does reposition the konsole window to the correct position.
it looks to me like i may have missed a setting somewhere in the rebuild that is causing the active window to lose focus as soon as i click the icon, thus, telling the script to move the desktop and not what had been the active window.
anyone know how to fix this?
thanks,
babag
Code:
#!/bin/sh
#
# Move the current window to the next monitor.
#
# Only works on a horizontal monitor setup.
# Also works only on one X screen (which is the most common case).
#
# Props to
# http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/
#
# Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and
# checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as
# the first command does not respect panel/decoration offsets and the second
# will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo".
screen_width=`xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f1`
display_width=`xdotool getdisplaygeometry | cut -d" " -f1`
window_id=`xdotool getactivewindow`
# Remember if it was maximized.
window_state=`xprop -id $window_id _NET_WM_STATE | awk '{ print $3 }'`
# Un-maximize current window so that we can move it
wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz
# Read window position
x=`xwininfo -id $window_id | awk '/Absolute upper-left X:/ { print $4 }'`
y=`xwininfo -id $window_id | awk '/Absolute upper-left Y:/ { print $4 }'`
# Subtract any offsets caused by panels or window decorations
x_offset=`xwininfo -id $window_id | awk '/Relative upper-left X:/ { print $4 }'`
y_offset=`xwininfo -id $window_id | awk '/Relative upper-left Y:/ { print $4 }'`
x=`expr $x - $x_offset`
y=`expr $y - $y_offset`
# Compute new X position
new_x=`expr $x + $display_width`
# If we would move off the right-most monitor, we set it to the left one.
# We also respect the window's width here: moving a window off more than half its width won't happen.
width=`xdotool getwindowgeometry $window_id | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1`
if [ `expr $new_x + $width / 2` -gt $screen_width ]; then
new_x=`expr $new_x - $screen_width`
fi
# Don't move off the left side.
if [ $new_x -lt 0 ]; then
new_x=0
fi
## Move the window
#xdotool windowmove $window_id $new_x $y
# Move the window to specific BabaG monitor setup location
#new_x=3360
#y=2160
new_x=3605
y=2190
xdotool windowmove $window_id $new_x $y
# Maximize window again, if it was before
if [ "${window_state}" = "_NET_WM_STATE_MAXIMIZED_HORZ," ]; then
wmctrl -ir $window_id -b add,maximized_vert,maximized_horz
fi