void handler_clientmessage_client(XClientMessageEvent *ev) { struct client *c; if (!(c = find_client_by_window(mons, ev->window))) return; if (ev->message_type == atom(WMState)) { DBG("%s: WMState\n", __func__); } else if (ev->message_type == netatom(NetActiveWindow)) { /* switch to the given client's monitor and workspace * and set focus on the client when a NetActive event * occurs. the spec is quite ambiguous about this. this * behaviour might be changed */ set_monitor(c->mon); monitor_select_client(c->mon, c, true); } else if (ev->message_type == atom(WMChangeState)) { if (ev->data.l[0] == IconicState && ev->format == 32) { printf("%s: minimize window\n", __func__); /* TODO: fix minimizing */ } } else if (ev->message_type == netatom(NetDesktop)) { unsigned long ws; DBG("%s: NetDesktop\n", __func__); /* TODO: handle multiple monitors */ if ((ws = ev->data.l[0]) != ALL_WS) ws = ws % N_WORKSPACES; client_set_ws(c, ws); monitor_focus(c->mon, NULL); monitor_arrange(c->mon); } else if (ev->message_type == netatom(NetWMState)) { if (ev->data.l[1] == netatom(NetWMFullscreen) || ev->data.l[2] == netatom(NetWMFullscreen)) { bool fs = false; if (ev->data.l[0] == NET_WM_STATE_ADD) fs = true; else if (ev->data.l[0] == NET_WM_STATE_TOGGLE) fs = !c->fullscreen; set_fullscreen(c, fs); } } }
void handler_motionnotify(XEvent *ev) { XMotionEvent *mev = &ev->xmotion; struct monitor *mon; struct client *c; if ((c = find_client_by_window(mons, mev->window))) { while(XCheckTypedEvent(dpy, MotionNotify, ev)); if (c->mon->sel != c) monitor_select_client(c->mon, c, false); if (motion->type == MovementMotion) handler_motionnotify_move(c, mev); else if (motion->type == ResizeMotion) handler_motionnotify_resize(c, mev); } else { mon = find_monitor_by_pos(mons, mev->x_root, mev->y_root); set_monitor(mon); } }
/* * @brief The main thread run, receiving and processing messages in an infinite * loop */ static void *run(void *arg) { (void) arg; msg_init_queue(msg_buffer, TRANSCEIVER_MSG_BUFFER_SIZE); while (1) { DEBUG("transceiver: Waiting for next message\n"); msg_t m; msg_receive(&m); /* only makes sense for messages for upper layers */ transceiver_command_t *cmd = (transceiver_command_t *) m.content.ptr; DEBUG("transceiver: Transceiver: Message received, type: %02X\n", m.type); switch (m.type) { case RCV_PKT_CC1020: case RCV_PKT_CC1100: case RCV_PKT_CC2420: case RCV_PKT_MC1322X: case RCV_PKT_NATIVE: case RCV_PKT_AT86RF231: receive_packet(m.type, m.content.value); break; case SND_PKT: response = send_packet(cmd->transceivers, cmd->data); m.content.value = response; msg_reply(&m, &m); break; case GET_CHANNEL: *((int32_t *) cmd->data) = get_channel(cmd->transceivers); msg_reply(&m, &m); break; case SET_CHANNEL: *((int32_t *) cmd->data) = set_channel(cmd->transceivers, cmd->data); msg_reply(&m, &m); break; case GET_ADDRESS: *((radio_address_t *) cmd->data) = get_address(cmd->transceivers); msg_reply(&m, &m); break; case SET_ADDRESS: *((radio_address_t *) cmd->data) = set_address(cmd->transceivers, cmd->data); msg_reply(&m, &m); break; case GET_LONG_ADDR: *((transceiver_eui64_t *) cmd->data) = get_long_addr(cmd->transceivers); msg_reply(&m, &m); break; case SET_LONG_ADDR: *((transceiver_eui64_t *) cmd->data) = set_long_addr(cmd->transceivers, cmd->data); msg_reply(&m, &m); break; case SET_MONITOR: set_monitor(cmd->transceivers, cmd->data); break; case POWERDOWN: powerdown(cmd->transceivers); break; case SWITCH_RX: switch_to_rx(cmd->transceivers); break; case GET_PAN: *((int32_t *) cmd->data) = get_pan(cmd->transceivers); msg_reply(&m, &m); break; case SET_PAN: *((int32_t *) cmd->data) = set_pan(cmd->transceivers, cmd->data); msg_reply(&m, &m); break; #ifdef DBG_IGNORE case DBG_IGN: *((int16_t *) cmd->data) = ignore_add(cmd->transceivers, cmd->data); msg_reply(&m, &m); break; #endif default: DEBUG("transceiver: Unknown message received\n"); break; } } return NULL; }
static void gnome_monitor (GtkWidget *widget, WView *view) { set_monitor (view, 1); }