Esempio n. 1
0
void
WmPanelistShow (Widget w)

{
   SwitchData * switch_data;
   Dimension switch_rc_height;   
   Dimension switch_button_height;   

   Dimension width = XtWidth(panel.shell);
   Dimension height = XtHeight(panel.shell);
   Position x = XtX(panel.shell);
   Position y = XtY(panel.shell);
   Dimension screen_width;

   Display * display;

   CompositeWidget  cw;
   Widget         * widget_list;
   DtWmHints        vHints;

   String    shell_geometry = NULL;
   char      geometry_buffer[32];

   XSizeHints   hints;
   long	        supplied;

   int i;
   Arg al[20];
   int ac;
   


   /*  Find the switch data for later processing  */
   
   switch_data = NULL;
   
   for (i = 0; i < panel.box_data_count; i++)
   {
      if (panel.box_data[i]->switch_data != NULL)
      {
         switch_data = panel.box_data[i]->switch_data;
         break;
      }
   }


   /*  Realize the shell so that it is sized properly for later  */
   /*  positioning and child repositioning.                      */

   XtRealizeWidget (panel.shell);


   /*  See if a geometry has been set.  */
   
   ac = 0;
   XtSetArg (al[ac], XmNgeometry, &shell_geometry);  ac++;
   XtGetValues (panel.shell, al, ac);


   /*  If the shell has no default geometry, construct a default    */
   /*  which will center the panel along the bottom of the display  */

   width = XtWidth (panel.shell);
   screen_width = WidthOfScreen (XtScreen (panel.shell));
   display = XtDisplay (panel.shell);

   if (shell_geometry == NULL)
   {
      Position  x;
      char      geometry_buffer[32];

      if (panel.element_values[PANEL_GEOMETRY].string_value != NULL)
      {
         shell_geometry = panel.element_values[PANEL_GEOMETRY].parsed_value;
      }
      else
      {
         x = (screen_width > width) ? (Position)(screen_width - width) / 2 : 0;
         sprintf (geometry_buffer, "+%d-0", x);
         shell_geometry = geometry_buffer;
      }
      
      XtSetArg (al[0], XmNgeometry, shell_geometry);
      XtSetValues (panel.shell, al, 1);
   }


   /*  Adjust the positions of the buttons within the switch  */
   /*  so that they are spaced nicely.                        */

   if (switch_data != NULL)
   {
      UpdateSwitchGeometry (switch_data->box_data);


      /*  Reposition or adjust the front panel if it is either off  */
      /*  the right edge of the screen or larger than the screen    */

      if (width > screen_width)
      {
         Arg al[1];

         while (width > screen_width && 
                panel.switch_row_count < switch_data->switch_count)
         {	    
            panel.switch_row_count++;

            XtSetArg (al[0], XmNnumColumns, panel.switch_row_count);
            XtSetValues (switch_data->rc, al, 1);

            width = XtWidth (panel.shell);
         }
      }
   }

   SetGeometry (panel.shell, shell_geometry, &x, &y);
   WorkspaceAdjustPanelPosition (x, y, XtWidth (panel.shell),
                                 XtHeight (panel.shell));


   /* Set hints to avoid interactive placement */

   if (XGetWMNormalHints(display, XtWindow(panel.shell),
                         &hints, &supplied) != 0)
   {
      hints.flags |= USPosition|USSize;
      XSetWMNormalHints(display, XtWindow(panel.shell), &hints);
   }


   /*  Set the shells icon and title for when it is minimized  */
   
   if (switch_data != NULL)
   {
      int current_workspace = switch_data->active_switch;

      XtSetArg (al[0], XmNiconName, switch_data->switch_names[current_workspace]);
      XtSetArg (al[1], XmNtitle, switch_data->switch_names[current_workspace]);
      XtSetValues (panel.shell, al, 2);
   }


   /*  Set panel's window manager hints.  */

   vHints.flags = DtWM_HINTS_BEHAVIORS;
   vHints.behaviors = DtWM_BEHAVIOR_PANEL;
   _DtWsmSetDtWmHints (XtDisplay(panel.shell), XtWindow (panel.shell), &vHints);


   /*  Set the subpanel's transientShell to update transientFor and  */
   /*  Set the subpanel hints.                                       */

   vHints.behaviors |= DtWM_BEHAVIOR_SUBPANEL;
   vHints.flags |= DtWM_HINTS_ATTACH_WINDOW;
   vHints.attachWindow = XtWindow (panel.shell);

   for (i = 0, widget_list = M_PopupList (panel.shell); 
        i < M_NumPopups (panel.shell); i++)
   {
      cw = (CompositeWidget) widget_list[i];

      ac = 0;
      XtSetArg (al[ac], XmNtransientFor, NULL);  ac++;
      XtSetValues ((Widget) cw, al, ac);

      ac = 0;
      XtSetArg (al[ac], XmNtransientFor, panel.shell);  ac++;
      XtSetValues ((Widget) cw, al, ac);

      if (M_NumChildren (cw) > 0)
      {
         XtRealizeWidget ((M_Children (cw))[0]);
         _DtWsmSetDtWmHints (XtDisplay (panel.shell), 
                             XtWindow (widget_list[i]), &vHints);
      }
   }


   /*  Set the push recall list and count into the window manager's  */
   /*  screen global data.                                           */
   
   PushRecallSetData ();


   /*  Set up the callback ot the workspace management API for  */
   /*  catching changes in workspace configuration.             */
      
   DtWsmAddWorkspaceModifiedCallback(panel.shell,
                                     WorkspaceModifyCB, (XtPointer)switch_data);


   /*  Get the front panel displayed  */

   XtSetMappedWhenManaged (panel.shell, True);
   XtPopup (panel.shell, XtGrabNone);


   /*  Restore the session information  */

   SessionRestoreData ();


   /*  Set up the window and geometry information for the embedded clients  */

   for (i = 0; i < panel.embedded_client_count; i++)
      EmbeddedClientSetGeometry (&(((WmFpEmbeddedClientList) panel.embedded_client_list)[i]));


   /*  Set the embedded client list and count into the window manager's  */
   /*  screen global data.                                               */

   EmbeddedClientSetData ();
}
Esempio n. 2
0
/*************************************<->*************************************
 *
 *  DtWsmRemoveWorkspaceFunctions (display, client)
 *
 *
 *  Description:
 *  -----------
 *  Request the window manager to disallow workspace functions
 *  for this client.
 *
 *
 *  Inputs:
 *  ------
 *  display	- display 
 *  root	- root window of screen 
 *
 *  Returns:
 *  --------
 *  none
 *
 *  
 *  Comments:
 *  ---------
 *  Disables f.workspace_presence, f.remove, f.occupy_all for this
 *  client.
 * 
 *************************************<->***********************************/
