示例#1
0
void WMDragImageFromView(WMView * view, XEvent * event)
{
	WMDraggingInfo *info = &W_VIEW_SCREEN(view)->dragInfo;
	WMPoint mouseLocation;

	switch (event->type) {
	case ButtonPress:
		if (event->xbutton.button == Button1) {
			XEvent nextEvent;

			XPeekEvent(event->xbutton.display, &nextEvent);

			/* Initialize only if a drag really begins (avoid clicks) */
			if (nextEvent.type == MotionNotify) {
				initSourceDragInfo(view, info);
			}
		}

		break;

	case ButtonRelease:
		if (WMIsDraggingFromView(view)) {
			Bool dropBegan = processButtonRelease(info);

			recolorCursor(info, False);
			if (dropBegan) {
				endDragImage(info, False);
				XDND_SOURCE_STATE(info) = finishDropState;
			} else {
				/* drop failed */
				endDragImage(info, True);
				endDragProcess(info, False);
			}
		}
		break;

	case MotionNotify:
		if (WMIsDraggingFromView(view)) {
			mouseLocation = wmkpoint(event->xmotion.x_root, event->xmotion.y_root);

			if (abs(XDND_DRAG_ICON_POS(info).x - mouseLocation.x) >=
			    MIN_X_MOVE_OFFSET
			    || abs(XDND_DRAG_ICON_POS(info).y - mouseLocation.y) >= MIN_Y_MOVE_OFFSET) {
				if (XDND_DRAG_ICON(info) == None) {
					initMotionProcess(view, info, event, &mouseLocation);
					startDragImage(view, info, event);
				} else {
					XDND_DRAG_ICON_POS(info).x = mouseLocation.x - XDND_MOUSE_OFFSET(info).x;
					XDND_DRAG_ICON_POS(info).y = mouseLocation.y - XDND_MOUSE_OFFSET(info).y;

					refreshDragImage(view, info);
					processMotion(info, &mouseLocation);
				}
			}
		}
		break;
	}
}
示例#2
0
文件: WMAddOns.c 项目: roblillack/mmp
void W_MaskedEventHandler(XEvent *event, void *data) {
  W_MaskedEvents *events = (W_MaskedEvents*)data;
  WMEventProc *proc = NULL;
  unsigned int i;
  
  for (i = 0; i < WMGetArrayItemCount(events->procs); i++) {
    if (WMIsDraggingFromView(events->view) == False) {
      proc = WMGetFromArray(events->procs, i);
      (*proc)(event, WMGetFromArray(events->data, i));
    } else {
      /* *cough* evil *cough* hack... */
      if (W_CLASS(events->view->self) == WC_List) {
        ((W_List*)(events->view->self))->flags.buttonWasPressed = 0;
        ((W_List*)(events->view->self))->flags.buttonPressed = 0;
      }
    }
  }
}