Esempio n. 1
0
XCTRL_API int get_workarea_geom(Display *disp, Geometry*geom, int desknum)
{
  ulong *wkarea = NULL;
  ulong wkarea_size = 0;
  int rv=0;
  if (desknum<0) { return 0; }
  if (get_number_of_desktops(disp)<=desknum) { return 0; }
  wkarea = get_uprop(DefRootWin, "_NET_WORKAREA", &wkarea_size);
  if (!wkarea) {
    wkarea = get_uprop(DefRootWin, "_WIN_WORKAREA", &wkarea_size);
  }
  if (wkarea && wkarea_size > 0) {
    if (wkarea_size == (4*sizeof(*wkarea))) {
      geom->x=wkarea[0];
      geom->y=wkarea[1];
      geom->w=wkarea[2];          
      geom->h=wkarea[3];
      rv=1;
    } else {
      if (desknum < wkarea_size / sizeof(*wkarea) / 4) {
        geom->y=wkarea[desknum*4];
        geom->x=wkarea[desknum*4+1];
        geom->w=wkarea[desknum*4+2];
        geom->h=wkarea[desknum*4+3];
        rv=1;
      }
    }
    sfree(wkarea);
  }
  return rv;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    if (!open_display()) {
        printf("Cannot open display\n");
        return 1;
    }

    init_atoms();

    iterate_client_list(get_number_of_desktops());
    event_loop();

    XCloseDisplay (dpy);
    return 0;
}
Esempio n. 3
0
void
pager_draw (void)
{
	int desks, i, x = GRILL_WIDTH;

	desks = get_number_of_desktops ();

	for (i = 0; i < desks; i++)
	{
		pager_draw_button (x, i);
		if (i > 8)
			break;
		x += PAGER_BUTTON_WIDTH;
	}

	pager_size = x;
}
Esempio n. 4
0
void
switch_desk (int new_desk)
{
	XClientMessageEvent xev;

	if (get_number_of_desktops () <= new_desk)
		return;

	xev.type = ClientMessage;
	xev.window = root_win;
	xev.message_type = atom__NET_CURRENT_DESKTOP;
	xev.format = 32;
	xev.data.l[0] = new_desk;
	xev.data.l[1] = 0;
	xev.data.l[2] = 0;
	xev.data.l[3] = 0;
	xev.data.l[4] = 0;
	XSendEvent (dd, root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *) &xev);
}
Esempio n. 5
0
void event_loop()
{
    XEvent ev;
    int xfd;

    xfd = ConnectionNumber(dpy);

    while(1){
        fd_set fd;

        FD_ZERO(&fd);
        FD_SET(xfd, &fd);
        select(xfd + 1, &fd, 0, 0, 0);

        while (XPending(dpy)) {
            XNextEvent(dpy, &ev);
            if(ev.type == PropertyNotify) {
                iterate_client_list(get_number_of_desktops());
            }        
        }
    }
}
Esempio n. 6
0
XCTRL_API int get_desktop_geom(Display *disp, int desknum, Geometry*geom)
{
  ulong *desk_geom   =  NULL;
  ulong geom_size = 0;
  ulong *vport  = NULL;
  ulong vport_size = 0;
  int rv=0;
  if (desknum<0) { return 0; }
  if (get_number_of_desktops(disp)<=desknum) { return 0; }
  desk_geom = get_uprop(DefRootWin, "_NET_DESKTOP_GEOMETRY", &geom_size);
  vport = get_uprop(DefRootWin, "_NET_DESKTOP_VIEWPORT", &vport_size);
  if (desk_geom && geom_size > 0) {
    if (geom_size == 2 * sizeof(*desk_geom)) {
      geom->w=desk_geom[0];
      geom->h=desk_geom[1];
    } else {
      geom->w=desk_geom[desknum*2];
      geom->h=desk_geom[desknum*2+1];
    }
    rv=1;
  }
  if (vport && vport_size > 0) {
    if (vport_size == 2 * sizeof(*vport)) {
      geom->x=vport[0];
      geom->y=vport[1];
    } else {
      if (desknum < vport_size / sizeof(*vport) / 2) {
        geom->x=vport[desknum*2];
        geom->y=vport[desknum*2+1];
      }
    }
    rv=1;
  }
  sfree(desk_geom);
  sfree(vport);
  return rv;
}