void
DtWsmRemoveWorkspaceFunctions (Display *display, Window client)
{
    DtWmHints vHints, *pHints;
    long functions;
    Boolean bSetHints = False;
    _DtSvcDisplayToAppContext(display);

    _DtSvcAppLock(app);

    if (_DtWsmGetDtWmHints (display, client, &pHints) != Success)
    {
	/*
	 * There were no existing workspace hints, so we'll
	 * just use our own variable
	 */
	pHints = &vHints;
	pHints->flags = 0;
    }

    if (pHints->flags & DtWM_HINTS_FUNCTIONS)
    {
	functions = pHints->functions & 
		(DtWM_FUNCTION_OCCUPY_WS | DtWM_FUNCTION_ALL);
	
	if (functions & DtWM_FUNCTION_ALL)
	{
	    /* 
	     * The flags are a list of functions to remove. If 
	     * the workspace functions aren't on this list, make 
	     * sure that it's put there.
	     */
	    if (!(functions & DtWM_FUNCTION_OCCUPY_WS))
	    {
		/* remove workspace functions */
		pHints->functions |=  DtWM_FUNCTION_OCCUPY_WS;
		bSetHints = True;
	    }
	}
	else
	{
	    /*
	     * The flags are a list of functions to add. If
	     * the workspace functions are on the list, make
	     * sure they get removed.
	     */
	    if (functions & DtWM_FUNCTION_OCCUPY_WS)
	    {
		/* remove workspace functions */
		pHints->functions &=  ~DtWM_FUNCTION_OCCUPY_WS;
		bSetHints = True;
	    }
	}
    }
    else
    {
	/*
	 * The hints didn't have workspace functions specified.
	 * Set the flag and remove workspace functions.
	 */
	pHints->flags |= DtWM_HINTS_FUNCTIONS;
	pHints->functions = DtWM_FUNCTION_OCCUPY_WS | DtWM_FUNCTION_ALL;
	bSetHints = True;
    }

    /*
     * If something needs to be changed, then change it.
     */
    if (bSetHints)
	_DtWsmSetDtWmHints (display, client, pHints);

    /*
     * If we read these hints off the window, then be sure to free
     * them.
     */
    if (pHints && (pHints != &vHints))
    {
	XFree ((char *)pHints);
    }

    _DtSvcAppUnlock(app);
} /* END OF FUNCTION DtWsmRemoveWorkspaceFunctions */