chiark / gitweb /
terminal: add unifont_get_width/height()
[elogind.git] / src / libsystemd-terminal / grdev.c
index c5ea524c69fd725990977f9e55bb4856527c4981..aaac06ec3435eddd9c609cdfc6ad1b5a7723ae11 100644 (file)
@@ -158,6 +158,7 @@ int grdev_tile_new_leaf(grdev_tile **out, grdev_pipe *pipe) {
         _cleanup_(grdev_tile_freep) grdev_tile *tile = NULL;
         int r;
 
+        assert_return(out, -EINVAL);
         assert_return(pipe, -EINVAL);
         assert_return(!pipe->tile, -EINVAL);
 
@@ -300,6 +301,18 @@ const char *grdev_display_get_name(grdev_display *display) {
         return display->name;
 }
 
+uint32_t grdev_display_get_width(grdev_display *display) {
+        assert_return(display, 0);
+
+        return display->width;
+}
+
+uint32_t grdev_display_get_height(grdev_display *display) {
+        assert_return(display, 0);
+
+        return display->height;
+}
+
 bool grdev_display_is_enabled(grdev_display *display) {
         return display && display->enabled;
 }
@@ -345,7 +358,7 @@ const grdev_display_target *grdev_display_next_target(grdev_display *display, co
                 assert(cache->pipe->tile->display == display);
                 assert(display->pipes >= cache);
 
-                idx = (cache - display->pipes) / sizeof(*cache) + 1;
+                idx = cache - display->pipes + 1;
         } else {
                 idx = 0;
         }
@@ -571,6 +584,8 @@ static bool display_cache(grdev_display *display) {
         }
 
         display_cache_targets(display);
+        display->width = display->tile->cache_w;
+        display->height = display->tile->cache_h;
 
         r = 0;