static void toggle_antialias(GtkWidget *menuitem, gpointer data) { VGUI.antialias=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)) ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE; cairo_set_antialias(VGUI.cr,VGUI.antialias); Keyboard_Buffer_push(''); // queue a redraw command notify_input(); }
static Bool canvas_configure_event(GtkWidget *widget, GdkEventConfigure *event) { GtkAllocation allocation; cairo_text_extents_t te; //printf("canvas_configure_event\n"); gtk_widget_get_allocation(widget,&allocation); vdevice.sizeX = 1; vdevice.sizeY = 1; vdevice.minVx = vdevice.minVy = 0; vdevice.maxVx = vdevice.sizeSx = allocation.width; vdevice.maxVy = vdevice.sizeSy = allocation.height; vdevice.depth = 3; if (VGUI.cr!=NULL) { cairo_destroy (VGUI.cr); cairo_surface_destroy (VGUI.surface); } VGUI.surface= gdk_window_create_similar_surface (gtk_widget_get_window (VGUI.canvas), CAIRO_CONTENT_COLOR, vdevice.sizeSx, vdevice.sizeSy); VGUI.cr = cairo_create(VGUI.surface); cairo_set_antialias(VGUI.cr,VGUI.antialias); my_set_font(VGUI.cr); cairo_text_extents (VGUI.cr, "A", &te); vdevice.hheight = te.height; vdevice.hwidth = te.x_advance; VGUI.line_width=1; //printf("vdevice address=%ld, vdevice.sizeSx=%d, vdevice.sizeSy=%d\n", (long)&vdevice, vdevice.sizeSx, vdevice.sizeSy); Keyboard_Buffer_push(''); // queue a redraw command notify_input(); return TRUE; }
/** * \brief Detects whether there were input events and if yes, handles them. */ void MainLoop::check_input() { // Check SDL events. std::unique_ptr<InputEvent> event = InputEvent::get_event(); while (event != nullptr) { notify_input(*event); event = InputEvent::get_event(); } // Check Lua requests. if (!lua_commands.empty()) { std::lock_guard<std::mutex> lock(lua_commands_mutex); for (const std::string& command : lua_commands) { std::cout << "\n"; // To make sure that the command delimiter starts on a new line. Logger::info("====== Begin Lua command #" + String::to_string(num_lua_commands_done) + " ======"); const bool success = LuaTools::do_string(get_lua_context().get_internal_state(), command, "Lua command"); if (success) { std::cout << "\n"; Logger::info("====== End Lua command #" + String::to_string(num_lua_commands_done) + ": success ======"); } else { std::cout << "\n"; Logger::info("====== End Lua command #" + String::to_string(num_lua_commands_done) + ": error ======"); } ++num_lua_commands_done; } lua_commands.clear(); } }
/** * \brief Detects whether there was an input event and if yes, handles it. */ void MainLoop::check_input() { InputEvent* event = InputEvent::get_event(); if (event != NULL) { notify_input(*event); delete event; } }
static Bool window_destroy_event(GtkWidget *windowp, gpointer data, GtkWidget *widget) { /* We don't want the default handler to be executed: */ g_signal_stop_emission_by_name(G_OBJECT(widget), "delete_event"); Keyboard_Buffer_push('X'); /* Queue an exit command */ notify_input(); return TRUE; }
/** * \brief Detects whether there were input events and if yes, handles them. */ void MainLoop::check_input() { std::unique_ptr<InputEvent> event = InputEvent::get_event(); while (event != nullptr) { notify_input(*event); event = InputEvent::get_event(); } }
static Bool button_press_event(GtkWidget *widget, GdkEventButton *event) { if (event->button>0) { VGUI.lastbutton=(1<<(event->button-1)); } notify_input(); //printf("Button: %d\n", VGUI.lastbutton); return TRUE; }
static void insert_key(GtkWidget *menuitem, gpointer data) { char *string=(char *)data; while (*string!='\0') { if (*string=='\n') { Keyboard_Buffer_push(RETKEY); string++; } else { Keyboard_Buffer_push(*string++); } } notify_input(); }
static Bool motion_notify_event(GtkWidget *widget, GdkEventMotion *event) { GdkModifierType state; if (event->is_hint) { gdk_window_get_device_position (event->window, event->device, &VGUI.lastx, &VGUI.lasty, &state); } else { VGUI.lastx = event->x; VGUI.lasty = event->y; state = event->state; } notify_input(); //printf("motion_notify_event: %d %d %d\n", VGUI.lastbutton, VGUI.lastx, VGUI.lasty); return FALSE; }
/* Parse input. */ void input_parse(struct window_pane *wp) { struct input_ctx *ictx = &wp->ictx; const struct input_transition *itr; struct evbuffer *evb = wp->event->input; u_char *buf; size_t len, off; if (EVBUFFER_LENGTH(evb) == 0) return; wp->window->flags |= WINDOW_ACTIVITY; wp->window->flags &= ~WINDOW_SILENCE; /* * Open the screen. Use NULL wp if there is a mode set as don't want to * update the tty. */ if (wp->mode == NULL) screen_write_start(&ictx->ctx, wp, &wp->base); else screen_write_start(&ictx->ctx, NULL, &wp->base); ictx->wp = wp; buf = EVBUFFER_DATA(evb); len = EVBUFFER_LENGTH(evb); notify_input(wp, evb); off = 0; /* Parse the input. */ while (off < len) { ictx->ch = buf[off++]; log_debug("%s: '%c' %s", __func__, ictx->ch, ictx->state->name); /* Find the transition. */ itr = ictx->state->transitions; while (itr->first != -1 && itr->last != -1) { if (ictx->ch >= itr->first && ictx->ch <= itr->last) break; itr++; } if (itr->first == -1 || itr->last == -1) { /* No transition? Eh? */ fatalx("No transition from state!"); } /* * Execute the handler, if any. Don't switch state if it * returns non-zero. */ if (itr->handler != NULL && itr->handler(ictx) != 0) continue; /* And switch state, if necessary. */ if (itr->state != NULL) input_set_state(wp, itr); /* If not in ground state, save input. */ if (ictx->state != &input_state_ground) evbuffer_add(ictx->since_ground, &ictx->ch, 1); } /* Close the screen. */ screen_write_stop(&ictx->ctx); evbuffer_drain(evb, len); }
static Bool key_press_event(GtkWidget *widget, GdkEventKey *event) { if (event->length==1) { //printf("Key pressed: >%s<\n", event->string); Keyboard_Buffer_push(*event->string); } else { char keysym='\0'; //printf("Key without string: value %d, state %d->shift %d\n", event->keyval, event->state, (event->state&GDK_SHIFT_MASK)); switch(event->keyval) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: keysym=RETKEY; break; case GDK_KEY_BackSpace: keysym=BACKSPACEKEY; break; case GDK_KEY_Home: keysym='c'; break; case GDK_KEY_Left: if (event->state&GDK_CONTROL_MASK) { keysym=((event->state&GDK_SHIFT_MASK) ? 'H' : 'h'); } else { keysym='I'; } break; case GDK_KEY_Right: if (event->state&GDK_CONTROL_MASK) { keysym=((event->state&GDK_SHIFT_MASK) ? 'L' : 'l'); } else { keysym='i'; } break; case GDK_KEY_Down: if (event->state&GDK_CONTROL_MASK) { keysym=((event->state&GDK_SHIFT_MASK) ? 'J' : 'j'); } else { keysym=')'; } break; case GDK_KEY_Up: if (event->state&GDK_CONTROL_MASK) { keysym=((event->state&GDK_SHIFT_MASK) ? 'K' : 'k'); } else { keysym='('; } break; case GDK_KEY_Page_Up: keysym='('; break; case GDK_KEY_Page_Down: keysym=')'; break; case GDK_KEY_KP_Left: keysym='t'; break; case GDK_KEY_KP_Right: keysym='T'; break; case GDK_KEY_KP_Up: keysym='+'; break; case GDK_KEY_KP_Down: keysym='-'; break; case GDK_KEY_KP_Home: keysym='['; break; case GDK_KEY_KP_End: keysym=']'; break; case GDK_KEY_KP_Add: keysym='i'; break; case GDK_KEY_KP_Subtract: keysym='I'; break; case GDK_KEY_KP_Multiply: keysym='m'; break; case GDK_KEY_KP_Page_Up: keysym='}'; break; case GDK_KEY_KP_Page_Down: keysym='{'; break; default: break; } if (keysym!='\0') Keyboard_Buffer_push(keysym); } notify_input(); return TRUE; }