void clayland_seat_handle_event (ClaylandSeat *seat, const ClutterEvent *event) { switch (event->type) { case CLUTTER_MOTION: handle_motion_event (seat, (const ClutterMotionEvent *) event); break; case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_RELEASE: handle_button_event (seat, (const ClutterButtonEvent *) event); break; case CLUTTER_KEY_PRESS: case CLUTTER_KEY_RELEASE: clayland_keyboard_handle_event (&seat->keyboard, (const ClutterKeyEvent *) event); break; default: break; } }
/* update_joystick: [joystick thread] * Reads in data for a single DirectInput joystick device, updates * the internal ALLEGRO_JOYSTICK_STATE structure, and generates any Allegro * events required. */ static void update_joystick(ALLEGRO_JOYSTICK_DIRECTX *joy) { DIDEVICEOBJECTDATA buffer[DEVICE_BUFFER_SIZE]; DWORD num_items = DEVICE_BUFFER_SIZE; HRESULT hr; ALLEGRO_EVENT_SOURCE *es = al_get_joystick_event_source(); /* some devices require polling */ IDirectInputDevice8_Poll(joy->device); /* get device data into buffer */ hr = IDirectInputDevice8_GetDeviceData(joy->device, sizeof(DIDEVICEOBJECTDATA), buffer, &num_items, 0); if (hr != DI_OK && hr != DI_BUFFEROVERFLOW) { if ((hr == DIERR_NOTACQUIRED) || (hr == DIERR_INPUTLOST)) { ALLEGRO_WARN("joystick device not acquired or lost\n"); } else { ALLEGRO_ERROR("unexpected error while polling the joystick\n"); } return; } /* don't bother locking the event source if there's no work to do */ /* this happens a lot for polled devices */ if (num_items == 0) return; _al_event_source_lock(es); { unsigned int i; for (i = 0; i < num_items; i++) { const DIDEVICEOBJECTDATA *item = &buffer[i]; const int dwOfs = item->dwOfs; const DWORD dwData = item->dwData; switch (dwOfs) { case DIJOFS_X: handle_axis_event(joy, &joy->x_mapping, dwData); break; case DIJOFS_Y: handle_axis_event(joy, &joy->y_mapping, dwData); break; case DIJOFS_Z: handle_axis_event(joy, &joy->z_mapping, dwData); break; case DIJOFS_RX: handle_axis_event(joy, &joy->rx_mapping, dwData); break; case DIJOFS_RY: handle_axis_event(joy, &joy->ry_mapping, dwData); break; case DIJOFS_RZ: handle_axis_event(joy, &joy->rz_mapping, dwData); break; case DIJOFS_SLIDER(0): handle_axis_event(joy, &joy->slider_mapping[0], dwData); break; case DIJOFS_SLIDER(1): handle_axis_event(joy, &joy->slider_mapping[1], dwData); break; case DIJOFS_POV(0): handle_pov_event(joy, joy->pov_mapping_stick[0], dwData); break; case DIJOFS_POV(1): handle_pov_event(joy, joy->pov_mapping_stick[1], dwData); break; case DIJOFS_POV(2): handle_pov_event(joy, joy->pov_mapping_stick[2], dwData); break; case DIJOFS_POV(3): handle_pov_event(joy, joy->pov_mapping_stick[3], dwData); break; default: /* buttons */ if ((dwOfs >= DIJOFS_BUTTON0) && (dwOfs < DIJOFS_BUTTON(joy->parent.info.num_buttons))) { int num = (dwOfs - DIJOFS_BUTTON0) / (DIJOFS_BUTTON1 - DIJOFS_BUTTON0); handle_button_event(joy, num, (dwData & 0x80)); } break; } } } _al_event_source_unlock(es); }
void mbdesktop_main(MBDesktop *mb) { XEvent ev; Atom workarea_atom = XInternAtom(mb->dpy, "_NET_WORKAREA",False); MBDesktopModuleslist *module_current = NULL; #ifdef USE_DNOTIFY sigset_t block_sigset; sigemptyset(&block_sigset); sigaddset(&block_sigset, SIGRTMIN); /* XXX should also add stuff like a HUP etc .. */ #endif mbdesktop_view_paint(mb, True); XFlush(mb->dpy); while (1) { if (WantReload) /* Triggered by dnotify signals etc */ { mbdesktop_item_folder_contents_free(mb, mb->top_head_item); mb->current_folder_item = mb->top_head_item; modules_unload(mb); /* XXX more eficient way ? */ modules_init(mb); mb->kbd_focus_item = mb->current_head_item = mb->scroll_offset_item = mb->top_head_item->item_child; mbdesktop_view_paint(mb, False); WantReload = False; XSync(mb->dpy, False); } XNextEvent(mb->dpy, &ev); #ifdef USE_DNOTIFY /* Block dnotify signal */ sigprocmask(SIG_BLOCK, &block_sigset, NULL); #endif #ifdef USE_XSETTINGS if (mb->xsettings_client != NULL) xsettings_client_process_event(mb->xsettings_client, &ev); #endif switch (ev.type) { case MappingNotify: XRefreshKeyboardMapping(&ev.xmapping); break; case FocusIn: mb->have_focus = True; mbdesktop_view_paint(mb, True); break; case FocusOut: mbdesktop_view_paint(mb, True); mb->have_focus = False; break; case Expose: if (ev.xexpose.count > 0) mbdesktop_view_paint(mb, True); break; case PropertyNotify: if (ev.xproperty.atom == workarea_atom) { int wx, wy, ww, wh; if (mbdesktop_get_workarea(mb, &wx, &wy, &ww, &wh)) { if (mb->workarea_x != wx || mb->workarea_y != wy || mb->workarea_width != ww || mb->workarea_height != wh) mbdesktop_view_configure(mb); } } else if (ev.xproperty.atom == mb->atom_mb_theme) { if (mbdesktop_get_theme_via_root_prop(mb)) mbdesktop_switch_theme (mb, NULL ); } break; /* case ConfigureRequest: mbdesktop_win_plugin_configure_request(mb, &ev.xconfigurerequest); break; */ case ConfigureNotify: if ( ev.xconfigure.width != mb->desktop_width || ev.xconfigure.height != mb->desktop_height) { mb->desktop_width = ev.xconfigure.width; mb->desktop_height = ev.xconfigure.height; mbdesktop_view_configure(mb); } break; case ButtonPress: handle_button_event(mb, &ev.xbutton); break; case KeyPress: handle_key_event(mb, &ev.xkey); break; } module_current = mb->modules; while (module_current != NULL) { if (module_current->module_handle->mod_xevent) module_current->module_handle->mod_xevent(mb, module_current->module_handle, &ev); module_current = module_current->next; } /* if (mb->current_folder_item && mb->current_folder_item->module_handle && mb->current_folder_item->module_handle->folder_xevent) { mb->current_folder_item->module_handle->folder_xevent(mb, mb->current_folder_item, &ev); } */ #ifdef USE_DNOTIFY /* Unblock dnotify signal */ sigprocmask(SIG_UNBLOCK, &block_sigset, NULL); #endif } }