static void MultiActivate( Widget wid, XEvent *buttonEvent, String *params, Cardinal *num_params) { /* When a multi click sequence occurs and the user Button Presses and * holds for a length of time, the final release should look like a * new/separate activate. */ XmArrowButtonWidget aw = (XmArrowButtonWidget) wid; if (aw->arrowbutton.multiClick == XmMULTICLICK_KEEP) { if ((buttonEvent->xbutton.time - aw->arrowbutton.armTimeStamp) > XtGetMultiClickTime(XtDisplay(aw))) aw->arrowbutton.click_count = 1; else aw->arrowbutton.click_count++; ActivateCommon((Widget) aw, buttonEvent); Disarm ((Widget) aw, buttonEvent, params, num_params); } }
static void BtnPress(Widget w, XtPointer closure, XEvent *event, Boolean *ctd) { XmLTreeWidget t; XmLTreeRow rowp; unsigned char rowType, colType; int row, col, x1, y1, x2, y2, xoff; XRectangle rect; XButtonEvent *be; static int lastRow = -1; static Time lastSelectTime = 0; t = (XmLTreeWidget)w; if (event->type != ButtonPress) return; be = (XButtonEvent *)event; if (be->button != Button1 || be->state & ControlMask || be->state & ShiftMask) return; if (XmLGridXYToRowColumn(w, be->x, be->y, &rowType, &row, &colType, &col) == -1) return; rowp = (XmLTreeRow)XmLGridGetRow(w, XmCONTENT, row); if (rowType != XmCONTENT || colType != XmCONTENT || col != 0) return; if (XmLGridRowColumnToXY(w, rowType, row, colType, col, False, &rect) == -1) return; if ((be->time - lastSelectTime) < XtGetMultiClickTime(XtDisplay(w)) && lastRow == row) { /* activate callback will be handling expand/collapse */ lastSelectTime = be->time; return; } lastSelectTime = be->time; lastRow = row; xoff = t->tree.levelSpacing; x1 = rect.x + (rowp->tree.level - 1) * xoff * 2 + xoff - 6; x2 = x1 + 13; y1 = rect.y + rect.height / 2 - 6; y2 = y1 + 13; if (be->x > x2 || be->x < x1 || be->y > y2 || be->y < y1) return; SwitchRowState(t, row, event); }
static void MultiActivate(Widget w, XEvent *event, String *params, Cardinal *num_params) { XButtonEvent *ev = (XButtonEvent *)event; XmDrawnButtonCallbackStruct cbs; DEBUGOUT(_LtDebug(__FILE__, w, "DrawnB: MultiClick\n")); if (DB_MultiClick(w) == XmMULTICLICK_KEEP) { Time mctime = XtGetMultiClickTime(XtDisplay(w)); if ((event->xbutton.time - DB_ArmTimeStamp(w)) < mctime) { DB_ClickCount(w)++; } else { DB_ClickCount(w) = 1; } DB_Armed(w) = False; if (XtIsRealized(w)) XtClass(w)->core_class.expose(w, event, NULL); if (ev->type == KeyPress || ev->type == KeyRelease || ((ev->x >= 0 && ev->x < XtWidth(w)) && (ev->y >= 0 && ev->y < XtHeight(w)))) { if (!Lab_SkipCallback(w) && DB_ActivateCallback(w)) { cbs.reason = XmCR_ACTIVATE; cbs.event = event; cbs.click_count = DB_ClickCount(w); XFlush(XtDisplay(w)); XtCallCallbackList(w, DB_ActivateCallback(w), (XtPointer)&cbs); } } Disarm(w, event, params, num_params); } }
void activateCB_filetype_icon (Widget wid, XtPointer client_data, DtIconCallbackStruct *cbs) { Time lts, mct = 0; static Time prev_lts = 0; if (cbs->reason == XmCR_ACTIVATE) { #ifdef DEBUG printf("In activate_filetype_icon callback.\n"); #endif if (last_filetype_pushed && (last_filetype_pushed != wid)) { XtVaSetValues(XtParent(last_filetype_pushed), XmNborderWidth, 0, NULL); } XtVaSetValues(XtParent(wid), XmNborderWidth, ICON_BORDER_WIDTH, NULL); last_filetype_pushed = wid; /********************************************************************/ /* This is the support needed to provide double-click functionality */ /* to the icon gadgets. When double-clicked, the icon editor will */ /* be launched. */ /********************************************************************/ XtVaSetValues(wid, XmNpushButtonClickTime, 0, NULL); lts = XtLastTimestampProcessed(XtDisplay(wid)); mct = XtGetMultiClickTime(XtDisplay(wid)); if ((prev_lts + mct) > lts) { prev_lts = XtLastTimestampProcessed(XtDisplay(wid)); } else { prev_lts = XtLastTimestampProcessed(XtDisplay(wid)); return; } #ifdef DEBUG printf("DblClick icon callback.\n"); #endif activateCB_edit_icon(wid, (XtPointer)CA_FILETYPE_ICONS, (XmPushButtonCallbackStruct *)cbs /* unused anyway */); } return; }
void iupmotCBbuttoncb (Widget w, XtPointer data, XEvent* event, Boolean* cont) { unsigned long elapsed; static Time last = 0; static char report[12]; Ihandle* n = (Ihandle*)data; IFniiiis cb = (IFniiiis) IupGetCallback(n, IUP_BUTTON_CB); XButtonEvent* ev = (XButtonEvent*)event; if ( ev->button!=Button1 && ev->button!=Button2 && ev->button!=Button3 ) return; if (ev->type == ButtonPress) XmProcessTraversal(w, XmTRAVERSE_CURRENT); if (cb) { int b = (ev->button==Button1) ? '1' : ((ev->button==Button2) ? '2' : '3' ); makeStateString(ev->state, ev->button, report); /* Double/Single Click */ if (ev->type == ButtonPress) { elapsed = ev->time - last; last = ev->time; if (elapsed <= XtGetMultiClickTime(iupmot_display)) strcat(report,"D"); /* Double_click */ else strcat(report,"S"); /* Single_click */ } iupmot_incallback = TRUE; if ( cb (n, b, (ev->type==ButtonPress), ev->x_root, ev->y_root, report)==IUP_CLOSE) iupmot_exitmainloop = 1; iupmot_incallback = FALSE; } }
static void BtnUp (Widget w, XEvent *event, String *params, Cardinal *num_params) { XmGrabShellWidget grabshell = (XmGrabShellWidget) w; int delta; /* Handle click to post we then ignore the event if it occured within the click to post time */ delta = event -> xbutton.time - grabshell -> grab_shell.post_time; if (delta <= XtGetMultiClickTime(XtDisplay(w))) { GSAllowEvents(w, SyncPointer, event -> xbutton.time); return; } Popdown(w, event, params, num_params); }
void iupmotButtonPressReleaseEvent(Widget w, Ihandle* ih, XEvent* evt, Boolean* cont) { unsigned long elapsed; static Time last = 0; char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT; IFniiiis cb; XButtonEvent *but_evt = (XButtonEvent*)evt; if (but_evt->button!=Button1 && but_evt->button!=Button2 && but_evt->button!=Button3 && but_evt->button!=Button4 && but_evt->button!=Button5) return; cb = (IFniiiis) IupGetCallback(ih,"BUTTON_CB"); if (cb) { int ret, doubleclick = 0; int b = IUP_BUTTON1+(but_evt->button-1); /* Double/Single Click */ if (but_evt->type==ButtonPress) { elapsed = but_evt->time - last; last = but_evt->time; if ((int)elapsed <= XtGetMultiClickTime(iupmot_display)) doubleclick = 1; } iupmotButtonKeySetStatus(but_evt->state, but_evt->button, status, doubleclick); ret = cb(ih, b, (but_evt->type==ButtonPress), but_evt->x, but_evt->y, status); if (ret==IUP_CLOSE) IupExitLoop(); else if (ret==IUP_IGNORE) *cont=False; } (void)w; }
long int GetMultiClickTime() { long int value = 200; int clicktime; bool successful = false; // Try and acquire the multi-click time from the user defined X defaults. char *xprop = XGetDefault(disp, "*", "multiClickTime"); if (xprop != NULL && sscanf(xprop, "%4i", &clicktime) != EOF) { successful = true; } xprop = XGetDefault(disp, "OpenWindows", "MultiClickTimeout"); if (xprop != NULL && sscanf(xprop, "%4i", &clicktime) != EOF) { successful = true; } #ifdef XT int argc = 0; char ** argv = {NULL}; // Fall back to the X Toolkit extension if available and other efforts failed. XtDisplayInitialize(app_context, disp, "JNativeHook", "JNativeHook", NULL, 0, &argc, argv); if (!successful) { clicktime = XtGetMultiClickTime(disp); if (clicktime >= 0) { successful = true; } } #endif if (successful) { value = clicktime; } return value; }