Hi!
This patch had been sitting with me for quite some time. If you guys
are ok with it, I could commit it. Basically adds an action for
toggling/fullscreen'ing of a window. Actually I once wrote an action
to send data over a socket, making it easy for writing shortcuts for
music player ipc's around. I know that this could be achieved by an
"exec nc ...", but I was a bit unsatisfied with the delay :) I'm not
convinced myself as to whether this should go in, but I just included
it in case any one felt it was worthy enough.. Feel free to reject it
:)
Index: e_actions.c
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_actions.c,v
retrieving revision 1.70
diff -r1.70 e_actions.c
355a356,416
> ACT_FN_GO(window_fullscreen_toggle)
> {
> if (!obj) obj = E_OBJECT(e_border_focused_get());
> if (!obj) return;
> if (obj->type != E_BORDER_TYPE)
> {
> obj = E_OBJECT(e_border_focused_get());
> if (!obj) return;
> }
> if (!((E_Border *)obj)->lock_user_fullscreen)
> {
> E_Border *bd;
> bd = (E_Border *)obj;
> if (bd->fullscreen)
> e_border_unfullscreen(bd);
> else if (params == 0 || *params == '\0')
> e_border_fullscreen(bd, e_config->fullscreen_policy);
> else if (! strcmp(params, "resize"))
> e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
> else if (! strcmp(params, "zoom"))
> e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
> }
> }
>
> /***************************************************************************/
> ACT_FN_GO(window_fullscreen)
> {
> if (!obj) obj = E_OBJECT(e_border_focused_get());
> if (!obj) return;
> if (obj->type != E_BORDER_TYPE)
> {
> obj = E_OBJECT(e_border_focused_get());
> if (!obj) return;
> }
> if (!((E_Border *)obj)->lock_user_fullscreen)
> {
> E_Border *bd;
> bd = (E_Border *)obj;
> if (params)
> {
> int v;
> char buf[32];
> if (sscanf(params, "%i %20s", &v, buf) == 2)
> {
> if (v == 1)
> {
> if (buf == 0 || *buf == '\0')
> e_border_fullscreen(bd, e_config->fullscreen_policy);
> else if (! strcmp(buf, "resize"))
> e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
> else if (! strcmp(buf, "zoom"))
> e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
> }
> else if (v == 0)
> e_border_unfullscreen(bd);
> }
> }
> }
> }
>
> /***************************************************************************/
1203a1265,1355
> #include <sys/socket.h>
> #include <sys/un.h>
>
> #define UNIX_PATH_MAX 108
>
> #include <netinet/in.h>
> #include <netdb.h>
>
> ACT_FN_GO(sock)
> {
> if (params)
> {
> struct sockaddr* addr = NULL;
> char *buf, *token, *type;
> int fd, addrlen, flag = 0;
> buf = strdup (params);
> if (! (token = strtok (buf, " "))) goto final;
> type = token;
> if (! (token = strtok (NULL, " "))) goto final;
> if ((! strncmp (type, "unix", 4) && (flag = 1)) ||
> (! strncmp (type, "unix-abs", 4) && (flag = 2)))
> {
> struct sockaddr_un *caddr;
> if ((fd = socket (AF_UNIX, SOCK_DGRAM, 0)) < 0) goto final;
> caddr = (struct sockaddr_un*) malloc (sizeof (struct sockaddr_un));
> caddr->sun_family = AF_UNIX;
> if (flag == 1)
> strncpy (caddr->sun_path, token, UNIX_PATH_MAX);
> else
> {
> *(caddr->sun_path) = '\0';
> strncpy (caddr->sun_path + 1, token, UNIX_PATH_MAX - 1);
> }
> addr = (struct sockaddr*) caddr;
> addrlen = sizeof (struct sockaddr_un);
> }
> else if ((! strcmp (type, "udp") && (flag = 3)) ||
> (! strcmp (type, "tcp") && (flag = 4)))
> {
> struct addrinfo hints;
> struct addrinfo* caddr, *ptr;
> char *colon;
> if (! (colon = strchr (token, ':'))) goto final;
> *colon = '\0';
> memset (&hints, 0, sizeof (struct addrinfo));
> hints.ai_family = AF_INET;
> hints.ai_socktype = ((flag == 3) ? SOCK_DGRAM : SOCK_STREAM);
> if (getaddrinfo (token, colon + 1, &hints, &caddr)) goto final;
> for (ptr = caddr; ptr; ptr = ptr->ai_next)
> {
> if (ptr->ai_family == hints.ai_family &&
> ptr->ai_socktype == hints.ai_socktype)
> {
> if ((fd = socket (ptr->ai_family, ptr->ai_socktype,
> ptr->ai_protocol)) < 0)
> ptr = NULL;
> else
> {
> addrlen = ptr->ai_addrlen;
> addr = (struct sockaddr*) malloc (addrlen);
> memcpy (addr, ptr->ai_addr, addrlen);
> }
> break;
> }
> }
> freeaddrinfo (caddr);
> if (! ptr) goto final;
> }
> else goto final;
> if (connect (fd, addr, addrlen) < 0) goto finish;
> token = strtok (NULL, "");
> {
> size_t towrite = strlen (token);
> ssize_t res;
> while (towrite)
> {
> int res = write (fd, token, towrite);
> if (res < 0 && errno == EINTR) continue;
> if (res <= 0) break;
> towrite -= res;
> token += res;
> }
> }
> finish:
> close (fd);
> free (addr);
> final:
> free (buf);
> }
> }
>
1596a1749,1756
> /* window_fullscreen_toggle */
> ACT_GO(window_fullscreen_toggle);
> e_register_action_predef_name(_("Window : State"), _("Fullscreen Mode
> Toggle"),
> "window_fullscreen_toggle", NULL,
> EDIT_RESTRICT_ACTION | EDIT_RESTRICT_PARAMS,
> 0);
>
> ACT_GO(window_fullscreen);
>
1795a1956,1960
> EDIT_RESTRICT_ACTION, 0);
>
> /* sock */
> ACT_GO(sock);
> e_register_action_predef_name(_("Launch"), _("Output to socket"), "sock",
> NULL,
--
April 1: This is the day upon which we are reminded of
what we are on the other three hundred and sixty-four.
-- Mark Twain, "Pudd'nhead Wilson's Calendar"
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel