Пример #1
0
Файл: view.c Проект: snells/wlc
void
wlc_view_get_bounds(struct wlc_view *view, struct wlc_geometry *out_bounds, struct wlc_geometry *out_visible)
{
   assert(view && out_bounds);
   memcpy(out_bounds, &view->commit.geometry, sizeof(struct wlc_geometry));

   struct wlc_surface *surface;
   if (!(surface = convert_from_wlc_resource(view->surface, "surface")))
      return;

   if (should_be_transformed_by_parent(view)) {
      for (struct wlc_view *parent = convert_from_wlc_handle(view->parent, "view"); parent; parent = convert_from_wlc_handle(parent->parent, "view")) {
         out_bounds->origin.x += parent->commit.geometry.origin.x;
         out_bounds->origin.y += parent->commit.geometry.origin.y;
      }
   }

   if (view->xdg_surface && view->commit.visible.size.w > 0 && view->commit.visible.size.h > 0) {
      // xdg-surface client that draws drop shadows or other stuff.
      // Only obey visible hints when not maximized or fullscreen.
      if (!(view->commit.state & WLC_BIT_MAXIMIZED) && !(view->commit.state & WLC_BIT_FULLSCREEN)) {
         out_bounds->origin.x -= view->commit.visible.origin.x;
         out_bounds->origin.y -= view->commit.visible.origin.y;

         // Make sure size is at least what we want, but may be bigger (shadows etc...)
         out_bounds->size.w = chck_maxu32(surface->size.w, view->commit.geometry.size.w);
         out_bounds->size.h = chck_maxu32(surface->size.h, view->commit.geometry.size.h);
      }
   }

   // Make sure bounds is never 0x0 w/h
   wlc_size_max(&out_bounds->size, &(struct wlc_size){ 1, 1 }, &out_bounds->size);
Пример #2
0
void
wlc_view_ack_surface_attach(struct wlc_view *view, struct wlc_surface *surface)
{
   assert(view && surface);

   if (view->x11.id) {
      surface->pending.opaque.extents = (pixman_box32_t){ 0, 0, surface->size.w, surface->size.h };
      view->surface_pending.visible = (struct wlc_geometry){ wlc_origin_zero, surface->size };
   }

   const bool resizing = (view->pending.state & WLC_BIT_RESIZING || view->commit.state & WLC_BIT_RESIZING);
   if (!resizing && !wlc_geometry_equals(&view->surface_pending.visible, &view->surface_commit.visible)) {
      struct wlc_geometry g = (struct wlc_geometry){ view->pending.geometry.origin, view->surface_pending.visible.size };
      wlc_view_request_geometry(view, &g);
   }

   view->surface_commit = view->surface_pending;
   wlc_dlog(WLC_DBG_COMMIT, "=> surface view %" PRIuWLC, convert_to_wlc_handle(view));
}

static bool
should_be_transformed_by_parent(struct wlc_view *view)
{
   return !(view->type & WLC_BIT_OVERRIDE_REDIRECT) && !(view->type & WLC_BIT_UNMANAGED);
}

void
wlc_view_get_bounds(struct wlc_view *view, struct wlc_geometry *out_bounds, struct wlc_geometry *out_visible)
{
   assert(view && out_bounds && out_bounds != out_visible);
   memcpy(out_bounds, &view->commit.geometry, sizeof(struct wlc_geometry));

   struct wlc_surface *surface;
   if (!(surface = convert_from_wlc_resource(view->surface, "surface")))
      return;

   if (should_be_transformed_by_parent(view)) {
      for (struct wlc_view *parent = convert_from_wlc_handle(view->parent, "view"); parent; parent = convert_from_wlc_handle(parent->parent, "view")) {
         out_bounds->origin.x += parent->commit.geometry.origin.x;
         out_bounds->origin.y += parent->commit.geometry.origin.y;
      }
   }

   if (view->xdg_surface && view->surface_commit.visible.size.w > 0 && view->surface_commit.visible.size.h > 0) {
      // xdg-surface client that draws drop shadows or other stuff.
      out_bounds->origin.x -= view->surface_commit.visible.origin.x;
      out_bounds->origin.y -= view->surface_commit.visible.origin.y;
      out_bounds->size.w += surface->size.w - view->surface_commit.visible.size.w;
      out_bounds->size.h += surface->size.h - view->surface_commit.visible.size.h;
   }

   // Make sure bounds is never 0x0 w/h
   wlc_size_max(&out_bounds->size, &(struct wlc_size){ 1, 1 }, &out_bounds->size);