static void keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard) { struct keyboard *keyboard; const struct layout *layout; struct wl_input_panel_surface *ips; layout = get_current_layout(virtual_keyboard); keyboard = xzalloc(sizeof *keyboard); keyboard->keyboard = virtual_keyboard; keyboard->window = window_create_custom(virtual_keyboard->display); keyboard->widget = window_add_widget(keyboard->window, keyboard); virtual_keyboard->keyboard = keyboard; window_set_title(keyboard->window, "Virtual keyboard"); window_set_user_data(keyboard->window, keyboard); widget_set_redraw_handler(keyboard->widget, redraw_handler); widget_set_resize_handler(keyboard->widget, resize_handler); widget_set_button_handler(keyboard->widget, button_handler); window_schedule_resize(keyboard->window, layout->columns * key_width, layout->rows * key_height); ips = wl_input_panel_get_input_panel_surface(virtual_keyboard->input_panel, window_get_wl_surface(keyboard->window)); wl_input_panel_surface_set_toplevel(ips, output_get_wl_output(output), WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM); }
static void keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard) { struct keyboard *keyboard; keyboard = malloc(sizeof *keyboard); memset(keyboard, 0, sizeof *keyboard); keyboard->keyboard = virtual_keyboard; keyboard->window = window_create_custom(virtual_keyboard->display); keyboard->widget = window_add_widget(keyboard->window, keyboard); window_set_title(keyboard->window, "Virtual keyboard"); window_set_user_data(keyboard->window, keyboard); widget_set_redraw_handler(keyboard->widget, redraw_handler); widget_set_resize_handler(keyboard->widget, resize_handler); widget_set_button_handler(keyboard->widget, button_handler); window_schedule_resize(keyboard->window, columns * key_width, rows * key_height); input_panel_set_surface(virtual_keyboard->input_panel, window_get_wl_surface(keyboard->window), output_get_wl_output(output)); }
static struct ModeInfo * create_wscreensaver_instance(struct wscreensaver *screensaver, struct wl_output *output, int width, int height) { static int instance; struct ModeInfo *mi; struct rectangle drawarea; mi = calloc(1, sizeof *mi); if (!mi) return NULL; if (demo_mode) mi->window = window_create(screensaver->display); else mi->window = window_create_custom(screensaver->display); if (!mi->window) { fprintf(stderr, "%s: creating a window failed.\n", progname); free(mi); return NULL; } window_set_title(mi->window, progname); if (screensaver->interface && !demo_mode) { mi->widget = window_add_widget(mi->window, mi); screensaver_set_surface(screensaver->interface, window_get_wl_surface(mi->window), output); } else { mi->widget = frame_create(mi->window, mi); } widget_set_redraw_handler(mi->widget, redraw_handler); mi->priv = screensaver; mi->eglctx = EGL_NO_CONTEXT; mi->instance_number = instance++; /* XXX */ widget_get_allocation(mi->widget, &drawarea); mi->width = drawarea.width; mi->height = drawarea.height; screensaver->plugin->init(mi); window_schedule_resize(mi->window, width, height); return mi; }
int main(int argc, char *argv[]) { struct fullscreen fullscreen; struct display *d; int i; fullscreen.width = 640; fullscreen.height = 480; fullscreen.fullscreen = 0; fullscreen.present_method = _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT; wl_list_init(&fullscreen.output_list); fullscreen.current_output = NULL; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-w") == 0) { if (++i >= argc) usage(EXIT_FAILURE); fullscreen.width = atol(argv[i]); } else if (strcmp(argv[i], "-h") == 0) { if (++i >= argc) usage(EXIT_FAILURE); fullscreen.height = atol(argv[i]); } else if (strcmp(argv[i], "--help") == 0) usage(EXIT_SUCCESS); else usage(EXIT_FAILURE); } d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; } fullscreen.display = d; fullscreen.fshell = NULL; display_set_user_data(fullscreen.display, &fullscreen); display_set_global_handler(fullscreen.display, global_handler); display_set_output_configure_handler(fullscreen.display, output_handler); if (fullscreen.fshell) { fullscreen.window = window_create_custom(d); _wl_fullscreen_shell_present_surface(fullscreen.fshell, window_get_wl_surface(fullscreen.window), fullscreen.present_method, NULL); /* If we get the CURSOR_PLANE capability, we'll change this */ fullscreen.draw_cursor = 1; } else { fullscreen.window = window_create(d); fullscreen.draw_cursor = 0; } fullscreen.widget = window_add_widget(fullscreen.window, &fullscreen); window_set_title(fullscreen.window, "Fullscreen"); widget_set_transparent(fullscreen.widget, 0); widget_set_default_cursor(fullscreen.widget, CURSOR_LEFT_PTR); widget_set_redraw_handler(fullscreen.widget, redraw_handler); widget_set_button_handler(fullscreen.widget, button_handler); widget_set_motion_handler(fullscreen.widget, motion_handler); widget_set_enter_handler(fullscreen.widget, enter_handler); widget_set_touch_down_handler(fullscreen.widget, touch_handler); window_set_key_handler(fullscreen.window, key_handler); window_set_fullscreen_handler(fullscreen.window, fullscreen_handler); window_set_user_data(fullscreen.window, &fullscreen); /* Hack to set minimum allocation so we can shrink later */ window_schedule_resize(fullscreen.window, 1, 1); window_schedule_resize(fullscreen.window, fullscreen.width, fullscreen.height); display_run(d); return 0; }