1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990, 1992 HEWLETT-PACKARD COMPANY
- * ALL RIGHTS RESERVED
- */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include "WmResNames.h"
- #include "WmHelp.h"
- #include "WmError.h"
- #include <X11/Core.h>
- #include <X11/StringDefs.h>
- #include <X11/Intrinsic.h>
- #include <X11/Xatom.h>
- #include <X11/Shell.h>
- #include <Xm/Xm.h>
- #include <Xm/Form.h>
- #include <Xm/PushBG.h>
- #include <Xm/PushB.h>
- #include <Xm/LabelG.h>
- #include <Xm/List.h>
- #include <Xm/SeparatoG.h>
- #include <Xm/ToggleB.h>
- #include <errno.h>
- #include <signal.h>
- #include <stdio.h>
- /*
- * Function Declarations:
- */
- #include "WmPresence.h"
- /******** Static Function Declarations ********/
- static void wspSetWindowName(
- PtrWsPresenceData pPres) ;
- static Boolean wspCreateWidgets(
- WmScreenData *pSD) ;
- static Widget wspCreateShell(
- WmScreenData *pSD) ;
- static Widget wspCreateManager(
- Widget shellW) ;
- static Widget wspCreateLabel(
- Widget mgrW,
- unsigned char *pchName,
- unsigned char *pchString) ;
- static Widget wspCreateSeparator(
- Widget mgrW) ;
- static Widget wspCreateWorkspaceList(
- Widget mgrW,
- PtrWsPresenceData pPres,
- WmScreenData *pSD) ;
- static void wspUpdateWorkspaceList(
- PtrWsPresenceData pPres) ;
- static Widget wspCreateToggleButton(
- Widget mgrW,
- unsigned char *pch) ;
- static Widget wspCreatePushButton(
- Widget mgrW,
- char *name,
- XmString label) ;
- static void wspSetPosition(
- PtrWsPresenceData pPres) ;
- static void wspLayout(
- PtrWsPresenceData pPres) ;
- static void wspOkCB(
- Widget buttonW,
- WmScreenData *pSD,
- XtPointer call_data) ;
- static void wspHelpCB(
- Widget buttonW,
- XtPointer client_data,
- XtPointer call_data) ;
- static void wspAllWsCB(
- Widget buttonW,
- WmScreenData *pSD,
- XmToggleButtonCallbackStruct *xmTbcs) ;
- static void wspCancelCB(
- Widget buttonW,
- XtPointer client_data,
- XtPointer call_data) ;
- static void wspExtendedSelectCB(
- Widget w,
- XtPointer client_data,
- XmListCallbackStruct *cb );
- static Dimension wspCharWidth (
- XmFontList xmfl);
- /******** End Static Function Declarations ********/
- /*
- * External references
- */
- #include "WmCDecor.h"
- #include "WmCDInfo.h"
- #include "WmIconBox.h"
- #include "WmPanelP.h" /* for typedef in WmManage.h */
- #include "WmManage.h"
- #include "WmResParse.h"
- #include "WmResource.h"
- #include "WmWinInfo.h"
- #include "WmWrkspace.h"
- /*
- * Global Variables:
- */
- /*
- * These two XmStrings are used in the workspace
- * presence box to indicate the name of the current
- * window for whice the presence box is active. If the
- * window is iconified, the title will be "Icon: <iconName>",
- * otherwise the title wil be "Window: <windowName>
- */
- XmString windowLabelString = (XmString)NULL;
- XmString iconLabelString = (XmString)NULL;
- /*************************************<->*************************************
- *
- * Boolean
- * MakePresenceBox (pSD)
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- *
- *
- * Outputs:
- * -------
- * Return = (Boolean) True if successful
- *
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- Boolean
- MakePresenceBox(
- WmScreenData *pSD )
- {
- PtrWsPresenceData pPres = &pSD->presence;
- Boolean rval;
- /*
- * Create the widgets for the workspace presence dialog
- */
- pPres->onScreen = False;
- if (wspCreateWidgets (pSD))
- {
- /*
- * lay out the form
- */
- wspLayout (pPres);
- /*
- * Set the ClientData fields.
- */
- XtRealizeWidget (pPres->shellW);
- DtWsmRemoveWorkspaceFunctions (DISPLAY1, XtWindow(pPres->shellW));
- ProcessPresenceResources (pSD);
- rval = True;
- }
- else
- {
- Warning(((char *)GETMESSAGE(52, 1, "Unable to create Occupy Workspace dialog.")));
- rval = False;
- }
- return (rval);
- } /* END OF FUNCTION MakePresenceBox */
- /*************************************<->*************************************
- *
- * void
- * ShowPresenceBox (pClient, wsContext)
- *
- *
- * Description:
- * -----------
- * Pops up (shows) the workspace presence dialog
- *
- * Inputs:
- * ------
- * pClient = pointer to client data which needs a presence dialog
- * up. (This is not the presence dialog's client data!!!)
- *
- * wsContext = context to post dialog for
- *
- *
- * Outputs:
- * -------
- * Return = none
- *
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- void
- ShowPresenceBox(
- ClientData *pClient,
- Context wsContext )
- {
- PtrWsPresenceData pPres;
- WmScreenData *pSD;
- pPres = &pClient->pSD->presence;
- pSD = pClient->pSD;
- pPres->pCDforClient = pClient;
- pPres->contextForClient = wsContext;
- /*
- * Create the presence dialog if not done yet.
- */
- if (!pSD->presence.shellW)
- {
- pPres->ItemSelected = NULL;
- pPres->ItemStrings = NULL;
- pPres->currentWsItem = 0;
- MakePresenceBox (pSD);
- }
- if (pPres->onScreen)
- {
- HidePresenceBox (pSD, True);
- }
- /* update workspace list */
- wspUpdateWorkspaceList (pPres);
- /* set position of dialog relative to client window */
- wspSetPosition (pPres);
- /*
- * pop it up
- */
- XtPopup (pPres->shellW, XtGrabNone);
- pPres->onScreen = True;
- } /* END OF FUNCTION ShowPresenceBox */
- /*************************************<->*************************************
- *
- * static void
- * wspSetWindowName (pPres)
- *
- *
- * Description:
- * -----------
- * Sets the name of the current window in the presence dialog
- *
- * Inputs:
- * ------
- * pPres = ptr to workspace presence dialog data
- *
- * Outputs:
- * -------
- * Return = none
- *
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- static void
- wspSetWindowName(
- PtrWsPresenceData pPres )
- {
- int nameN, labelN;
- Arg nameArgs[1];
- Arg labelArgs[1];
- /*
- * Set the name of the current window
- */
- nameN = 0;
- labelN = 0;
- if (pPres->contextForClient == F_CONTEXT_ICON)
- {
- XtSetArg (nameArgs[nameN], XmNlabelString,
- pPres->pCDforClient->iconTitle); nameN++;
- XtSetArg (labelArgs[labelN], XmNlabelString,
- iconLabelString); labelN++;
- }
- else
- {
- XtSetArg (nameArgs[nameN], XmNlabelString,
- pPres->pCDforClient->clientTitle); nameN++;
- XtSetArg (labelArgs[labelN], XmNlabelString,
- windowLabelString); labelN++;
- }
- XtSetValues (pPres->windowNameW, nameArgs, nameN);
- XtSetValues (pPres->windowLabelW, labelArgs, labelN);
- } /* END OF FUNCTION wspSetWindowName */
- /*************************************<->*************************************
- *
- * void
- * HidePresenceBox (pSD, userDismissed)
- *
- *
- * Description:
- * -----------
- * Pops down (hides) the workspace presence dialog
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- * userDismissed = did the user dismiss or did workspace switching
- * unpost the workspace presence box ?
- *
- * Outputs:
- * -------
- * Return = none
- *
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- void
- HidePresenceBox(
- WmScreenData *pSD,
- Boolean userDismissed )
- {
- if (pSD->presence.onScreen)
- {
- /* Pop down the shell */
- XtPopdown (pSD->presence.shellW);
- /*
- * Do a withdraw to make sure window gets unmanaged
- * (popdown does nothing if its unmapped)
- */
- XWithdrawWindow (DISPLAY, XtWindow (pSD->presence.shellW),
- pSD->screen);
- /* must sync to insure event order */
- XSync (DISPLAY, False);
- pSD->presence.onScreen = False;
- pSD->presence.userDismissed = userDismissed;
- }
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspCreateWidgets (pSD)
- *
- *
- * Description:
- * -----------
- * Creates all the widgets for the workspace presence dialog box
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- *
- * Outputs:
- * -------
- * Return = false on any failure
- *
- * Comments:
- * ---------
- * Only creates widgets
- ******************************<->***********************************/
- static Boolean
- wspCreateWidgets(
- WmScreenData *pSD )
- {
- PtrWsPresenceData pPres = &pSD->presence;
- Arg args [5];
- int n;
- Boolean rval /* = True */;
- #ifdef NO_MESSAGE_CATALOG
- XmString tmpXmString;
- #endif /* NO_MESSAGE_CATALOG */
- rval = ((pPres->shellW = wspCreateShell (pSD)) != NULL);
- if (rval)
- {
- rval = ((pPres->formW = wspCreateManager (pPres->shellW)) != NULL);
- }
- if (rval)
- {
- rval = ((pPres->windowLabelW = wspCreateLabel (pPres->formW,
- (unsigned char *)"window",
- NULL)) != NULL);
- }
- if (rval)
- {
- rval = ((pPres->windowNameW = wspCreateLabel (pPres->formW,
- (unsigned char *)"windowName",
- (unsigned char *)" ")) != NULL);
- }
- if (rval)
- {
- rval = ((pPres->workspaceLabelW =
- wspCreateLabel (pPres->formW, (unsigned char *)"workspaces",
- ((unsigned char *)GETMESSAGE(52, 3, "Workspaces: ")))) != NULL);
- }
- if (rval)
- {
- rval = ((pPres->workspaceListW =
- wspCreateWorkspaceList (pPres->formW, pPres, pSD)) != NULL);
- pPres->workspaceScrolledListW = XtParent (pPres->workspaceListW);
- }
- if (rval)
- {
- rval = ((pPres->allWsW = wspCreateToggleButton (pPres->formW,
- ((unsigned char *)GETMESSAGE(52, 4, "All Workspaces"))))
- != NULL);
- XtAddCallback (pPres->allWsW, XmNvalueChangedCallback,
- (XtCallbackProc)wspAllWsCB, (XtPointer)pSD);
- }
- if (rval)
- {
- rval = ((pPres->sepW = wspCreateSeparator (pPres->formW)) != NULL);
- }
- if (rval)
- {
- #ifndef NO_MESSAGE_CATALOG
- rval = ((pPres->OkW =
- wspCreatePushButton (pPres->formW, "ok", wmGD.okLabel))
- != NULL);
- #else
- tmpXmString = XmStringCreateLocalized ("OK");
- rval = ((pPres->OkW =
- wspCreatePushButton (pPres->formW, "ok", tmpXmString))
- != NULL);
- XmStringFree(tmpXmString);
- #endif
- /* set the default action */
- n = 0;
- XtSetArg (args[n], XmNdefaultButton, pPres->OkW); n++;
- XtSetValues (pPres->formW, args, n);
- XtAddCallback (pPres->OkW, XmNactivateCallback,
- (XtCallbackProc) wspOkCB, (XtPointer)pSD);
- }
- if (rval)
- {
- #ifndef NO_MESSAGE_CATALOG
- rval = ((pPres->CancelW = wspCreatePushButton (pPres->formW,
- "cancel", wmGD.cancelLabel)) != NULL);
- #else
- tmpXmString = XmStringCreateLocalized ("Cancel");
- rval = ((pPres->CancelW =
- wspCreatePushButton (pPres->formW, "cancel", tmpXmString))
- != NULL);
- XmStringFree(tmpXmString);
- #endif
- XtAddCallback (pPres->CancelW, XmNactivateCallback,
- (XtCallbackProc) wspCancelCB, (XtPointer)pSD);
- /* set the cancel button (for KCancel) */
- n = 0;
- XtSetArg (args[n], XmNcancelButton, pPres->CancelW); n++;
- XtSetValues (pPres->formW, args, n);
- }
- if (rval)
- {
- #ifndef NO_MESSAGE_CATALOG
- rval = ((pPres->HelpW =
- wspCreatePushButton (pPres->formW, "help", wmGD.helpLabel))
- != NULL);
- #else
- tmpXmString = XmStringCreateLocalized ("Help");
- rval = ((pPres->HelpW =
- wspCreatePushButton (pPres->formW, "help", tmpXmString))
- != NULL);
- XmStringFree(tmpXmString);
- #endif
- XtAddCallback (pPres->HelpW, XmNactivateCallback,
- WmDtWmTopicHelpCB,
- WM_DT_WSPRESENCE_TOPIC);
- }
- return(rval);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * Widget
- * wspCreateShell (pSD)
- *
- *
- * Description:
- * -----------
- * Creates the shell widget for the workspace presence dialog
- *
- *
- * Inputs:
- * ------
- * psD = pointer to screen data
- *
- * Outputs:
- * -------
- * Return = shell widget created
- *
- ******************************<->***********************************/
- static Widget
- wspCreateShell(
- WmScreenData *pSD )
- {
- Arg setArgs[20];
- int i;
- Widget shellW;
- /*
- * Create top level shell for workspace presence dialog
- */
- i=0;
- XtSetArg (setArgs[i], XmNallowShellResize, (XtArgVal)True); i++;
-
- XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal)0); i++;
- XtSetArg (setArgs[i], XmNkeyboardFocusPolicy,
- (XtArgVal)XmEXPLICIT); i++;
- XtSetArg (setArgs[i], XmNmappedWhenManaged,
- (XtArgVal)False); i++;
- XtSetArg (setArgs[i], XmNmwmFunctions,
- PRESENCE_BOX_FUNCTIONS); i++;
- XtSetArg (setArgs[i], XmNmwmDecorations,
- (MWM_DECOR_TITLE|MWM_DECOR_BORDER)); i++;
- XtSetArg (setArgs[i], XmNdepth,
- (XtArgVal) DefaultDepth (DISPLAY1, pSD->screen)); i++;
- XtSetArg (setArgs[i], XmNscreen, (XtArgVal)
- ScreenOfDisplay (DISPLAY1, pSD->screen)); i++;
- XtSetArg (setArgs[i], XtNcolormap,
- (XtArgVal )DefaultColormap(DISPLAY1, pSD->screen)); i++;
- shellW = (Widget) XtCreatePopupShell (WmNfeedback,
- transientShellWidgetClass,
- pSD->screenTopLevelW1,
- (ArgList)setArgs, i);
- return (shellW);
- } /* END OF FUNCTION wspCreateShell */
- /*************************************<->*************************************
- *
- * wspCreateManager (shellW)
- *
- *
- * Description:
- * -----------
- * Creates the manager widget for the workspace presence dialog
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- * Comments:
- * ---------
- * Creates a form widget
- ******************************<->***********************************/
- static Widget
- wspCreateManager(
- Widget shellW )
- {
- Arg setArgs[20];
- Widget formW;
- /* !!! set colors? !!! */
- formW = (Widget) XmCreateForm (shellW, "form", (ArgList) setArgs, 0);
- XtAddCallback (formW, XmNhelpCallback,
- WmDtWmTopicHelpCB, WM_DT_WSPRESENCE_TOPIC);
- XtManageChild (formW);
- return (formW);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspCreateLabel (mgrW, pchName, pchString)
- *
- *
- * Description:
- * -----------
- * Creates a label widget as a child of the passed in manager
- *
- * Inputs:
- * ------
- * mgrW = manager widget (parent of this label)
- * pchName = name of the widget
- * pchString = string that is to be in label
- *
- * Outputs:
- * -------
- * Return = Widget created.
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Widget
- wspCreateLabel(
- Widget mgrW,
- unsigned char *pchName,
- unsigned char *pchString )
- {
- Arg setArgs[20];
- int i;
- Widget labelW;
- XmString tmpXmString = (XmString)NULL;
- i = 0;
- if (!strcmp((char *)pchName, "window"))
- {
- if (windowLabelString != (XmString)NULL)
- XmStringFree(windowLabelString);
- if (iconLabelString != (XmString)NULL)
- XmStringFree(iconLabelString);
- windowLabelString =
- XmStringCreateLocalized ((char *)GETMESSAGE(52, 2, "Window: "));
- /*
- * If we do this, USE the message catalog for iconLabelString
- * just as we do for windowLabelString !!!
- */
- iconLabelString =
- XmStringCreateLocalized ((char *)GETMESSAGE(52, 6, "Icon: "));
- XtSetArg (setArgs[i], XmNlabelString, windowLabelString ); i++;
- }
- else
- {
- tmpXmString = XmStringCreateLocalized ((char *)pchString);
- XtSetArg (setArgs[i], XmNlabelString, tmpXmString); i++;
- }
-
- labelW = XmCreateLabelGadget (mgrW, (char *)pchName, setArgs, i);
- XtManageChild (labelW);
- if (tmpXmString != (XmString)NULL)
- XmStringFree(tmpXmString);
- return (labelW);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspCreateSeparator (mgrW)
- *
- *
- * Description:
- * -----------
- * Creates a separator widget as a child of the passed in manager
- *
- * Inputs:
- * ------
- * mgrW = manager widget (parent of this label)
- *
- * Outputs:
- * -------
- * Return = Widget created.
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Widget
- wspCreateSeparator(
- Widget mgrW )
- {
- Arg setArgs[10];
- int i;
- Widget sepW;
- i = 0;
- sepW = XmCreateSeparatorGadget (mgrW, "separator", setArgs, i);
- XtManageChild (sepW);
- return (sepW);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspCreateWorkspaceList (mgrW, pPres, pSD)
- *
- *
- * Description:
- * -----------
- * Creates a list widget containing all the workspaces defined for a
- * screen.
- *
- * Inputs:
- * ------
- * mgrW = manager widget (parent of this child)
- * pPres = pointer to presence data
- * pSD = ptr to screen data
- *
- * Outputs:
- * -------
- * Return = widget created.
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Widget
- wspCreateWorkspaceList(
- Widget mgrW,
- PtrWsPresenceData pPres,
- WmScreenData *pSD )
- {
- Arg setArgs[20];
- int i;
- Widget listW;
- int numVisible;
- #define MIN_VISIBLE 6
- /*
- * Create the array of strings that will go into the list.
- */
- if (((pPres->ItemStrings = (XmStringTable) XtMalloc
- (pSD->numWorkspaces * sizeof(XmString *))) == NULL) ||
- ((pPres->ItemSelected = (Boolean *) XtMalloc
- (pSD->numWorkspaces * sizeof(Boolean))) == NULL))
- {
- Warning (((char *)GETMESSAGE(52, 5, "Insufficient memory to create Occupy Workspace dialog.")));
- return (NULL);
- }
- pPres->numWorkspaces = pSD->numWorkspaces;
- for (i = 0; i < pSD->numWorkspaces; i++)
- {
- pPres->ItemStrings[i] = XmStringCopy (pSD->pWS[i].title);
- if (pSD->pWS[i].id == pSD->pActiveWS->id)
- {
- pPres->currentWsItem = 1+i;
- }
- }
- /*
- * Create the widget
- */
- i = 0;
- XtSetArg (setArgs[i], XmNitemCount, pSD->numWorkspaces); i++;
- XtSetArg (setArgs[i], XmNitems, pPres->ItemStrings); i++;
- XtSetArg (setArgs[i], XmNselectionPolicy, XmEXTENDED_SELECT); i++;
- XtSetArg (setArgs[i], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); i++;
- listW = XmCreateScrolledList (mgrW, "list", setArgs, i);
- XtManageChild (listW);
- if (pPres->pCDforClient)
- {
- /*
- * Highlight the workspaces this client resides in
- */
- for (i = 0; i < pPres->pCDforClient->pSD->numWorkspaces; i++)
- {
- if (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[i],
- pPres->pCDforClient))
- {
- XmListSelectPos (listW, i+1, TRUE);
- pPres->ItemSelected[i] = True;
- }
- else
- {
- pPres->ItemSelected[i] = False;
- }
- }
- }
- /*
- * Insure a minimum number are visible.
- */
- i = 0;
- XtSetArg (setArgs[i], XmNvisibleItemCount, &numVisible); i++;
- XtGetValues (listW, setArgs, i);
- if (numVisible < MIN_VISIBLE)
- {
- i = 0;
- XtSetArg (setArgs[i], XmNvisibleItemCount, MIN_VISIBLE);i++;
- XtSetValues (listW, setArgs, i);
- }
- XtAddCallback (listW, XmNextendedSelectionCallback,
- (XtCallbackProc) wspExtendedSelectCB, (XtPointer)pSD);
- /* Handle the double-click just like if the Ok button was pressed */
- XtAddCallback (listW, XmNdefaultActionCallback,
- (XtCallbackProc) wspOkCB, (XtPointer)pSD);
- return (listW);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspUpdateWorkspaceList (pPres)
- *
- *
- * Description:
- * -----------
- * Updates the list widget containing all the workspaces.
- * Sets the ones for this client.
- *
- * Inputs:
- * ------
- * pPres = ptr to presence dialog data
- *
- * Outputs:
- * -------
- * none
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static void
- wspUpdateWorkspaceList(
- PtrWsPresenceData pPres )
- {
- int n;
- XmString xmsTmp, *pxmsSelected;
- WmScreenData *pSD;
- Arg args[5];
- int wsnum, numSelected;
- /*
- * Update the list of workspaces to -- one may have been
- * renamed since the last time we were up.
- */
- pSD = pPres->pCDforClient->pSD;
- for (wsnum = 0; wsnum < pSD->numWorkspaces; wsnum++)
- {
- xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);
- if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum]))
- {
- /*
- * Replace the string in our local list
- */
- XmStringFree (pPres->ItemStrings[wsnum]);
- pPres->ItemStrings[wsnum] = xmsTmp;
- /*
- * Replace the item in the scrolled list.
- */
- XmListDeletePos (pPres->workspaceListW, 1+wsnum);
- XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);
- }
- else
- {
- XmStringFree (xmsTmp);
- }
- }
- /*
- * Highlight the workspaces this client resides in
- */
- XmListDeselectAllItems (pPres->workspaceListW);
- pxmsSelected = (XmString *)
- XtMalloc (pPres->pCDforClient->pSD->numWorkspaces * sizeof (XmString));
- numSelected = 0;
- for (wsnum = 0; wsnum < pPres->pCDforClient->pSD->numWorkspaces; wsnum++)
- {
- if (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum],
- pPres->pCDforClient))
- {
- pxmsSelected[numSelected++] = pPres->ItemStrings[wsnum];
- pPres->ItemSelected[wsnum] = True;
- }
- else
- {
- pPres->ItemSelected[wsnum] = False;
- pPres->pCDforClient->putInAll = False;
- }
- if (pPres->pCDforClient->pSD->pActiveWS->id ==
- pPres->pCDforClient->pSD->pWS[wsnum].id)
- {
- /* save item number of current workspace */
- pPres->currentWsItem = 1+wsnum;
- }
- }
- /* set the selected items */
- n = 0;
- XtSetArg (args[n], XmNselectedItems, pxmsSelected); n++;
- XtSetArg (args[n], XmNselectedItemCount, numSelected); n++;
- XtSetValues (pPres->workspaceListW, args, n);
- /* set state of all workspaces button */
- n = 0;
- XtSetArg (args[n], XmNset, pPres->pCDforClient->putInAll); n++;
- XtSetValues (pPres->allWsW, args, n);
- /* set name of window we're popped up for */
- wspSetWindowName (pPres);
- XtFree ((char *) pxmsSelected);
-
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * wspCreateToggleButton (mgrW, pch)
- *
- *
- * Description:
- * -----------
- * Creates a toggle button as a child of mgrW with the string pch.
- *
- * Inputs:
- * ------
- * mgrW = parent widget
- * pch = string to use for toggle button
- *
- * Outputs:
- * -------
- * Return = widget created
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Widget
- wspCreateToggleButton(
- Widget mgrW,
- unsigned char *pch )
- {
- Arg setArgs[20];
- int i;
- Widget toggleW;
- XmString labelString;
- i = 0;
- labelString = XmStringCreateLocalized ((char *)pch);
- XtSetArg (setArgs[i], XmNlabelString, labelString); i++;
- toggleW = XmCreateToggleButton (mgrW, (char *)pch, setArgs, i);
- XmStringFree(labelString);
- XtManageChild (toggleW);
- return (toggleW);
- } /* END OF FUNCTION wspCreateToggleButton */
- /*************************************<->*************************************
- *
- * wspCreatePushButton (mgrW, label)
- *
- *
- * Description:
- * -----------
- * Creates a push button as a child of mgrW with the string pch.
- *
- * Inputs:
- * ------
- * mgrW = parent widget
- * label = XmString to use for button label
- *
- * Outputs:
- * -------
- * Return = widget created
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Widget
- wspCreatePushButton(
- Widget mgrW,
- char *name,
- XmString label )
- {
- Arg setArgs[20];
- int i;
- Widget pushW;
- i = 0;
- XtSetArg (setArgs[i], XmNlabelString, label); i++;
- pushW = (Widget) XmCreatePushButton (mgrW, name, setArgs, i);
- XtManageChild (pushW);
- return (pushW);
- } /* END OF FUNCTION wspCreatePushButton */
- /*************************************<->*************************************
- *
- * wspSetPosition (pPres)
- *
- *
- * Description:
- * -----------
- * Sets the position of the workspace presence dialog
- *
- * Inputs:
- * ------
- * pPres = pointer to workspace presence data
- *
- * Outputs:
- * --------
- *
- ******************************<->***********************************/
- static void
- wspSetPosition(
- PtrWsPresenceData pPres )
- {
- WmScreenData *pSD = pPres->pCDforClient->pSD;
- Arg args[10];
- int n;
- XFontStruct *font;
- Dimension height;
- int x, y;
- /*
- * Get size of this dialog
- */
- n = 0;
- XtSetArg (args[n], XmNheight, &height); n++;
- XtGetValues (pPres->shellW, args, n);
- if (wmGD.positionIsFrame)
- {
- if (pSD->decoupleTitleAppearance)
- {
- font = pSD->clientTitleAppearance.font;
- }
- else
- {
- font = pSD->clientAppearance.font;
- }
- height += TEXT_HEIGHT(font) + (2 * pSD->frameBorderWidth);
- }
- /*
- * set position of dialog relative to client window
- * (use system menu position)
- * set this dialog to be transient for the client
- * for which it is posted.
- */
- GetSystemMenuPosition (pPres->pCDforClient,
- &x, &y, height,
- pPres->contextForClient);
- n = 0;
- XtSetArg (args[n], XmNx, x); n++;
- XtSetArg (args[n], XmNy, y); n++;
- XtSetArg (args[n], XmNtransientFor, NULL); n++;
- if (pPres->contextForClient != F_CONTEXT_ICON)
- {
- XtSetArg (args[n], XmNwindowGroup, pPres->pCDforClient->client); n++;
- }
- else if (pSD->useIconBox && P_ICON_BOX(pPres->pCDforClient))
- {
- XtSetArg (args[n], XmNwindowGroup,
- P_ICON_BOX(pPres->pCDforClient)->pCD_iconBox->client); n++;
- }
- else
- {
- XtSetArg (args[n], XmNwindowGroup, 0); n++;
- }
- XtSetArg (args[n], XmNwaitForWm, False); n++;
- XtSetValues (pPres->shellW, args, n);
- } /* END OF FUNCTION wspSetPosition */
- /*************************************<->*************************************
- *
- * wspCharWidth (xmfl)
- *
- *
- * Description:
- * -----------
- * Returns the max logical character width for this fontList
- *
- *
- * Inputs:
- * ------
- * xmfl - XmFontList
- *
- * Returns:
- * -------
- * max logical character width
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static Dimension
- wspCharWidth(
- XmFontList xmfl )
- {
- XmFontContext fc;
- XmFontListEntry entry;
- Dimension dWidth, dTmpWidth;
- XtPointer pFont;
- XmFontType type;
- XFontSetExtents *pExtents;
- XmFontListInitFontContext ( &fc, xmfl);
- dWidth = 0;
- entry = XmFontListNextEntry (fc);
- while (entry)
- {
- pFont = XmFontListEntryGetFont (entry, &type);
- switch (type)
- {
- case XmFONT_IS_FONT:
- dTmpWidth = ((XFontStruct *)pFont)->max_bounds.rbearing -
- ((XFontStruct *)pFont)->min_bounds.lbearing;
- break;
- case XmFONT_IS_FONTSET:
- pExtents = XExtentsOfFontSet ((XFontSet) pFont);
- dTmpWidth = pExtents->max_logical_extent.width;
- break;
- default:
- dTmpWidth = 0;
- break;
- }
- if (dTmpWidth > dWidth)
- dWidth = dTmpWidth;
- entry = XmFontListNextEntry (fc);
- }
- XmFontListFreeFontContext (fc);
- return (dWidth);
- }
- /*************************************<->*************************************
- *
- * wspLayout (pPres)
- *
- *
- * Description:
- * -----------
- * Lays out the workspace presence dialog
- *
- *
- * Inputs:
- * ------
- * pPres = pointer to workspace presence data
- *
- * Outputs:
- * -------
- * none
- *
- * Comments:
- * ---------
- ******************************<->***********************************/
- static void
- wspLayout(
- PtrWsPresenceData pPres )
- {
- Arg args[20];
- int n;
- #define SEP_OFFSET 10
- #define IW_OFFSET_1 8
- #define IW_OFFSET_0 4
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNtopPosition, 5); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNleftOffset, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetValues (pPres->windowLabelW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->windowLabelW); n++;
- XtSetArg (args[n], XmNtopOffset, IW_OFFSET_0); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNleftOffset, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomOffset, 0); n++;
- XtSetValues (pPres->workspaceLabelW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNtopPosition, 5); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, pPres->workspaceLabelW); n++;
- XtSetArg (args[n], XmNleftOffset, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNrightOffset, 5); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomOffset, 0); n++;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetValues (pPres->windowNameW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->windowNameW); n++;
- XtSetArg (args[n], XmNtopOffset, IW_OFFSET_0); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, pPres->workspaceLabelW); n++;
- XtSetArg (args[n], XmNleftOffset, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNrightOffset, 5); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomOffset, 0); n++;
- XtSetValues (pPres->workspaceScrolledListW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->workspaceScrolledListW); n++;
- XtSetArg (args[n], XmNtopOffset, IW_OFFSET_1); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, pPres->workspaceLabelW); n++;
- XtSetArg (args[n], XmNleftOffset, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNrightOffset, 5); n++;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg (args[n], XmNmarginRight, 5); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomOffset, 0); n++;
- XtSetValues (pPres->allWsW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->allWsW); n++;
- XtSetArg (args[n], XmNtopOffset, SEP_OFFSET); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNleftOffset, 0); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNrightOffset, 0); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg (args[n], XmNbottomOffset, 0); n++;
- XtSetValues (pPres->sepW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->sepW); n++;
- XtSetArg (args[n], XmNtopOffset, SEP_OFFSET); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNleftPosition, 5); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNrightPosition, 30); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNbottomPosition, 95); n++;
- XtSetValues (pPres->OkW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->sepW); n++;
- XtSetArg (args[n], XmNtopOffset, SEP_OFFSET); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNleftPosition, 36); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNrightPosition, 66); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNbottomPosition, 95); n++;
- XtSetValues (pPres->CancelW, args, n);
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNtopWidget, pPres->sepW); n++;
- XtSetArg (args[n], XmNtopOffset, SEP_OFFSET); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNleftPosition, 71); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNrightPosition, 95); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNbottomPosition, 95); n++;
- XtSetValues (pPres->HelpW, args, n);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * static void
- * wspOkCB (w, client_data, call_data)
- *
- *
- * Description:
- * -----------
- * OK callback.
- *
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void
- wspOkCB(
- Widget buttonW,
- WmScreenData *pSD,
- XtPointer call_data )
- {
- Arg args[20];
- int n, j;
- int selectedItemCount;
- XmStringTable selectedItems;
- PtrWsPresenceData pPres = &pSD->presence;
- Boolean bAllSelected;
- /* find the selected workspaces */
- n = 0;
- XtSetArg (args[n], XmNselectedItemCount, &selectedItemCount); n++;
- XtSetArg (args[n], XmNselectedItems, &selectedItems); n++;
- XtGetValues (pPres->workspaceListW, args, n);
- /* find the state of all workspaces button */
- n = 0;
- XtSetArg (args[n], XmNset, &bAllSelected); n++;
- XtGetValues (pPres->allWsW, args, n);
- if (bAllSelected)
- {
- F_AddToAllWorkspaces(NULL, pPres->pCDforClient, NULL);
- }
- else if (selectedItemCount)
- {
- for (n = 0; n < pSD->numWorkspaces; n++)
- {
- pPres->ItemSelected[n] = False;
- for (j = 0; j < selectedItemCount; j++)
- {
- if (XmStringCompare (selectedItems[j],
- pPres->ItemStrings[n]))
- {
- pPres->ItemSelected[n] = True;
- }
- }
- if (!pPres->ItemSelected[n] &&
- ClientInWorkspace (&pSD->pWS[n], pPres->pCDforClient))
- {
- RemoveClientFromWorkspaces (pPres->pCDforClient,
- &pSD->pWS[n].id, 1);
- }
- if (pPres->ItemSelected[n] &&
- !ClientInWorkspace (&pSD->pWS[n], pPres->pCDforClient))
- {
- AddClientToWorkspaces (pPres->pCDforClient,
- &pSD->pWS[n].id, 1);
- }
- }
- }
- /* withdraw the dialog */
- wspCancelCB (buttonW, (XtPointer)pSD, call_data);
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * static void
- * wspAllWsCB (w, client_data, call_data)
- *
- *
- * Description:
- * -----------
- * All Workspace toggle button callback.
- *
- *
- * Inputs:
- * ------
- * None.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void
- wspAllWsCB(
- Widget buttonW,
- WmScreenData *pSD,
- XmToggleButtonCallbackStruct *xmTbcs )
- {
- PtrWsPresenceData pPres = &pSD->presence;
- int wsnum;
- XmString *pxmsSelected;
- Arg args[5];
- int n;
- if (xmTbcs->reason == XmCR_VALUE_CHANGED)
- {
- if (xmTbcs->set)
- {
- pxmsSelected = (XmString *)
- XtMalloc (pSD->numWorkspaces * sizeof (XmString));
- for (wsnum = 0; wsnum < pSD->numWorkspaces; wsnum++)
- {
- pxmsSelected[wsnum] = pPres->ItemStrings[wsnum];
- }
- /* set the selected items */
- n = 0;
- XtSetArg (args[n], XmNselectedItems, pxmsSelected); n++;
- XtSetArg (args[n], XmNselectedItemCount, pSD->numWorkspaces); n++;
- XtSetValues (pPres->workspaceListW, args, n);
- XtFree ((char *) pxmsSelected);
- }
- else
- {
- /* select current workspace */
- XmListDeselectAllItems (pPres->workspaceListW);
- XmListSelectPos (pPres->workspaceListW, pPres->currentWsItem, TRUE);
- }
- }
- } /* END OF FUNCTION */
- /*************************************<->*************************************
- *
- * static void
- * wspExtendedSelectCB (w, client_data, cb)
- *
- *
- * Description:
- * -----------
- * Cancel callback.
- *
- *
- * Inputs:
- * ------
- * None.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void
- wspExtendedSelectCB(
- Widget w,
- XtPointer client_data,
- XmListCallbackStruct *cb )
- {
- WmScreenData *pSD = (WmScreenData *) client_data;
- PtrWsPresenceData pPres = &pSD->presence;
- int n;
- Arg args[5];
- if (cb->reason == XmCR_EXTENDED_SELECT)
- {
- if ((cb->selected_item_count < pSD->numWorkspaces) &&
- (cb->event != None))
- {
- n = 0;
- XtSetArg (args[n], XmNset, False); n++;
- XtSetValues (pPres->allWsW, args, n);
- }
- }
- } /* END OF FUNCTION wspExtendedSelectCB */
- /*************************************<->*************************************
- *
- * static void
- * wspCancelCB (w, client_data, call_data)
- *
- *
- * Description:
- * -----------
- * Cancel callback.
- *
- *
- * Inputs:
- * ------
- * None.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void
- wspCancelCB(
- Widget buttonW,
- XtPointer client_data,
- XtPointer call_data )
- {
- WmScreenData *pSD = (WmScreenData *) client_data;
- XtPopdown (pSD->presence.shellW);
- pSD->presence.onScreen = False;
- } /* END OF FUNCTION wspCancelCB */
- /*************************************<->*************************************
- *
- * GetPresenceBoxMenuItems (pSD)
- *
- *
- * Description:
- * -----------
- * XXDescription ...
- *
- *************************************<->***********************************/
- MenuItem *
- GetPresenceBoxMenuItems(
- WmScreenData *pSD )
- {
- return(NULL);
- } /* END OF FUNCTION GetPresenceBoxMenuItems */
- /*************************************<->*************************************
- *
- * UpdatePresenceWorkspaces (pSD)
- *
- *
- * Description:
- * -----------
- * Update the presence dialog when the number of workspaces changes.
- *
- *************************************<->***********************************/
- void
- UpdatePresenceWorkspaces(
- WmScreenData *pSD )
- {
- PtrWsPresenceData pPres = &pSD->presence;
- int wsnum;
- XmString xmsTmp;
- if (pPres->shellW)
- {
- if (pPres->numWorkspaces < pSD->numWorkspaces)
- {
- if (((pPres->ItemStrings = (XmStringTable) XtRealloc
- ((char *)pPres->ItemStrings,
- (pSD->numWorkspaces * sizeof(XmString *)))) == NULL) ||
- ((pPres->ItemSelected = (Boolean *) XtRealloc
- ((char *)pPres->ItemSelected,
- (pSD->numWorkspaces * sizeof(Boolean)))) == NULL))
- {
- Warning (((char *)GETMESSAGE(52, 5, "Insufficient memory to create Occupy Workspace dialog.")));
- pPres->shellW = NULL;
- return;
- }
- }
- /*
- * Replace the names in the dialog's list
- */
- for (wsnum = 0; wsnum < pPres->numWorkspaces; wsnum++)
- {
- if (wsnum < pSD->numWorkspaces)
- {
- xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);
- if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum]))
- {
- /*
- * Replace the string in our local list
- */
- XmStringFree (pPres->ItemStrings[wsnum]);
- pPres->ItemStrings[wsnum] = xmsTmp;
- /*
- * Replace the item in the scrolled list.
- */
- XmListDeletePos (pPres->workspaceListW, 1+wsnum);
- XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);
- }
- else
- {
- XmStringFree (xmsTmp);
- }
- }
- else
- {
- /*
- * Delete this workspace from the list
- */
- XmStringFree (pPres->ItemStrings[wsnum]);
- pPres->ItemStrings[wsnum] = NULL;
- XmListDeletePos (pPres->workspaceListW, 1+wsnum);
- }
- }
- for (; wsnum < pSD->numWorkspaces; wsnum++)
- {
- /*
- * Add these workspaces to the list.
- */
- xmsTmp = XmStringCopy (pSD->pWS[wsnum].title);
- pPres->ItemStrings[wsnum] = xmsTmp;
- XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum);
- if (pPres->pCDforClient &&
- (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum],
- pPres->pCDforClient)))
- {
- XmListSelectPos (pPres->workspaceListW, 1+wsnum, TRUE);
- pPres->ItemSelected[wsnum] = True;
- }
- else
- {
- pPres->ItemSelected[wsnum] = False;
- }
- }
- pPres->numWorkspaces = pSD->numWorkspaces;
- }
- } /* END OF FUNCTION UpdatePresenceWorkspaces */
- /**************************** eof ***************************/
|