void
GrabButtonSet(unsigned int button, unsigned int modifiers, Win win,
	      unsigned int event_mask, unsigned int csr, int confine)
{
   Bool                owner_events = False;
   int                 pointer_mode = GrabModeSync;
   int                 keyboard_mode = GrabModeAsync;
   Window              confine_to = (confine) ? WinGetXwin(win) : None;
   int                 i;

   if (modifiers == AnyModifier)
     {
	XGrabButton(disp, button, modifiers,
		    WinGetXwin(win), owner_events, event_mask, pointer_mode,
		    keyboard_mode, confine_to, ECsrGet(csr));
	return;
     }

   for (i = 0; i < 8; i++)
     {
	if (i && !Mode.masks.mod_combos[i])
	   continue;
	XGrabButton(disp, button, modifiers | Mode.masks.mod_combos[i],
		    WinGetXwin(win), owner_events, event_mask, pointer_mode,
		    keyboard_mode, confine_to, ECsrGet(csr));
     }
}
Exemple #2
0
void client_select_events(struct WM_t *W, struct wmclient *C)
{
    XSelectInput(W->XDisplay, C->win, StructureNotifyMask);

    /* Grab ALT+click events for moving windows */
    XGrabButton(W->XDisplay, Button1, Mod1Mask, C->win, 0,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
                GrabModeAsync, GrabModeSync, None, None);
    /* Grab Shift+alt+click events for moving windows */
    XGrabButton(W->XDisplay, Button1, Mod1Mask | ShiftMask, C->win, 0,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
                GrabModeAsync, GrabModeSync, None, None);
    /* Grab for any click so if it is clicked on it can be refocused */
    XGrabButton(W->XDisplay, Button1, 0, C->win, 0, ButtonPressMask,
                GrabModeAsync, GrabModeSync, None, None);

    /* Alt-Tab */
    grabkey(W, C, XK_Tab, Mod1Mask);
    /* Shift-alt-enter for menu */
    grabkey(W, C, XK_Return, ShiftMask | Mod1Mask);
    /* Shift-alt-F for fullscreen */
    grabkey(W, C, XK_f, ShiftMask | Mod1Mask);
    /* Shift-alt-arrows for tiling */
    grabkey(W, C, XK_Up, ShiftMask | Mod1Mask);
    grabkey(W, C, XK_Down, ShiftMask | Mod1Mask);
    grabkey(W, C, XK_Left, ShiftMask | Mod1Mask);
    grabkey(W, C, XK_Right, ShiftMask | Mod1Mask);
}
Exemple #3
0
/** Grab buttons
 * \param c Client pointer
 * \param focused For know if c is or not focused
*/
void
mouse_grabbuttons(Client *c, Bool focused)
{
     size_t i;
     uint but[] = {Button1, Button2, Button3, Button4, Button5};

     XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
     if(focused)
          for(i = 0; i < LEN(but); ++i)
          {
               XGrabButton(dpy, but[i], conf.client.mod, c->win, False,
                           ButtonMask, GrabModeAsync,GrabModeSync, None, None);
               XGrabButton(dpy, but[i], conf.client.mod|LockMask, c->win, False,
                           ButtonMask, GrabModeAsync,GrabModeSync, None, None);
               XGrabButton(dpy, but[i], conf.client.mod|numlockmask, c->win, False,
                           ButtonMask, GrabModeAsync,GrabModeSync, None, None);
               XGrabButton(dpy, but[i], conf.client.mod|LockMask|numlockmask, c->win, False,
                           ButtonMask, GrabModeAsync,GrabModeSync, None, None);
          }
     else
          XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
                      ButtonMask, GrabModeAsync, GrabModeSync, None, None);

     return;
}
Exemple #4
0
void
GrabButtonSet(unsigned int button, unsigned int modifiers, Win win,
	      unsigned int event_mask, unsigned int csr, int confine __UNUSED__)
{
   Bool                owner_events = False;
   int                 pointer_mode = GrabModeSync;
   int                 keyboard_mode = GrabModeAsync;
   int                 i;

#if USE_XI2
   EXIEventMask        em;
   XIGrabModifiers     modifiers_inouts[8];
   int                 num_modifiers;

   EXIMaskSetup(&em, DEV_PTR, event_mask);

   if (modifiers == AnyModifier)
     {
	num_modifiers = 1;
	modifiers_inouts[0].modifiers = XIAnyModifier;
	modifiers_inouts[0].status = 0;
     }
   else
     {
	num_modifiers = 0;
	for (i = 0; i < 8; i++)
	  {
	     if (i && !Mode.masks.mod_combos[i])
		continue;
	     modifiers_inouts[num_modifiers].modifiers =
		modifiers | Mode.masks.mod_combos[i];
	     modifiers_inouts[num_modifiers].status = 0;
	     num_modifiers++;
	  }
     }
   XIGrabButton(disp, DEV_PTR, button, WinGetXwin(win), ECsrGet(csr),
		pointer_mode, keyboard_mode, owner_events,
		&em.em, num_modifiers, modifiers_inouts);
#else
   EX_Window           confine_to = (confine) ? WinGetXwin(win) : NoXID;

   if (modifiers == AnyModifier)
     {
	XGrabButton(disp, button, modifiers,
		    WinGetXwin(win), owner_events, event_mask, pointer_mode,
		    keyboard_mode, confine_to, ECsrGet(csr));
	return;
     }

   for (i = 0; i < 8; i++)
     {
	if (i && !Mode.masks.mod_combos[i])
	   continue;
	XGrabButton(disp, button, modifiers | Mode.masks.mod_combos[i],
		    WinGetXwin(win), owner_events, event_mask, pointer_mode,
		    keyboard_mode, confine_to, ECsrGet(csr));
     }
#endif
}
Exemple #5
0
void Gesture::grab_mouse( bool grab_P )
    {
    if( grab_P )
        {
        KXErrorHandler handler;
        static int mask[] = { 0, Button1MotionMask, Button2MotionMask, Button3MotionMask,
            Button4MotionMask, Button5MotionMask, ButtonMotionMask, ButtonMotionMask,
            ButtonMotionMask, ButtonMotionMask };
#define XCapL KKeyNative::modXLock()
#define XNumL KKeyNative::modXNumLock()
#define XScrL KKeyNative::modXScrollLock()
        unsigned int mods[ 8 ] = 
            {
            0, XCapL, XNumL, XNumL | XCapL,
            XScrL, XScrL | XCapL,
            XScrL | XNumL, XScrL | XNumL | XCapL
            };
#undef XCapL
#undef XNumL
#undef XScrL
        for( int i = 0;
             i < 8;
             ++i )
            XGrabButton( qt_xdisplay(), button, mods[ i ], qt_xrootwin(), False,
                ButtonPressMask | ButtonReleaseMask | mask[ button ], GrabModeAsync, GrabModeAsync,
                None, None );
        bool err = handler.error( true );
        kdDebug( 1217 ) << "Gesture grab:" << err << endl;
        }
    else
        {
        kdDebug( 1217 ) << "Gesture ungrab" << endl;
        XUngrabButton( qt_xdisplay(), button, AnyModifier, qt_xrootwin());
        }
    }
