Widget get_shell_focused_widget(Widget w) { while (w != NULL && !XtIsShell(w)) { w = XtParent(w); } if (w != NULL) { return XmGetFocusWidget(w); } else { return NULL; } }
static void edit_find_cancel_callback(Widget w, XtPointer context, XtPointer info) { if (XmGetFocusWidget(edit_find_dialog) == XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_OK_BUTTON)) { if (ss->checking_explicitly) ss->stopped_explicitly = true; else { XtUnmanageChild(edit_find_dialog); clear_find_error(); } } else edit_find_next_callback(w, context, info); }
/* * Class: java_awt_KeyboardFocusManager * Method: clearGlobalFocusOwner * Signature: ()V */ JNIEXPORT void JNICALL Java_java_awt_KeyboardFocusManager__1clearGlobalFocusOwner (JNIEnv *env, jobject self) { /* Redirect focus to the focus proxy of the active Window. The effect we want is for the active Window to remain active, but for none of its children to be the focus owner. AWT maintains state to know that any key events delivered after this call (but before focus is re-established elsewhere) get ignored. */ jobject activeWindow; Widget proxy; if ((*env)->EnsureLocalCapacity(env, 1) < 0) { return; } AWT_LOCK(); activeWindow = (*env)->CallStaticObjectMethod (env, keyboardFocusManagerIDs.keyboardFocusManagerCls, keyboardFocusManagerIDs.markClearGlobalFocusOwnerMID); if (activeWindow != NULL) { // Setting focus owner to proxy will be equivalent haveing // null focus owner in Java layer while we will still be // able to receive key events. proxy = findWindowsProxy(activeWindow, env); if (proxy != NULL) { Widget curFocusWidget = XmGetFocusWidget(proxy); if (curFocusWidget != NULL) { callFocusHandler(curFocusWidget, FocusOut); } // Disable all but proxy widgets processTree(curFocusWidget, proxy, False); XmProcessTraversal(proxy, XmTRAVERSE_CURRENT); } } AWT_UNLOCK(); }
int XFE_ComposeAttachFolderView::addAttachments(const char **items,int numItems,int pre_existing,Boolean attach_binary) { // lock out addition of existing attachments after first time through _addedExistingAttachments=TRUE; // abort if attachment adding or delivery is in progress // (and not adding pre_exisiting attachments) if (!pre_existing && !verifySafeToAttach()) return FALSE; if (!items || numItems==0) return FALSE; int addStatus=FALSE; // desired type is NULL == as-is (used to read from format toggle buttons.) char *desiredType=NULL; // if an icon has focus, restore it when we remap the pane Widget focusWidget=XmGetFocusWidget(getBaseWidget()); if (focusWidget && XtParent(focusWidget)!=_attachPanel->pane()) focusWidget=NULL; _attachPanel->unmapPane(); for (int i=0;i<numItems;i++) { // is there space in the list? if (_numAttachments>=_maxAttachments) { char *msg=PR_smprintf(XP_GetString(XFE_MN_TOO_MANY_ATTACHMENTS)); if (msg) { fe_Alert_2(getBaseWidget(),msg); XP_FREE(msg); } break; } // is the item already attached? int duplicate=FALSE; for (int j=0;j<_numAttachments;j++) { if (strcmp(items[i],_attachments[j].url)==0) { char *msg=PR_smprintf(XP_GetString(XFE_MN_ITEM_ALREADY_ATTACHED),items[i]); if (msg) { fe_Alert_2(getBaseWidget(),msg); XP_FREE(msg); } duplicate=TRUE; break; } } if (duplicate) continue; // nyi - hack "addbook:add?vcard=" URL to be vcard data, and accept as attachment // (then turn back on dragging of addbook:add URL's in XFE_HTMLDrag) // WinFE does this already. // is it a valid attachment? if ((!pre_existing) && (!validateAttachment(getBaseWidget(),items[i]))) continue; // at least one attachment was accepted, return success status addStatus=TRUE; // add to internal attachment list struct MSG_AttachmentData m = { 0 }; m.url=XP_STRDUP(items[i]); m.desired_type=desiredType; if (attach_binary) m.real_type= "application/octet-stream"; else if (IsWebJumper(m.url)) m.real_type= "text/webjumper"; else m.real_type=NULL; _attachments[_numAttachments]=m; _numAttachments++; char *itemLabel=parseItemLabel(items[i]); // add icon to attachment panel _attachPanel->addItem(items[i],itemLabel); XP_FREE(itemLabel); } // always select last-added item if (addStatus && _attachPanel->numItems()>0) { _attachPanel->selectItem(_attachPanel->items()[_attachPanel->numItems()-1]); if (!pre_existing) { focusWidget=_attachPanel->items()[_attachPanel->numItems()-1]->image(); } } // update attachment panel _attachPanel->updateDisplay(); _attachPanel->mapPane(); // restore focus if we had it before the unmapPane() if (focusWidget) XmProcessTraversal(focusWidget,XmTRAVERSE_CURRENT); // update internal attachment list, if not adding pre-exisiting attachments if (addStatus && !pre_existing) updateAttachments(); // pop attachment folder to top, if not adding pre-exisiting attachments if (!pre_existing) { getParent()->doCommand(xfeCmdViewAttachments); } return addStatus; }