All,
Raster suggested that I use the E_Action system to change desks
instead of my current method of 5 parameters which I thought was
clunky.
So I've added a generic IPC call to execute a named action, as well as
a new action which flips to a desk given the manager, container, zone,
row and column.
This IPC call executes E-Action.func.go exclusively, so it cannot be
used for mouse and keyboard actions I believe.
The number of parameters is variable, but is interpreted as follows:
5 params: manager container zone row column
4 params: container zone row column
3 params: zone row column
2 params: row column
1 param: column
I imagine this works correctly for parameters higher than 2, but I
don't have multihead or xinerama to test it here at work...
I also don't know what would cause there to be more than one manager
in the managers_list (multiple X servers running Enlightenment?), so I
don't know how to tell if 5 params even works : )
Please let me know what you think,
Marc
--
http://www.diadems.com/
1 3 5
2 4 6 R
diff -u -r e/src/bin/e_actions.c /home/mcgmar0u/source/e/src/bin/e_actions.c
--- e/src/bin/e_actions.c 2005-07-06 13:17:03.000000000 -0500
+++ /home/mcgmar0u/source/e/src/bin/e_actions.c 2005-07-06 14:08:50.000000000 -0500
@@ -467,6 +467,122 @@
}
/***************************************************************************/
+ACT_FN_GO(desk_flip_to_complete)
+{
+ /*
+ * NOTE:
+ *
+ * This function does not care if it is given a NULL Manager, as it walks the manager list itself
+ *
+ */
+
+ Evas_List *m, *c, *z;
+ E_Manager *man;
+ E_Container *con;
+ E_Zone *zone;
+
+ int
+ zoneCtr,
+ containerCtr,
+ managerCtr,
+ dx,
+ dy,
+ done
+ ;
+ int
+ intParams[5],
+ maxParams,
+ actualParamCtr,
+ missingOptParamCount,
+ targetCtr
+ ;
+ /*
+ * Array sizes were decided as follows:
+ *
+ * n parameters * 3 chars max + (n - 1) spaces + 1 null terminator
+ *
+ * I think we have limited numbers of desktops to 64, so this might be 1 byte wasted for each parameter...
+ *
+ * tgtParams[20] = 5 parameters * 3 chars max + (5 - 1) spaces + null terminator
+ */
+ char
+ tgtParams[20],
+ *currToken
+ ;
+
+ maxParams = 5;
+ actualParamCtr = 0;
+ memset(intParams, 0, sizeof(intParams));
+ memset(tgtParams, 0, sizeof(tgtParams));
+ strncpy(tgtParams, params, sizeof(tgtParams) - 1);
+
+ /*
+ * Extract the parameters from the string
+ */
+ currToken = strtok(tgtParams, " ");
+
+ while (currToken != NULL) {
+ intParams[actualParamCtr] = atoi(currToken);
+ actualParamCtr++;
+ currToken = strtok(NULL, " ");
+ }
+
+ /*
+ * Now shift the params towards the end of the array if we are missing optional ones
+ *
+ * Optional parameters default to zero
+ */
+ if (actualParamCtr < maxParams) {
+ missingOptParamCount = maxParams - actualParamCtr;
+ for (targetCtr = maxParams - 1; targetCtr >= missingOptParamCount; targetCtr--) {
+ intParams[targetCtr] = intParams[targetCtr - missingOptParamCount];
+ intParams[targetCtr - missingOptParamCount] = 0;
+ }
+ }
+
+ done = 0;
+ managerCtr = 0;
+
+ for (m = e_manager_list(); m && done == 0; m = m->next) {
+ man = m->data;
+
+ if (managerCtr == intParams[0] && man) {
+
+ containerCtr = 0;
+
+ for (c = man->containers; c && done == 0; c = c->next) {
+ con = c->data;
+
+ if (containerCtr == intParams[1] && con) {
+ zoneCtr = 0;
+
+ for (z = con->zones; z && done == 0; z = z->next) {
+ zone = z->data;
+
+ if (zoneCtr == intParams[2] && zone) {
+ e_zone_desk_flip_to(zone, intParams[4], intParams[3]);
+
+ done = 1;
+ }
+
+ zoneCtr++;
+ }
+ }
+
+ containerCtr++;
+ }
+ }
+ managerCtr++;
+ }
+
+ if (done == 0) {
+ printf("Warning: Could not change to requested desk Manager(%i), Container(%i), Zone(%i), Row(%i), Column(%i)\n",
+ intParams[0], intParams[1], intParams[2], intParams[3], intParams[4]
+ );
+ }
+}
+
+/***************************************************************************/
static void
_e_actions_cb_menu_end(void *data, E_Menu *m)
{
@@ -788,6 +904,8 @@
ACT_GO(desk_linear_flip_to);
+ ACT_GO(desk_flip_to_complete);
+
ACT_GO(menu_show);
ACT_GO_MOUSE(menu_show);
ACT_GO_KEY(menu_show);
diff -u -r e/src/bin/e_ipc_handlers.h /home/mcgmar0u/source/e/src/bin/e_ipc_handlers.h
--- e/src/bin/e_ipc_handlers.h 2005-07-06 13:17:03.000000000 -0500
+++ /home/mcgmar0u/source/e/src/bin/e_ipc_handlers.h 2005-07-06 14:05:30.000000000 -0500
@@ -4019,6 +4019,41 @@
#endif
#undef HDL
+/****************************************************************************/
+#define HDL E_IPC_OP_EXEC_ACTION
+#if (TYPE == E_REMOTE_OPTIONS)
+ OP("-exec-action", 2, "Executes an action given the name (OPT1) and a string of parameters (OPT2).", 0, HDL)
+#elif (TYPE == E_REMOTE_OUT)
+ REQ_2STRING(params[0], params[1], HDL);
+#elif (TYPE == E_WM_IN)
+ STRING2(actionName, paramList, e_2str, HDL);
+ {
+ Evas_List *m;
+ E_Manager *man;
+ E_Action
+ *act
+ ;
+
+ man = NULL;
+
+ m = e_manager_list();
+ if (m) {
+ man = m->data;
+
+ if (man) {
+ act = e_action_find(actionName);
+
+ if (act && act->func.go) {
+ act->func.go(E_OBJECT(man), paramList);
+ }
+ }
+ }
+ }
+ END_STRING2(e_2str)
+#elif (TYPE == E_REMOTE_IN)
+#endif
+#undef HDL
+
#if 0
}
#endif
diff -u -r e/src/bin/e_ipc_handlers_list.h /home/mcgmar0u/source/e/src/bin/e_ipc_handlers_list.h
--- e/src/bin/e_ipc_handlers_list.h 2005-07-06 13:17:03.000000000 -0500
+++ /home/mcgmar0u/source/e/src/bin/e_ipc_handlers_list.h 2005-07-06 13:49:54.000000000 -0500
@@ -196,3 +196,4 @@
#define E_IPC_OP_FOCUS_SETTING_SET 196
#define E_IPC_OP_FOCUS_SETTING_GET 197
#define E_IPC_OP_FOCUS_SETTING_GET_REPLY 198
+#define E_IPC_OP_EXEC_ACTION 199