static GdkFilterReturn filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { XEvent *x_event; x_event = (XEvent *) gdk_xevent; switch (x_event->type) { case KeyPress: if (popup == NULL && popup_keycode_to_free == -1) { popup_keycode_to_free = x_event->xkey.keycode; popup = popup_create (screen); } else { popup_on_key_press (popup, GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &x_event->xkey); } break; case KeyRelease: if (popup_keycode_to_free == x_event->xkey.keycode) { popup_keycode_to_free = -1; popup_free (popup); popup = NULL; } break; default: // No-op. break; } return GDK_FILTER_CONTINUE; }
gboolean superswitcher_show_popup (void *object, GError **error) { if (!popup) { popup = popup_create (screen); } return TRUE; }
static void handle_new_popup(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, new_popup); struct wlr_xdg_popup_v6 *wlr_popup = data; popup_create(wlr_popup, &xdg_shell_v6_view->view); }
static void popup_handle_new_popup(struct wl_listener *listener, void *data) { struct sway_xdg_popup_v6 *popup = wl_container_of(listener, popup, new_popup); struct wlr_xdg_popup_v6 *wlr_popup = data; popup_create(wlr_popup, popup->child.view); }
/** * Load the book interface. * @param data * Book's content. * @param len * Length of 'data'. */ void book_load(const char *data, int len) { SDL_Rect box; int pos; /* Nothing to do. */ if (!data || !len) { return; } /* Free old book data and reset the values. */ if (book_content != NULL) { efree(book_content); } book_lines = 0; book_scroll_lines = 0; book_scroll = 0; /* Store the data. */ book_content = estrdup(data); book_name_change("Book", 4); /* Strip trailing newlines. */ for (pos = len - 1; pos >= 0; pos--) { if (book_content[pos] != '\n') { break; } book_content[pos] = '\0'; } /* No data... */ if (book_content[0] == '\0') { return; } /* Calculate the line numbers. */ box.w = BOOK_TEXT_WIDTH; box.h = BOOK_TEXT_HEIGHT; text_show(NULL, FONT_ARIAL11, book_content, BOOK_TEXT_STARTX, BOOK_TEXT_STARTY, COLOR_WHITE, TEXT_WORD_WRAP | TEXT_MARKUP | TEXT_LINES_CALC, &box); book_lines = box.h; book_scroll_lines = box.y; /* Create the book popup if it doesn't exist yet. */ if (!popup_get_head() || popup_get_head()->texture != texture_get(TEXTURE_TYPE_CLIENT, "book")) { popup_struct *popup; popup = popup_create(texture_get(TEXTURE_TYPE_CLIENT, "book")); popup->draw_func = popup_draw_func; popup->draw_post_func = popup_draw_post_func; popup->event_func = popup_event_func; popup->destroy_callback_func = popup_destroy_callback; popup->clipboard_copy_func = popup_clipboard_copy_func; popup->disable_texture_drawing = 1; popup->button_left.x = 25; popup->button_left.y = 25; if (book_help_history_enabled) { popup->button_left.event_func = popup_button_event_func; popup_button_set_text(&popup->button_left, "<"); } popup->button_right.x = 649; popup->button_right.y = 25; } scrollbar_create(&scrollbar, BOOK_SCROLLBAR_WIDTH, BOOK_SCROLLBAR_HEIGHT, &book_scroll, &book_lines, book_scroll_lines); scrollbar.redraw = &popup_get_head()->redraw; popup_get_head()->redraw = 1; }