WmSetWs.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: WmSetWs.c /main/6 1996/06/21 17:24:17 ageorge $
  24. *
  25. * (c) Copyright 1996 Digital Equipment Corporation.
  26. * (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
  27. * (c) Copyright 1993,1994,1996 International Business Machines Corp.
  28. * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
  29. * (c) Copyright 1993,1994,1996 Novell, Inc.
  30. * (c) Copyright 1996 FUJITSU LIMITED.
  31. * (c) Copyright 1996 Hitachi.
  32. */
  33. /************************************<+>*************************************
  34. ****************************************************************************
  35. **
  36. ** File: WmSetWs.c
  37. **
  38. ** Project: DT Workspace Manager
  39. **
  40. ** Description: Set the current workspace
  41. **
  42. ****************************************************************************
  43. ************************************<+>*************************************/
  44. #include <stdio.h>
  45. #include <X11/Intrinsic.h>
  46. #include <Dt/Wsm.h>
  47. #include <Dt/WsmP.h>
  48. #include <Dt/WsmM.h>
  49. #include <Dt/Service.h>
  50. #include <Xm/Xm.h>
  51. #include <Xm/AtomMgr.h>
  52. #include <Tt/tttk.h>
  53. #include "DtSvcLock.h"
  54. /*************************************<->*************************************
  55. *
  56. * int DtWsmSetCurrentWorkspace (widget, aWs)
  57. *
  58. *
  59. * Description:
  60. * -----------
  61. * Set the current workspace
  62. *
  63. *
  64. * Inputs:
  65. * ------
  66. * screen_num - screen number, integer
  67. * aWs - atom of workspace
  68. *
  69. * Outputs:
  70. * --------
  71. * Return - 1 (*not* Success) if communication to workspace manager
  72. * was successful.
  73. *
  74. * Comments:
  75. * ---------
  76. * The odd-ball successful return value is a CDE 1.0 bug being
  77. * preserved for backward compatibility.
  78. *
  79. *************************************<->***********************************/
  80. int
  81. DtWsmSetCurrentWorkspace (
  82. Widget widget,
  83. Atom aWs)
  84. {
  85. String pStr[2];
  86. char pch[40];
  87. Tt_message msg;
  88. Tt_status status;
  89. _DtSvcWidgetToAppContext(widget);
  90. _DtSvcAppLock(app);
  91. sprintf (pch, "0x%lx", aWs);
  92. pStr[0] = (String) &pch[0];
  93. pStr[1] = NULL;
  94. msg = tttk_message_create(0, TT_REQUEST, TT_SESSION, 0,
  95. "DtWorkspace_SetCurrent", 0);
  96. status = tt_ptr_error(msg);
  97. if (status != TT_OK) {
  98. _DtSvcAppUnlock(app);
  99. return dtmsg_FAIL;
  100. }
  101. status = tt_message_arg_add(msg, TT_IN, "integer", NULL);
  102. if (status != TT_OK) {
  103. _DtSvcAppUnlock(app);
  104. return dtmsg_FAIL;
  105. }
  106. status = tt_message_arg_ival_set(msg, 0,
  107. XScreenNumberOfScreen(XtScreen(widget)) % 1000);
  108. if (status != TT_OK) {
  109. _DtSvcAppUnlock(app);
  110. return dtmsg_FAIL;
  111. }
  112. status = tt_message_arg_add(msg, TT_IN, Tttk_string, pStr[0]);
  113. if (status != TT_OK) {
  114. _DtSvcAppUnlock(app);
  115. return dtmsg_FAIL;
  116. }
  117. status = tt_message_callback_add(msg, _DtWsmConsumeReply);
  118. if (status != TT_OK) {
  119. _DtSvcAppUnlock(app);
  120. return dtmsg_FAIL;
  121. }
  122. status = tt_message_send(msg);
  123. if (status != TT_OK) {
  124. _DtSvcAppUnlock(app);
  125. return dtmsg_FAIL;
  126. }
  127. _DtSvcAppUnlock(app);
  128. return (dtmsg_SUCCESS);
  129. } /* END OF FUNCTION DtWsmSetCurrentWorkspace */