int main(int argc, char * argv[]) { int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) { show_help(argc, argv); return 0; } else if (strcmp(argv[i], "-res") == 0) { show_resources(); return 0; } } init_appres(argc, argv); the_bar.realized = 0; if (!get_display_info() || !init_resources() || !create_main_window()) exit (1); set_signals(); XMapWindow(gdi.display, gdi.mainw); set_keybindings(); XEvent evt; while (1) { XNextEvent(gdi.display, &evt); #ifdef DEBUG printf("wid %08X\t%s\n", (int)(evt.xany.window), event_names[evt.type]); fflush(stdout); #endif switch(evt.type){ case KeyPress: handle_key_press(&evt); break; case ReparentNotify: handle_reparent(&evt); break; case MapRequest: /* add a new tab */ handle_maprequest(&evt); break; case DestroyNotify: /* remove a tab */ handle_destroy(&evt); break; case ConfigureNotify: handle_configure_notify(&evt); break; case ConfigureRequest: handle_configure_request(&evt); break; case Expose: if (evt.xexpose.window != gdi.mainw) bar_handle_expose(&(evt.xexpose)); break; case ButtonPress: bar_handle_button(&(evt.xbutton)); break; case PropertyNotify: bar_handle_prop(&evt); break; case MapNotify: if (evt.xmap.window == gdi.mainw) { if (init_stage == 0) { init_stage ++; spawn_xterm(); } } break; case UnmapNotify: if (the_bar.tab_group.tab_count == 0) exit(0); break; case EnterNotify: set_focus(); break; default: break; } XFlush(gdi.display); }; return 0; }
void handle_event(XEvent *ev) { switch(ev->type){ CASE_EVENT(MapRequest) handle_map_request(&(ev->xmaprequest)); break; CASE_EVENT(ConfigureRequest) handle_configure_request(&(ev->xconfigurerequest)); break; CASE_EVENT(UnmapNotify) handle_unmap_notify(&(ev->xunmap)); break; CASE_EVENT(DestroyNotify) handle_destroy_notify(&(ev->xdestroywindow)); break; CASE_EVENT(ClientMessage) handle_client_message(&(ev->xclient)); break; CASE_EVENT(PropertyNotify) handle_property(&(ev->xproperty)); break; CASE_EVENT(FocusIn) handle_focus_in(&(ev->xfocus)); break; CASE_EVENT(FocusOut) handle_focus_out(&(ev->xfocus)); break; CASE_EVENT(EnterNotify) handle_enter_window(ev); break; CASE_EVENT(Expose) handle_expose(&(ev->xexpose)); break; CASE_EVENT(KeyPress) assert(wglobal.input_handler!=NULL); assert(wglobal.input_handler->keyboard!=NULL); wglobal.input_handler->keyboard(ev); break; CASE_EVENT(KeyRelease) assert(wglobal.input_handler!=NULL); assert(wglobal.input_handler->keyboard!=NULL); wglobal.input_handler->keyboard(ev); break; CASE_EVENT(ButtonPress) assert(wglobal.input_handler!=NULL); if(wglobal.input_handler->pointer!=NULL) wglobal.input_handler->pointer(ev); break; CASE_EVENT(ColormapNotify) handle_colormap_notify(&(ev->xcolormap)); break; CASE_EVENT(MappingNotify) XRefreshKeyboardMapping(&(ev->xmapping)); update_modmap(); break; CASE_EVENT(SelectionClear) clear_selection(); break; CASE_EVENT(SelectionNotify) receive_selection(&(ev->xselection)); break; CASE_EVENT(SelectionRequest) send_selection(&(ev->xselectionrequest)); break; } }