Page 6 of 16 FirstFirst ... 45678 ... LastLast
Results 51 to 60 of 158

Thread: Aero Snap function?

  1. #51
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    Quote Originally Posted by arrow.69 View Post
    For compizsnap-left.sh:

    Code:
    #!/bin/sh
    
    if (/usr/bin/X11/xinput --query-state 11 | grep down)
    then
    	while (/usr/bin/X11/xinput --query-state 11 | grep down)
    	do 
    	echo 'test'
    	done
    
    
    	if (xdotool getmouselocation | grep x:[0-7][[:space:]])
    	then
            
    		WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
    
    	else
    	exit 1
    	fi
    
    
    else
            exit 1
    fi
    we could easily grep the current mouse location (with only using native xorg binaries) out of the following command:
    Code:
    xinput --query-state <your mouse id>
    it gives you the following lines:
    Code:
    ValuatorClass Mode=Relative Proximity=In
    	valuator[0]=981
    	valuator[1]=350
    give me a few mins to play around with it on my machine and I will see if we cant combine our two scripts and figure this out once and for all.

  2. #52
    Join Date
    Mar 2009
    Beans
    41

    Re: Aero Snap function?

    The nice thing about using

    Code:
    xinput --query-stae <mouse-id>
    is the output seems to be independent of screen resolution, at least on my system. Changing resolution from 1440x900 to 1200x720, extreme right stays constant at valuator[0]=5470

    Those numbers do seem kind of arbitrary though. Do you know what they're meant to represent?

  3. #53
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    I never actually noticed that. I am going to do some reading on the manpages and maybe I can find out.

  4. #54
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    from what I can tell after testing it out on my own machine the values actually max out at the maximum of your screen resolution. So on my 1440x900 it has a range of

    valuator[0]=0 through valuator[0]=1439
    valuator[1]=0 through valuator[1]=899

    however, I did notice that the mouse didnt always seem to stay at the maximum value so we may want to implement a range check instead of a max value check. I'm thinking something in the range of 10 pixels.

    so, time to dive back into the code

  5. #55
    Join Date
    Mar 2009
    Beans
    41

    Re: Aero Snap function?

    It's odd. If I call xdotool getmouselocation, the value ranges from

    x: 0-1439
    y: 0-899

    My resolution's the same as yours.

    However with xinput --query state 11, my range is:

    valuator[0]=1472-5469
    valuator[1]=1408-4445

    Those values mean a ratio of 3997/3037, which is different from 1440/900. I'm running on 10.04. If it's a problem with my particular set up, then that's fine, but if it's like this for anyone running lucid, it might cause issues because you can't simply use your resolution value to determine what your bounds for the valuator values are. I don't see why my output would be ****ed, since I'm running a standard one screen setup with standard open Radeon drivers.

  6. #56
    Join Date
    Mar 2009
    Beans
    41

    Re: Aero Snap function?

    I'm thinking the difference between our outputs might have something to do with subpixel mapping.

    xinput --version outputs:

    xinput version 1.5.0
    XI version on server: 2.0

    According to this link, new features in XI2 include support for subpixel mapping. That might explain why my numbers seem more arbitrary. Of course if you're using the same version as me, my theory collapses.

  7. #57
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    I am using the same version as you. However, I know most systems are differently set up. Did you forget to change the mouse's ID (I might have been unclear in the directions). My mouse has an ID of 11. Yours may be different. xinput list should show which one you are looking for.

    toss me the output of
    Code:
    xinput list
    and just a heads up... i have a working (and hopefully resolution independent) prototype running right now. I will post the files here shortly after i fix the bugs.

  8. #58
    Join Date
    Mar 2009
    Beans
    41

    Re: Aero Snap function?

    Sounds good. No, I'm pretty positive I have the right ID.

    I'm on my laptop and the Synaptics touchpad is 11. In any case here's the output for xinput --list

    Code:
    ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=11	[slave  pointer  (2)]
    ⎜   ↳ Macintosh mouse button emulation        	id=12	[slave  pointer  (2)]
    ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
        ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
        ↳ Power Button                            	id=6	[slave  keyboard (3)]
        ↳ Video Bus                               	id=7	[slave  keyboard (3)]
        ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
        ↳ USB 2.0 Camera                          	id=9	[slave  keyboard (3)]
        ↳ AT Translated Set 2 keyboard            	id=10	[slave  keyboard (3)]
        ↳ Asus Laptop extra buttons               	id=13	[slave  keyboard (3)]
    xinput --query-state 11 gives me relevant output. The changes in value agree with my cursor movements. The range of values is just odd. As long as it's just on my system, it's not a big deal, snap is working fine with my current script. I'm mainly just curious as to why my output is different. Changing resolution from 640x480 to 1440x900, the ranges for valuator[0-1] stay exactly the same.

  9. #59
    Join Date
    Dec 2009
    Location
    Vidor, Texas
    Beans
    26
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Aero Snap function?

    I would just like to say thanks for all of your work. I am a student and do not have the time or the knowledge to contribute (yet). So, thanks on behalf of us free loaders. I am off to bed (finals week next week), but I am super interested in seeing your solution. During the summer I hope to work on my programming skills so that I, too, may contribute. Thanks.

  10. #60
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    Quote Originally Posted by arrow.69 View Post
    xinput --query-state 11 gives me relevant output. The changes in value agree with my cursor movements. The range of values is just odd. As long as it's just on my system, it's not a big deal, snap is working fine with my current script. I'm mainly just curious as to why my output is different. Changing resolution from 640x480 to 1440x900, the ranges for valuator[0-1] stay exactly the same.
    interesting, I wonder if it has anything to do with the type of video card and/or driver you are using. I am personaly using a NVIDIA card using the non-free NV driver. Either way the nice thing is that the scripts will work independently of resolution (HOORAY FOR MATH ). I updated my previous howto for the complete updated instructions (even with some comments) but will post again here for posterity. Enjoy the snapping wonders cause next we tackle aero shake

    compizsnap-left.sh
    Code:
    #!/bin/sh
    #
    # CompizSnap is a collaborative project from ubuntuforums.org and is free software. 
    # This script adds window snapping functionality to compiz using the commands plugin.
    # 
    # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: 
    #
    
    MOUSE="11"
    
    # ----- Don't edit below this line unless you know what you are doing.
    WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2-10))
    
    echo $WIDTH
    TEMPWIDTH=$(($WIDTH-10))
    echo $TEMPWIDTH
    if /usr/bin/X11/xinput --query-state $MOUSE | grep down
    then
       	while (/usr/bin/X11/xinput --query-state $MOUSE | grep down)
    	do 
    		echo 'button pressed'
    	done
    	
    	if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[0\]=." | sed s/"valuator\[0\]="//)" -le 10 ]
    	then
            
    		wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-10
    
    	else
    		echo "exiting without matching"
    		exit 1
    	fi
    else
    		echo "exiting because button isnt "
            exit 1
    fi
    compizsnap-right.sh
    Code:
    #!/bin/sh
    #
    # CompizSnap is a collaborative project from ubuntuforums.org and is free software. 
    # This script adds window snapping functionality to compiz using the commands plugin.
    # 
    # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: 
    #
    
    MOUSE="11"
    
    # ----- Don't edit below this line unless you know what you are doing.
    WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2))
    
    echo $WIDTH
    TEMPWIDTH=$(($WIDTH-10))
    echo $TEMPWIDTH
    if /usr/bin/X11/xinput --query-state $MOUSE | grep down
    then
       	while (/usr/bin/X11/xinput --query-state $MOUSE | grep down)
    	do 
    		echo 'button pressed'
    	done
    	
    	if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[0\]=." | sed s/"valuator\[0\]="//)" -ge $TEMPWIDTH ]
    	then
            
    		wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
    
    	else
    		echo "exiting without matching"
    		exit 1
    	fi
    else
    		echo "exiting because button isnt "
            exit 1
    fi
    compizsnap-max.sh
    Code:
    #!/bin/sh
    #
    # CompizSnap is a collaborative project from ubuntuforums.org and is free software. 
    # This script adds window snapping functionality to compiz using the commands plugin.
    # 
    # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: 
    #
    
    MOUSE="11"
    
    # ----- Don't edit below this line unless you know what you are doing.
    if /usr/bin/X11/xinput --query-state $MOUSE | grep down
    then
       	while (/usr/bin/X11/xinput --query-state $MOUSE | grep down)
    	do 
    		echo 'button pressed'
    	done
    	if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[1\]=." | sed s/"valuator\[1\]="//)" -le 10 ]
    	then
            
    		wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
    
    	else
    		echo "exiting without matching"
    		exit 1
    	fi
    else
    		echo "exiting because button isnt "
            exit 1
    fi
    Last edited by gotsanity; May 1st, 2010 at 06:18 AM. Reason: added code

Page 6 of 16 FirstFirst ... 45678 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •