コード例 #1
0
ファイル: main.c プロジェクト: xiaq/hlwm
// scan for windows and add them to the list of managed clients
// from dwm.c
void scan(void) {
    unsigned int num;
    Window d1, d2, *cl, *wins = NULL;
    unsigned long cl_count;
    XWindowAttributes wa;

    ewmh_get_original_client_list(&cl, &cl_count);
    if (XQueryTree(g_display, g_root, &d1, &d2, &wins, &num)) {
        for (int i = 0; i < num; i++) {
            if(!XGetWindowAttributes(g_display, wins[i], &wa)
            || wa.override_redirect || XGetTransientForHint(g_display, wins[i], &d1))
                continue;
            // only manage mapped windows.. no strange wins like:
            //      luakit/dbus/(ncurses-)vim
            // but manage it if it was in the ewmh property _NET_CLIENT_LIST by
            // the previous window manager
            // TODO: what would dwm do?
            if (is_window_mapped(g_display, wins[i])
                || 0 <= array_find(cl, cl_count, sizeof(Window), wins+i)) {
                manage_client(wins[i]);
                XMapWindow(g_display, wins[i]);
            }
        }
        if(wins)
            XFree(wins);
    }
}
コード例 #2
0
ファイル: waiting_for_connection.c プロジェクト: quito/my_ftp
int		waiting_for_connection(t_info *info)
{
  int		b;
  unsigned int	size;

  b = 1;
  while (info->accept_connections)
    {
      size = sizeof(info->sin_client);
      info->csock = accept(info->socket,
			   (struct sockaddr *)(&(info->sin_client)),
			   &size);
      if (info->csock == -1)
	{
	  b = 0;
	  info->accept_connections = 0;
	}
      else if (manage_client(info) == 0)
	info->accept_connections = 0;
      close(info->csock);
    }
  waiting_for_pid(info->pid_list);
  close_everything(info);
  return (b);
}
コード例 #3
0
int main(int argc, char **argv)
{
	int sock;
	int new_sock;
	pid_t pid = 0;
	int opt = 1;

	parse_options(argc, argv);

	sock = create_sock();

	while (1) {
		new_sock = accept_request(sock);
		if (new_sock < 1) {
			break;
		}

		if ((setsockopt(new_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) < 0) {
			perror("setsockopt");
		}

		pid = client_fork();
		if (pid == 0) {
			printf("Client spawned\n");
			manage_client(new_sock, "A_PASS_HERE", "ENC_TYPE_HERE");
			close(new_sock);
		}
	}

	return 0;
}
コード例 #4
0
ファイル: loop_server.c プロジェクト: VictorCholet/my_irc
int			post_select(t_server *server,
				    fd_set *rfds,
				    fd_set *wfds)
{
  if (FD_ISSET(server->fd, rfds))
  {
    add_client(server);
  }
  else
  {
    manage_client(server, rfds, wfds);
  }
  return (0);
}
コード例 #5
0
ファイル: main.c プロジェクト: kcirick/fusionwm
// scan for windows and add them to the list of managed clients
void scan(void) {
    unsigned int i, num;
    Window d1, d2, *wins = NULL;
    XWindowAttributes wa;

    if(XQueryTree(gDisplay, gRoot, &d1, &d2, &wins, &num)) {
        for(i = 0; i < num; i++) {
            if(!XGetWindowAttributes(gDisplay, wins[i], &wa)
            || wa.override_redirect || XGetTransientForHint(gDisplay, wins[i], &d1))
                continue;
            if (wa.map_state == IsViewable)
                manage_client(wins[i]);
        }
        for(i = 0; i < num; i++){ // now the transients
           if(!XGetWindowAttributes(gDisplay, wins[i], &wa))
              continue;
           if(XGetTransientForHint(gDisplay, wins[i], &d1)
              && (wa.map_state == IsViewable))
              manage_client(wins[i]);
        }
        if(wins) XFree(wins);
    }
}
コード例 #6
0
ファイル: main.c プロジェクト: kcirick/fusionwm
void maprequest(XEvent* event) {
    XMapRequestEvent* mapreq = &event->xmaprequest;
    Client *c;

    if((c = wintosystrayicon(mapreq->window))) {
       resizebarwin(get_current_monitor());
       updatesystray();
    }

    if (!get_client_from_window(mapreq->window)) {
        // client should be managed (is not ignored but is not managed yet
        Client* client = manage_client(mapreq->window);
        if (client && find_monitor_with_tag(client->tag)) 
            XMapWindow(gDisplay, mapreq->window);
    } 
}
コード例 #7
0
ファイル: rtsp-server.c プロジェクト: PeterXu/gst-mobile
/**
 * gst_rtsp_server_io_func:
 * @channel: a #GIOChannel
 * @condition: the condition on @source
 *
 * A default #GIOFunc that creates a new #GstRTSPClient to accept and handle a
 * new connection on @channel or @server.
 *
 * Returns: TRUE if the source could be connected, FALSE if an error occured.
 */
gboolean
gst_rtsp_server_io_func (GIOChannel * channel, GIOCondition condition,
    GstRTSPServer * server)
{
  gboolean result;
  GstRTSPClient *client = NULL;
  GstRTSPServerClass *klass;

  if (condition & G_IO_IN) {
    klass = GST_RTSP_SERVER_GET_CLASS (server);

    if (klass->create_client)
      client = klass->create_client (server);
    if (client == NULL)
      goto client_failed;

    /* a new client connected, create a client object to handle the client. */
    if (klass->accept_client)
      result = klass->accept_client (server, client, channel);
    if (!result)
      goto accept_failed;

    /* manage the client connection */
    manage_client (server, client);
  } else {
    GST_WARNING_OBJECT (server, "received unknown event %08x", condition);
  }
  return TRUE;

  /* ERRORS */
client_failed:
  {
    GST_ERROR_OBJECT (server, "failed to create a client");
    return FALSE;
  }
accept_failed:
  {
    GST_ERROR_OBJECT (server, "failed to accept client");
    gst_object_unref (client);
    return FALSE;
  }
}
コード例 #8
0
ファイル: main.c プロジェクト: xiaq/hlwm
void maprequest(XEvent* event) {
    HSDebug("name is: MapRequest\n");
    XMapRequestEvent* mapreq = &event->xmaprequest;
    if (is_herbstluft_window(g_display, mapreq->window)) {
        // just map the window if it wants that
        XWindowAttributes wa;
        if (!XGetWindowAttributes(g_display, mapreq->window, &wa)) {
            return;
        }
        XMapWindow(g_display, mapreq->window);
    } else if (!get_client_from_window(mapreq->window)) {
        // client should be managed (is not ignored)
        // but is not managed yet
        HSClient* client = manage_client(mapreq->window);
        if (client && find_monitor_with_tag(client->tag)) {
            XMapWindow(g_display, mapreq->window);
        }
    }
    // else: ignore all other maprequests from windows
    // that are managed already
}
コード例 #9
0
ファイル: do_server.c プロジェクト: dmBART/zappy-autiste
void			manage_serveur(t_desc *serv, t_env *e)
{
  int			i;
  t_timev		t;
  struct timeval	tv;

  FD_ZERO(&e->readfs);
  FD_ZERO(&e->wrtefs);
  i = -1;
  FD_SET(serv->s, &e->readfs);
  t = manage_time(serv);
  while (++i < MAX_FD)
    if (serv->players[i].type != FD_FREE)
      {
	FD_SET(serv->players[i].cs, &e->readfs);
	FD_SET(serv->players[i].cs, &e->wrtefs);
      }
  e->fd_max = search_max_fd(serv->players, e->fd_max);
  manage_time_in_select(t, &tv);
  xselect(e->fd_max + 1, &e->readfs, &e->wrtefs, NULL, &tv);
  if (FD_ISSET(serv->s, &e->readfs))
    add_players(serv, e);
  manage_client(serv, e, t);
}