LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   about xwindow. mouse left button and right button (https://www.linuxquestions.org/questions/programming-9/about-xwindow-mouse-left-button-and-right-button-732402/)

chuangsheng 06-12-2009 02:18 AM

about xwindow. mouse left button and right button
 
The Button1MotionMask happend MotionNotify,
and Button2MotionMask happend MotionNotify to,
Button3MotionMask,
Button4MotionMask
Button5MotionMask.......


same,there happend ButtonPress and ButtonRelease.
but, i don't know where is mouse left button, where is mouse right button.

my code:)
Code:


if ((XGrabPointer
            (disp, root, False,
              Button1MotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
              GrabModeAsync, root, cursor, CurrentTime) != GrabSuccess))
                gib_eprintf("couldn't grab pointer:");



        while (1) {       
                while (!done && XPending(disp)) {
                        XNextEvent(disp, &ev);

                        switch (ev.type) {
                                case MotionNotify://left button select to do something..

                                case xxxx://left button ButtonPress to do something..

                                case xxxx://left button ButtonRelease to do something..

[same:------->  right button no select~~]
                                case xxxx://right button ButtonPress to do something..



a new progremer..


thanks.

wje_lq 06-12-2009 04:46 AM

The left button is button 1.

The right button is button 2.

dmail 06-12-2009 09:24 AM

Quote:

Originally Posted by wje_lq (Post 3571517)
The left button is button 1.

The right button is button 2.

__normally__ right is Button3.
Code:

        while (1)
        {       
                while (!done && XPending(disp))
                {
                        XNextEvent(disp, &ev);

                        switch (ev.type)
                        {
                                case MotionNotify://left button select to do something..

                                case ButtonRelease:
                                case ButtonPress:
                                {
                                        switch (ev.xbutton.button)
                                        {
                                                case Button1://left
                                                case Button2://middle
                                                case Button3://right
                                                case Button4://wheel up
                                                case Button5://whell down


wje_lq 06-13-2009 12:33 AM

Quote:

Originally Posted by dmail (Post 3571745)
__normally__ right is Button3.

Oops. My bad.

chuangsheng 06-13-2009 12:34 AM

Thanks wje_lq and dmail.
I'm form China, I'm sorry my English is bad.
my codes run my ubuntu now ^_^ thanks!


All times are GMT -5. The time now is 04:27 AM.