static void view_paint(struct ctx *context, struct wlc_view *view) { assert(context && view); struct wlc_surface *surface; if (!(surface = convert_from_wlc_resource(view->surface, "surface"))) return; struct paint settings; memset(&settings, 0, sizeof(settings)); settings.dim = ((view->commit.state & WLC_BIT_ACTIVATED) || (view->type & (WLC_BIT_UNMANAGED|WLC_BIT_SPLASH|WLC_BIT_OVERRIDE_REDIRECT)) ? 1.0f : DIM); settings.program = (enum program_type)surface->format; struct wlc_geometry geometry; wlc_view_get_bounds(view, &geometry, &settings.visible); surface_paint_internal(context, surface, &geometry, &settings); if (DRAW_OPAQUE) { wlc_view_get_opaque(view, &geometry); settings.visible = geometry; settings.program = PROGRAM_CURSOR; GL_CALL(glBlendFunc(GL_ONE, GL_DST_COLOR)); texture_paint(context, &context->textures[TEXTURE_BLACK], 1, &geometry, &settings); GL_CALL(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); } }
void wlc_view_get_input(struct wlc_view *view, struct wlc_geometry *out_input) { assert(view && out_input); struct wlc_geometry b, v; wlc_view_get_bounds(view, &b, &v); wlc_surface_get_input(convert_from_wlc_resource(view->surface, "surface"), &v.origin, out_input); }
bool wlc_view_get_opaque(struct wlc_view *view, struct wlc_geometry *out_opaque) { assert(view && out_opaque); struct wlc_geometry b, v; wlc_view_get_bounds(view, &b, &v); return wlc_surface_get_opaque(convert_from_wlc_resource(view->surface, "surface"), &v.origin, out_opaque); }
WLC_API void wlc_view_get_visible_geometry(wlc_handle view, struct wlc_geometry *out_geometry) { assert(out_geometry); struct wlc_view *v; if (!(v = convert_from_wlc_handle(view, "view"))) return; wlc_view_get_bounds(v, out_geometry, NULL); }
void wlc_view_commit_state(struct wlc_view *view, struct wlc_view_state *pending, struct wlc_view_state *out) { assert(view && pending && out); struct wlc_surface *surface; if (!(surface = convert_from_wlc_resource(view->surface, "surface"))) return; // FIXME: handle ping #if 0 struct wl_resource *r; if (view->shell_surface && (r = wl_resource_from_wlc_resource(view->shell_surface, "shell-surface"))) wl_shell_surface_send_ping(r, wl_display_next_serial(wlc_display())); wlc_dlog(WLC_DBG_COMMIT, "=> ping view %" PRIuWLC, convert_to_wlc_handle(view)); return; #endif if (!view->state.created) { // Initial size of the view view->pending.geometry.size = surface->size; view->state.created = true; if (WLC_INTERFACE_EMIT_EXCEPT(view.created, false, convert_to_wlc_handle(view))) { wlc_view_close_ptr(view); return; } } if (!memcmp(pending, out, sizeof(struct wlc_view_state))) return; if (pending->state != out->state) { const struct { enum wlc_view_state_bit bit; uint32_t state; } map[] = { { WLC_BIT_MAXIMIZED, XDG_SURFACE_STATE_MAXIMIZED }, { WLC_BIT_FULLSCREEN, XDG_SURFACE_STATE_FULLSCREEN }, { WLC_BIT_RESIZING, XDG_SURFACE_STATE_RESIZING }, { WLC_BIT_ACTIVATED, XDG_SURFACE_STATE_ACTIVATED }, }; chck_iter_pool_flush(&view->wl_state); for (uint32_t i = 0; i < LENGTH(map); ++i) { if (pending->state & map[i].bit) chck_iter_pool_push_back(&view->wl_state, &map[i].state); } } const bool size_changed = (!wlc_size_equals(&pending->geometry.size, &out->geometry.size) || !wlc_size_equals(&pending->geometry.size, &surface->size)); wlc_dlog(WLC_DBG_COMMIT, "=> pending view commit %" PRIuWLC " (%d) pending: %ux%u commited: %ux%u surface: %ux%u", convert_to_wlc_handle(view), size_changed, pending->geometry.size.w, pending->geometry.size.h, out->geometry.size.w, out->geometry.size.h, surface->size.w, surface->size.h); if (pending->state != out->state || size_changed) configure_view(view, pending->edges, &pending->geometry); *out = *pending; struct wlc_geometry geom, visible; wlc_view_get_bounds(view, &geom, &visible); surface_tree_update_coordinate_transform(surface, &visible); wlc_dlog(WLC_DBG_COMMIT, "=> commit view %" PRIuWLC, convert_to_wlc_handle(view)); }