Exemple #6
0
static void __focus_grab_one_button(
	FvwmWindow *fw, int button, int grab_buttons)
{
	Bool do_grab;

	do_grab = (grab_buttons & (1 << button));
	if ((do_grab & (1 << button)) == (fw->grabbed_buttons & (1 << button)))
	{
		return;
	}
	if (do_grab)
	{
		XGrabButton(
			dpy, button + 1, AnyModifier, FW_W_PARENT(fw), True,
			ButtonPressMask, GrabModeSync, GrabModeAsync, None,
			None);
		/* Set window flags accordingly as we grab or ungrab. */
		fw->grabbed_buttons |= (1 << button);
	}
	else
	{
		XUngrabButton(dpy, button + 1, AnyModifier, FW_W_PARENT(fw));
		fw->grabbed_buttons &= ~(1 << button);
	}

	return;
}
Exemple #7
0
void client_focus(struct WM_t *W, struct wmclient *C)
{
    int oldidx;
    struct wmclient *old;

    /* Don't do anything if there's nothing to focus */
    if (W->nclients == 0)
        return;

    oldidx = get_client_index(W, C->win);
    old = W->clients[0];

    move_down_client_list(W, 0, oldidx);
    W->clients[0] = C;

    /* Unfocus the old window */
    /* Re-enable grabbing for click events */
    XGrabButton(W->XDisplay, Button1, 0, old->win, 0, ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
                GrabModeAsync, GrabModeSync, None, None);
    /* Make the border boring */
    set_border_colour(W, old, 0);

    set_border_colour(W, C, 1);
    XRaiseWindow(W->XDisplay, C->win);
    XSetInputFocus(W->XDisplay, C->win, RevertToPointerRoot, CurrentTime);
    XUngrabButton(W->XDisplay, Button1, 0, C->win);

    refresh_current_head(W);
}
static void
updatePassiveButtonGrabs (CompScreen *s)
{
    unsigned int mask;
    int          i;

    XUngrabButton (s->display->display, AnyButton, AnyModifier, s->root);

    for (i = 0; i < s->nButtonGrab; i++)
    {
	mask = virtualToRealModMask (s->display, s->buttonGrab[i].modifiers);
	if (!(mask & CompNoMask))
	{
	    XGrabButton (s->display->display,
			 s->buttonGrab[i].button,
			 mask,
			 s->root,
			 TRUE,
			 POINTER_GRAB_MASK,
			 GrabModeAsync,
			 GrabModeAsync,
			 None,
			 None);
	}
    }
}
Exemple #9
0
PRIVATE void CreateLido ()
{
	Widget	sink;
	Arg	args[10];
	int	n;

      /* Create a new toplevel Shell */
	n = 0;
	if (LidoGeometry[0] != '\0')
	{
		XtSetArg (args[n], XtNgeometry, LidoGeometry); n++;
	}
	XtSetArg (args[n], XtNtitle, Res.lido_name); n++;
	LidoTop = XtCreatePopupShell ("lido", topLevelShellWidgetClass,
						Toplevel, args, n);

      /* Create the Text Widget */
	n = 0;
	XtSetArg (args[n], XtNtype, XawAsciiFile); n++;
	XtSetArg (args[n], XtNstring, Res.lido_name); n++;
	LidoText = XtCreateManagedWidget ("lidoText", asciiTextWidgetClass,
						LidoTop, args, n);

      /* Realize the new top level Widget */
	XtPopup (LidoTop, XtGrabNone);

      /*
       * This is a hack so that wm_delete_window will close the rule graph window.
       */
       
        /* Register Actions */
       XtAppAddActions (XtWidgetToApplicationContext(LidoTop), lido_actions, XtNumber(lido_actions));

       XtOverrideTranslations(LidoTop, 
		    XtParseTranslationTable ("<Message>WM_PROTOCOLS: close()"));
       
       wm_delete_window = XInternAtom (XtDisplay(LidoTop), "WM_DELETE_WINDOW", False);
       
       XSetWMProtocols (XtDisplay(LidoTop), XtWindow(LidoTop),
			    &wm_delete_window, 1);


      /* Try to find text sink */
	sink = XtNameToWidget (LidoTop, AsciiTextSinkName);
	if (sink == NULL)
	{
/* Don't give warnings... XtNameToWidget has never worked!
		fprintf (stderr,"%s: Couldn't find window of LIDO text.\n",
				ProgName);
		fprintf (stderr, "Menu will not work in LIDO window.\n");
*/
		return;
	}
	
      /* Register a passive grab for menu-popup */
	XGrabButton (XtDisplay (sink), AnyButton, AnyModifier, 
		XtWindow (sink), TRUE, ButtonPressMask|ButtonReleaseMask,
		GrabModeAsync, GrabModeAsync, None, None);
}
Exemple #10
0
int main(int argc, char * argv[]) {
	Window root;
	Display * display;
	XEvent xev;
	int screenWidth;
	int screenHeight;

	display = XOpenDisplay(NULL);
	if (display == NULL) {
		if (debug) printf("Could not open display\n");
		return 1;
	}

	root = DefaultRootWindow(display);
	screenWidth = WidthOfScreen(DefaultScreenOfDisplay(display));
	screenHeight = HeightOfScreen(DefaultScreenOfDisplay(display));
	if (debug) printf("Screen width: %i\n", screenWidth);
	if (debug) printf("Screen height: %i\n", screenHeight);

	XAllowEvents(display, AsyncBoth, CurrentTime);

	bool go = true;

	// We grab
	XGrabButton(display, AnyButton, AnyModifier, root, true, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);

	while (go) {
		XNextEvent(display, &xev);

		switch(xev.type) {
			case ButtonPress:
				if (debug) printf("Button press - %i\n", xev.xbutton.button);
				if (debug) printf("Coordinates - %i, %i\n", xev.xbutton.x, xev.xbutton.y);
			break;

			case ButtonRelease:
				if (debug) printf("Button release - %i\n", xev.xbutton.button);
				if (xev.xbutton.y>screenHeight-400)
					// If we touch on the bottom side of the screen, we go to the next page
					pageForward(display);
				else if (xev.xbutton.x>screenWidth-200 && xev.xbutton.y<200)
					// If we touch the upper right corner, we quit
					go = false;
				else
					// If touched anywhere else let's apply a simple touch where we are
					// It's not perfect, because it will disable gestures
					SendMouseEvent(display, Button1, xev.xbutton.x, xev.xbutton.y, true);
					usleep(10000);
					SendMouseEvent(display, Button1, xev.xbutton.x, xev.xbutton.y, false);
			break;
		}
	}

	XUngrabButton(display, AnyButton, AnyModifier, root);

	XCloseDisplay(display);

	return 0;
}
void x11_hotkeys::my_grab_button(Display * dpy, unsigned int button, 
			      unsigned int modifier, Window win)
{
  modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);

  XGrabButton (dpy, button, modifier, (win ? win : DefaultRootWindow (dpy)),
	       False, ButtonPressMask | ButtonReleaseMask,
	       GrabModeAsync, GrabModeAsync, None, None);

  if (modifier == AnyModifier)
    return;

  if (numlock_mask)
    XGrabButton (dpy, button, modifier | numlock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);


  if (capslock_mask)
    XGrabButton (dpy, button, modifier | capslock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);

  if (scrolllock_mask)
    XGrabButton (dpy, button, modifier | scrolllock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);

  if (numlock_mask && capslock_mask)
    XGrabButton (dpy, button, modifier | numlock_mask | capslock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);

  if (numlock_mask && scrolllock_mask)
    XGrabButton (dpy, button, modifier | numlock_mask | scrolllock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);

  if (capslock_mask && scrolllock_mask)
    XGrabButton (dpy, button, modifier | capslock_mask | scrolllock_mask,
		 (win ? win : DefaultRootWindow (dpy)),
		 False, ButtonPressMask | ButtonReleaseMask,
		 GrabModeAsync, GrabModeAsync, None, None);

  if (numlock_mask && capslock_mask && scrolllock_mask)
    XGrabButton (dpy, button,
		 modifier | numlock_mask | capslock_mask | scrolllock_mask,
		 (win ? win : DefaultRootWindow (dpy)), False,
		 ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
		 GrabModeAsync, None, None);
}
Exemple #12
0
static void grab_client_button(MouseBinding* bind, HSClient* client) {
    unsigned int modifiers[] = { 0, LockMask, *g_numlockmask_ptr, *g_numlockmask_ptr|LockMask };
    for(int j = 0; j < LENGTH(modifiers); j++) {
        XGrabButton(g_display, bind->button,
                    bind->modifiers | modifiers[j],
                    client->window, False, ButtonPressMask | ButtonReleaseMask,
                    GrabModeAsync, GrabModeSync, None, None);
    }
}
Exemple #13
0
static inline int up_x11createframe(void)
{
  XGCValues gcval;
  char *argv[2] = { "nuttx", NULL };
  char *winName = "NuttX";
  char *iconName = "NX";
  XTextProperty winprop;
  XTextProperty iconprop;
  XSizeHints hints;

  g_display = XOpenDisplay(NULL);
  if (g_display == NULL)
    {
      printf("Unable to open display.\n");
      return -1;
    }

  g_screen = DefaultScreen(g_display);
  g_window = XCreateSimpleWindow(g_display, DefaultRootWindow(g_display),
                                 0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
                                 BlackPixel(g_display, g_screen),
                                 BlackPixel(g_display, g_screen));

  XStringListToTextProperty(&winName, 1, &winprop);
  XStringListToTextProperty(&iconName, 1, &iconprop);

  hints.flags = PSize | PMinSize | PMaxSize;
  hints.width = hints.min_width  = hints.max_width  = g_fbpixelwidth;
  hints.height= hints.min_height = hints.max_height = g_fbpixelheight;

  XSetWMProperties(g_display, g_window, &winprop, &iconprop, argv, 1,
                   &hints, NULL, NULL);

  XMapWindow(g_display, g_window);

  /* Select window input events */

  XSelectInput(g_display, g_window,
               ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask);

  /* Release queued events on the display */

#ifdef CONFIG_SIM_TOUCHSCREEN
  (void)XAllowEvents(g_display, AsyncBoth, CurrentTime);

  /* Grab mouse button 1, enabling mouse-related events */

  (void)XGrabButton(g_display, Button1, AnyModifier, g_window, 1,
                    ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,
                    GrabModeAsync, GrabModeAsync, None, None);
#endif

  gcval.graphics_exposures = 0;
  g_gc = XCreateGC(g_display, g_window, GCGraphicsExposures, &gcval);

  return 0;
}
Exemple #14
0
int main(int argc, char * argv[]) {
    XEvent ev;
    int click_count = 0;
    long last_click_time = 0L;
    long cur_click_time = 0L;
    
    bool hook_enable = true;


    display = XOpenDisplay(NULL);
    if(display == NULL) {
        if(debug) printf("Could not open display\n");
        return 1;
    }
    root = DefaultRootWindow(display);
    
    // start hook
    XGrabButton(display, AnyButton, AnyModifier, root, true, ButtonPressMask | ButtonReleaseMask, GrabModeSync, GrabModeSync, None, None);
    signal(SIGINT, cleanup);

    while(1){
        XNextEvent(display, &ev);
        printf("hook_enable == %s\n", hook_enable ? "ENABLED" : "DISABLED");
        switch(ev.type){
            case ButtonPress:
            case ButtonRelease:
            // 1448x1072
                if(ev.type == ButtonPress && ev.xbutton.x > 950 && ev.xbutton.y > 1350){
                    cur_click_time = time(NULL);
                    if(cur_click_time - last_click_time >= click_triger_timeout){
                        last_click_time = cur_click_time;
                        click_count = 1;
                    }
                    else{
                        ++click_count;
                    }
                    
                    if(click_count >= 3){
                        click_count = 0;
                        hook_enable = !hook_enable;
                        printf("tiger hook to %s\n", hook_enable ? "ENABLED" : "DISABLED");
                        ignore_button(display, ev);
                    }
                }
                
                if(hook_enable && process_event(display, ev)){
                   continue; 
                }
            break;
        }
        passthru_button(display, ev);
    }

    cleanup();
    return 0;
}
Exemple #15
0
void
xu_btn_grab(Window win, int mask, unsigned int btn)
{
	unsigned int	i;

	for (i = 0; i < nitems(ign_mods); i++)
		XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
		    False, BUTTONMASK, GrabModeAsync,
		    GrabModeSync, None, None);
}
Exemple #16
0
int main(void)
{
    Display * dpy;
    XWindowAttributes attr;
    XButtonEvent start;
    XEvent ev;

    if(!(dpy = XOpenDisplay(0x0))) return 1;

    XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask,
            DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
    XGrabButton(dpy, 1, Mod1Mask, DefaultRootWindow(dpy), True,
            ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
    XGrabButton(dpy, 3, Mod1Mask, DefaultRootWindow(dpy), True,
            ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);

    start.subwindow = None;
    for(;;)
    {
        XNextEvent(dpy, &ev);
        if(ev.type == KeyPress && ev.xkey.subwindow != None)
            XRaiseWindow(dpy, ev.xkey.subwindow);
        else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
        {
            XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
            start = ev.xbutton;
        }
        else if(ev.type == MotionNotify && start.subwindow != None)
        {
            int xdiff = ev.xbutton.x_root - start.x_root;
            int ydiff = ev.xbutton.y_root - start.y_root;
            XMoveResizeWindow(dpy, start.subwindow,
                attr.x + (start.button==1 ? xdiff : 0),
                attr.y + (start.button==1 ? ydiff : 0),
                MAX(1, attr.width + (start.button==3 ? xdiff : 0)),
                MAX(1, attr.height + (start.button==3 ? ydiff : 0)));
        }
        else if(ev.type == ButtonRelease)
            start.subwindow = None;
    }
}
Exemple #17
0
void grab_client_buttons(HSClient* client, bool focused) {
    update_numlockmask();
    XUngrabButton(g_display, AnyButton, AnyModifier, client->window);
    if (focused) {
        g_list_foreach(g_mouse_binds, (GFunc)grab_client_button, client);
    }
    unsigned int btns[] = { Button1, Button2, Button3 };
    for (int i = 0; i < LENGTH(btns); i++) {
        XGrabButton(g_display, btns[i], AnyModifier, client->window, False,
                    ButtonPressMask|ButtonReleaseMask, GrabModeSync,
                    GrabModeSync, None, None);
    }
}
Exemple #18
0
int main(void) {

    //create display
    if(!(display = XOpenDisplay(NULL)))
        return 1;

    screen = DefaultScreenOfDisplay(display);
    printf("Screen: width=%d, height=%d\n", screen->width, screen->height);

    XGrabKey(display, XKeysymToKeycode(display, XStringToKeysym("F1")), Mod1Mask, DefaultRootWindow(display), True, GrabModeAsync, GrabModeAsync);
    XGrabButton(display, 1, Mod1Mask, DefaultRootWindow(display), True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
    XGrabButton(display, 3, Mod1Mask, DefaultRootWindow(display), True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);

    btnEvnt.subwindow = None;

    mainLoop();

    //Cleanup
    XCloseDisplay(display);

    return 0;
}
Exemple #19
0
void grab_button_full(guint button, guint state, Window win, guint mask,
                      gint pointer_mode, ObCursor cur)
{
    guint i;

    xerror_set_ignore(TRUE); /* can get BadAccess from these */
    xerror_occured = FALSE;
    for (i = 0; i < MASK_LIST_SIZE; ++i)
        XGrabButton(ob_display, button, state | mask_list[i], win, False, mask,
                    pointer_mode, GrabModeAsync, None, ob_cursor(cur));
    xerror_set_ignore(FALSE);
    if (xerror_occured)
        ob_debug("Failed to grab button %d modifiers %d\n", button, state);
}
Exemple #20
0
/*
 * Purpose:
 *	Setup the video display and windows required
 *
 * Parameters:
 * 	1st - general wayv data configuration
 * 	2nd - video display setup
 *
 * Returns:
 * 	GOOD on success
 * 	BAD on failure
 *
 * History:
 *	04/03/2001 (Mike Bennett): Updated for input box
 *	22/03/2001 (Mike Bennett): Moved into display.c and renamed
 *	16/04/2001 (Mike Bennett): Added else check for input windows
*/
int setupPointer(WSETUP *wayv, GDISPLAY *video) {
	Window win;

//	XAllowEvents(video->display, AsyncBoth, CurrentTime);

	if(wayv->pretty->display[0] != 'i')
		win = DefaultRootWindow(video->display);
	else
		win = video->window;

	XGrabButton(video->display, wayv->launch->pbutton,
		wayv->launch->kmodifier, win, False,
		ButtonMotionMask | ButtonPressMask | ButtonReleaseMask,
		GrabModeAsync, GrabModeAsync, None, None);

	/* We don't want Caps Lock interfering */
	XGrabButton(video->display, wayv->launch->pbutton,
		wayv->launch->kmodifier | KMODLOCK, win, False,
		ButtonMotionMask | ButtonPressMask | ButtonReleaseMask,
		GrabModeAsync, GrabModeAsync, None, None);

	return GOOD;
}
Exemple #21
0
void grab_zoom_button(X11Data* x11data)
{
    unsigned int    button          = Button1;
    unsigned int    modifiers       = ControlMask;
    Window          grab_window     = DefaultRootWindow(x11data->display);
    /* Window          grab_window     =  x11data.window; */
    Bool            owner_events    = False;
    int             event_mask      = ButtonPressMask;
    int             pointer_mode    = GrabModeAsync;
    int             keyboard_mode   = GrabModeAsync;
    Window          confine_to      = None;
    Cursor          cursor          = None;

    XGrabButton(x11data->display, button, modifiers, grab_window, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor);
}
Exemple #22
0
void Client::deactivate()	// called from wm?
{
//    fprintf(stderr, 
//	    "Client::deactivate (this = %p, window = %x, parent = %x)\n",
//	    this, m_window, parent());

    if (parent() == root()) {
	fprintf(stderr, "wm2: warning: bad parent in Client::deactivate\n");
	return;
    }

    XGrabButton(display(), AnyButton, AnyModifier, parent(), False,
		ButtonPressMask | ButtonReleaseMask,
		GrabModeAsync, GrabModeSync, None, None);

    decorate(False);
}
Exemple #23
0
void
wHackedGrabButton(unsigned int button, unsigned int modifiers,
		  Window grab_window, Bool owner_events,
		  unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor)
{
	XGrabButton(dpy, button, modifiers, grab_window, owner_events,
		    event_mask, pointer_mode, keyboard_mode, confine_to, cursor);

	if (modifiers == AnyModifier)
		return;

	XGrabButton(dpy, button, modifiers | LockMask, grab_window, owner_events,
		    event_mask, pointer_mode, keyboard_mode, confine_to, cursor);

#ifdef NUMLOCK_HACK
	/* same as above, but for mouse buttons */
	if (_NumLockMask)
		XGrabButton(dpy, button, modifiers | _NumLockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
	if (_ScrollLockMask)
		XGrabButton(dpy, button, modifiers | _ScrollLockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
	if (_NumLockMask && _ScrollLockMask)
		XGrabButton(dpy, button, modifiers | _ScrollLockMask | _NumLockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
	if (_NumLockMask)
		XGrabButton(dpy, button, modifiers | _NumLockMask | LockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
	if (_ScrollLockMask)
		XGrabButton(dpy, button, modifiers | _ScrollLockMask | LockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
	if (_NumLockMask && _ScrollLockMask)
		XGrabButton(dpy, button, modifiers | _ScrollLockMask | _NumLockMask | LockMask,
			    grab_window, owner_events, event_mask, pointer_mode,
			    keyboard_mode, confine_to, cursor);
#endif				/* NUMLOCK_HACK */
}
Exemple #24
0
void grab_button(int is_grab)
{
    Window rw = RootWindow(main_window->display, DefaultScreen(main_window->display));
    int status;
    if (is_grab)
    {
        status = XGrabButton(main_window->display, Button1, AnyModifier, rw, FALSE, ButtonPressMask|ButtonReleaseMask, GrabModeSync, GrabModeAsync, None, None);
        XSync (main_window->display, FALSE);
    }
    else
        status = XUngrabButton(main_window->display, AnyButton, AnyModifier, rw);

    if (status == BadCursor)
        log_message(ERROR, _("Failed to %s mouse with error BadCursor"), grab_ungrab[is_grab]);
    else if (status == BadValue)
        log_message(ERROR, _("Failed to %s mouse with error BadValue"), grab_ungrab[is_grab]);
    else if (status == BadWindow)
        log_message(ERROR, _("Failed to %s mouse with error BadWindow"), grab_ungrab[is_grab]);
}
Exemple #25
0
void
run(void) {
	for(int scr=0;scr < ScreenCount(dpy); scr++) {
		XUngrabButton(dpy, AnyButton, AnyModifier, RootWindow (dpy, scr));
	}

	for(int scr=0;scr < ScreenCount(dpy); scr++) {
		XGrabButton(dpy, button, AnyModifier, RootWindow(dpy, scr),
				False, ButtonPressMask | ButtonReleaseMask,
				GrabModeAsync, GrabModeAsync, None, None);
	}

	for(;;) {
		XEvent ev;
		XNextEvent(dpy, &ev);
		if(ev.xbutton.button == button && ev.xbutton.type == btype) {
			spawn();
		}
	}
}
Exemple #26
0
void eMapRequest(XEvent *event) {
  fprintf(stderr, "Got a map request\n");
  Node *newNode = allocateNode();
  newNode -> window = event -> xmaprequest.window;

  /* For Click to Focus */
  XGrabButton(display, AnyButton, AnyModifier, newNode -> window,
      True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeSync,
      None, None);

  //Containerize and move the viewNode
  if (focusedNode == viewNode) {
    fprintf(stderr, "Focused node is equal to the viewnode\n");
    containerize();
    viewNode = viewNode -> parent ? viewNode -> parent : viewNode;

    //This is the case in which we reparented the root node
    if (focusedNode == rootNode) { rootNode = viewNode; }

    //Brother the new node and rerender
    brotherNode(newNode, viewNode -> child, 1);
    placeNode(viewNode,  rootX, rootY, rootWidth, rootHeight);
  } else if (focusedNode && focusedNode -> parent) {
    brotherNode(newNode, focusedNode, 1);
    placeNode(focusedNode,
        focusedNode -> parent -> x, focusedNode -> parent -> y,
        focusedNode -> parent -> width, focusedNode -> parent -> height);
  } else {
    //No focus node, fist element created
    fprintf(stderr, "FIRST NODE YO\n");

    parentNode(newNode, viewNode);
  }

  fprintf(stderr, "\n\nAFTA\n\n");

  addLookupEntry(newNode, &newNode -> window);
  fprintf(stderr, "added the lookup entry\n");
  focusNode(newNode, NULL, True, True);
  fprintf(stderr, "done with the map request\n");
}
Exemple #27
0
void Gesture::grab_mouse( bool grab_P )
{
    kDebug() << grab_P;

    if( grab_P )
    {
        kDebug() << "gesture grab";
        Q_ASSERT( button != 0 );
        KXErrorHandler handler;
        static int mask[] = { 0, Button1MotionMask, Button2MotionMask, Button3MotionMask,
                              Button4MotionMask, Button5MotionMask, ButtonMotionMask, ButtonMotionMask,
                              ButtonMotionMask, ButtonMotionMask
                            };
#define XCapL KKeyServer::modXLock()
#define XNumL KKeyServer::modXNumLock()
#define XScrL KKeyServer::modXScrollLock()
        unsigned int mods[ 8 ] =
        {
            0, XCapL, XNumL, XNumL | XCapL,
            XScrL, XScrL | XCapL,
            XScrL | XNumL, XScrL | XNumL | XCapL
        };
#undef XCapL
#undef XNumL
#undef XScrL
        for( int i = 0;
                i < 8;
                ++i )
            XGrabButton( QX11Info::display(), button, mods[ i ], QX11Info::appRootWindow(), False,
                         ButtonPressMask | ButtonReleaseMask | mask[ button ], GrabModeAsync, GrabModeAsync,
                         None, None );
        bool err = handler.error( true );
        kDebug() << "Gesture grab:" << err;
    }
    else
    {
        kDebug() << "Gesture ungrab";
        XUngrabButton( QX11Info::display(), button, AnyModifier, QX11Info::appRootWindow());
    }
}
Exemple #28
0
/*
 *	MakeGrab
 */
static void  MakeGrab(
    XtServerGrabPtr	grab,
    XtServerGrabPtr	*passiveListPtr,
    Boolean		isKeyboard,
    XtPerDisplayInput	pdi,
    XtPerWidgetInput	pwi)
{
    if (!isKeyboard && !pwi->active_handler_added) {
	XtAddEventHandler(grab->widget, ButtonReleaseMask, FALSE,
			  ActiveHandler, (XtPointer)pdi);
	pwi->active_handler_added = TRUE;
    }

    if (isKeyboard) {
	XGrabKey(pDisplay(grab),
		 grab->keybut, grab->modifiers,
		 pWindow(grab), grab->ownerEvents,
		 grab->pointerMode, grab->keyboardMode);
    } else {
	Window confineTo = None;
	Cursor cursor = None;

	if (grab->hasExt) {
	    if (grab->confineToIsWidgetWin)
		confineTo = XtWindow (grab->widget);
	    else
		confineTo = GRABEXT(grab)->confineTo;
	    cursor = GRABEXT(grab)->cursor;
	}
	XGrabButton(pDisplay(grab),
		    grab->keybut, grab->modifiers,
		    pWindow(grab), grab->ownerEvents, grab->eventMask,
		    grab->pointerMode, grab->keyboardMode,
		    confineTo, cursor);
    }

    /* Add the new grab entry to the passive key grab list */
    grab->next = *passiveListPtr;
    *passiveListPtr = grab;
}
Exemple #29
0
void	InitX(void)
{
	int	screen, dum;
	Pixmap	check;

	display = XOpenDisplay("");
	screen = DefaultScreen(display);
	cmap = DefaultColormap(display, screen);

	white = WhitePixel(display, screen);
	black = BlackPixel(display, screen);
	
	XGetGeometry(display, DefaultRootWindow(display),
		     &root, &dum, &dum, &width, &height, (unsigned int *)&dum, &depth);
	
	rootmap = XCreatePixmap(display, root, width, height, depth);
	cutmap = XCreatePixmap(display, root, width, height, depth);
	
	scratch = XCreateWindow(display, root, 0, 0, WINW, WINH, 0, depth,
			    InputOutput, CopyFromParent, 0, NULL);
	XSelectInput(display, scratch,
		     ExposureMask | KeyPressMask | PointerMotionMask |
		     ButtonPressMask | ButtonReleaseMask);
	XMapRaised(display, scratch);
	scratchmap = XCreatePixmap(display, root, WINW, WINH, depth);
	
	gc = XCreateGC(display, root, 0, 0);
	XSetSubwindowMode(display, gc, IncludeInferiors);
	
	shadow_gc = XCreateGC(display, root, 0, 0);
	XSetFillStyle(display, shadow_gc, FillStippled);
	check = XCreateBitmapFromData(display, root, check_bits, check_width, check_height);
	XSetStipple(display, shadow_gc, check);

	XGrabButton(display, Button1, Mod1Mask, DefaultRootWindow(display), False,
		    PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
		    GrabModeAsync, GrabModeAsync, DefaultRootWindow(display), None);
}
Exemple #30
0
compzillaWindow::compzillaWindow(Display *display, Window win, XWindowAttributes *attrs)
    : mAttr(*attrs),
      mDisplay(display),
      mWindow(win),
      mPixmap(None),
      mDamage(None),
      mLastEntered(None),
      mIsDestroyed(false),
      mIsRedirected(false),
      mIsResizePending(false)
{
    XSelectInput (display, win, (PropertyChangeMask | EnterWindowMask | FocusChangeMask));

#if HAVE_XSHAPE
    XShapeSelectInput (display, win, ShapeNotifyMask);
#endif

    // Get notified of global cursor changes.  
    // FIXME: This is not very useful, as X has no way of fetching the Cursor
    // for a given window.
    //XFixesSelectCursorInput (display, win, XFixesDisplayCursorNotifyMask);

    XGrabButton (display, AnyButton, AnyModifier, win, true, 
                 (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask),
                 GrabModeSync, GrabModeSync, None, None);

    /* 
     * Set up damage notification.  RawRectangles gives us smaller grain
     * changes, versus NonEmpty which seems to always include the entire
     * contents.
     */
    mDamage = XDamageCreate (mDisplay, mWindow, XDamageReportRawRectangles);

    if (mAttr.map_state == IsViewable) {
        mAttr.map_state = IsUnmapped;
        Mapped (mAttr.override_redirect);
    }
}