/** Transfert the selected client to * the wanted tag * \param cmd Wanted tag, uicb_t type */ void uicb_tagtransfert(uicb_t cmd) { CHECK(sel); tag_transfert(sel, atoi(cmd)); return; }
/** Transfert the selected client to the prev tag * \param cmd uicb_t type unused */ void uicb_tagtransfert_prev(uicb_t cmd) { CHECK(sel); int tag = seltag[selscreen] - 1; (void)cmd; if(tag <= 0) { if(!conf.tag_round) return; tag = conf.ntag[selscreen]; } tag_transfert(sel, tag); return; }
/** Transfert the selected client to the next tag * \param cmd uicb_t type unused */ void uicb_tagtransfert_next(uicb_t cmd) { CHECK(sel); int tag = seltag[selscreen] + 1; (void)cmd; if(tag > conf.ntag[selscreen]) { if(!conf.tag_round) return; tag = 1; } tag_transfert(sel, tag); return; }
/** ButtonPress handle event * \param ev XButtonEvent pointer */ static void buttonpress(XButtonEvent *ev) { Client *c; int i, j, n; screen_get_sel(); /* If the mouse is on a not selected client and you click on it. */ if(((c = client_gb_win(ev->window)) || (c = client_gb_titlebar(ev->window))) && c != sel && (ev->button == Button1 || ev->button == Button2 || ev->button == Button3)) { client_focus(c); client_raise(c); return; } /* Titlebar */ if((c = client_gb_titlebar(ev->window)) && c == sel) for(i = 0; i < conf.titlebar.nmouse; ++i) if(ev->button == conf.titlebar.mouse[i].button) if(conf.titlebar.mouse[i].func) conf.titlebar.mouse[i].func(conf.titlebar.mouse[i].cmd); /* Titlebar buttons */ if((c = client_gb_button(ev->window, &n))) for(i = 0; i < conf.titlebar.button[n].nmouse; ++i) if(ev->button == conf.titlebar.button[n].mouse[i].button) if(conf.titlebar.button[n].mouse[i].func) { client_focus(c); conf.titlebar.button[n].mouse[i].func(conf.titlebar.button[n].mouse[i].cmd); } /* Frame Resize Area */ if((c = client_gb_resize(ev->window))) mouse_resize(c); /* Client */ if((c = client_gb_win(ev->window)) && c == sel) for(i = 0; i < conf.client.nmouse; ++i) if(ev->button == conf.client.mouse[i].button) if(conf.client.mouse[i].func) conf.client.mouse[i].func(conf.client.mouse[i].cmd); /* Root */ if(ev->window == ROOT) for(i = 0; i < conf.root.nmouse; ++i) if(conf.root.mouse[i].tag == seltag[conf.root.mouse[i].screen] || conf.root.mouse[i].tag < 0) if(ev->button == conf.root.mouse[i].button) if(conf.root.mouse[i].func) conf.root.mouse[i].func(conf.root.mouse[i].cmd); /* Infobars */ for(i = 0; i < screen_count(); ++i) if(ev->window == infobar[i].bar->win) for(j = 0; j < conf.bars.nmouse; ++j) if(conf.bars.mouse[j].screen == i || conf.bars.mouse[j].screen < 0) if(conf.bars.mouse[j].tag == seltag[i] || conf.bars.mouse[j].tag < 0) if(ev->button == conf.bars.mouse[j].button) if(conf.bars.mouse[j].func) conf.bars.mouse[j].func(conf.bars.mouse[j].cmd); /* Selbar */ if(conf.bars.selbar && ev->window == infobar[selscreen].selbar->win) for(i = 0; i < conf.selbar.nmouse; ++i) if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen] || conf.selbar.mouse[i].tag < 0) if(ev->button == conf.selbar.mouse[i].button) if(conf.selbar.mouse[i].func) conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd); /* Tags */ for(i = 1; i < conf.ntag[selscreen] + 1; ++i) if(ev->window == infobar[selscreen].tags[i]->win) { for(j = 0; j < tags[selscreen][i].nmouse; ++j) if(ev->button == tags[selscreen][i].mouse[j].button) if(tags[selscreen][i].mouse[j].func) tags[selscreen][i].mouse[j].func(tags[selscreen][i].mouse[j].cmd); /* Mouse button action on tag */ if(ev->button == conf.mouse_tag_action[TagSel]) tag_set(i); else if(ev->button == conf.mouse_tag_action[TagTransfert]) tag_transfert(sel, i); else if(ev->button == conf.mouse_tag_action[TagAdd]) tag_additional(selscreen, seltag[selscreen], i); else if(ev->button == conf.mouse_tag_action[TagNext]) tag_set(seltag[selscreen] + 1); else if(ev->button == conf.mouse_tag_action[TagPrev]) tag_set(seltag[selscreen] - 1); } /* Layout button */ if(ev->window == infobar[selscreen].layout_button->win && conf.nlayout > 1) { if(conf.layout_system && (ev->button == Button1 || ev->button == Button3)) /* True -> menu */ { menulayout.y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH; menulayout.x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH); if(infobar[selscreen].geo.y != spgeo[selscreen].y) menulayout.y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH; uicb_menu("menulayout"); } else { switch(ev->button) { case Button1: case Button4: layoutswitch(True); break; case Button3: case Button5: layoutswitch(False); break; } } } return; }
/* ClientMessage handle event *\param ev XClientMessageEvent pointer */ static void clientmessageevent(XClientMessageEvent *ev) { Client *c; Systray *sy; int s, i, mess_t = 0; Atom rt; int rf; ulong ir, il; uchar *ret = NULL; uchar *ret_cmd = NULL; void (*func)(uicb_t); if(ev->format != 32) return; s = screen_count(); for(i = 0; i < net_last + s; ++i) if(net_atom[i] == ev->message_type) mess_t = i; if(ev->window == ROOT) { /* Manage _NET_CURRENT_DESKTOP */ if(mess_t == net_current_desktop && ev->data.l[0] >= 0 && ev->data.l[0] < conf.ntag[selscreen]) tag_set((int)(ev->data.l[0] + 1)); /* Manage _WMFS_SET_SCREEN */ if(mess_t == wmfs_set_screen && ev->data.l[0] >= 0 && ev->data.l[0] <= s) screen_set_sel((int)(ev->data.l[0])); /* Manage _NET_ACTIVE_WINDOW */ else if(mess_t == net_active_window) { if((c = client_gb_win(ev->window))) client_focus(c); else if((sy = systray_find(ev->data.l[0]))) XSetInputFocus(dpy, sy->win, RevertToNone, CurrentTime); } } else if(ev->window == traywin) { /* Manage _NET_WM_SYSTEM_TRAY_OPCODE */ if(mess_t == net_wm_system_tray_opcode) { if(ev->data.l[1] == XEMBED_EMBEDDED_NOTIFY) { systray_add(ev->data.l[2]); systray_update(); } else if(ev->data.l[1] == XEMBED_REQUEST_FOCUS) if((sy = systray_find(ev->data.l[2]))) ewmh_send_message(sy->win, sy->win, "_XEMBED", XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0, 0); } } /* Manage _NET_WM_STATE */ if(mess_t == net_wm_state) if((c = client_gb_win(ev->window))) ewmh_manage_net_wm_state(ev->data.l, c); /* Manage _NET_CLOSE_WINDOW */ if(mess_t == net_close_window) if((c = client_gb_win(ev->window))) client_kill(c); /* Manage _NET_WM_DESKTOP */ if(mess_t == net_wm_desktop) if((c = client_gb_win(ev->window)) && ev->data.l[0] != (long)0xFFFFFFFF) tag_transfert(c, ev->data.l[0]); /* Manage _WMFS_STATUSTEXT_x */ if(mess_t >= wmfs_statustext && ev->data.l[4] == True) { if(XGetWindowProperty(dpy, ROOT, net_atom[mess_t], 0, 4096, False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret) == Success) { statustext_handle(mess_t - wmfs_statustext, (char*)ret); XFree(ret); } } /* Manage _WMFS_FUNCTION && _WMFS_CMD */ if((mess_t == wmfs_function && ev->data.l[4] == True) || (mess_t == wmfs_cmd && ev->data.l[4] == True)) { XGetWindowProperty(dpy, ROOT, net_atom[wmfs_function], 0, 4096, False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret); XGetWindowProperty(dpy, ROOT, net_atom[wmfs_cmd], 0, 4096, False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret_cmd); if((func = name_to_func((char*)ret, func_list))) func((uicb_t)ret_cmd); XFree(ret_cmd); XFree(ret); } /* Manage _WMFS_UPDATE_HINTS */ if(mess_t == wmfs_update_hints) { ewmh_get_number_of_desktop(); ewmh_update_current_tag_prop(); ewmh_get_client_list(); ewmh_get_desktop_names(); ewmh_set_desktop_geometry(); screen_count(); screen_get_sel(); } if(mess_t == wmfs_update_status && estatus) spawn(conf.status_path); return; }