summary refs log tree commit diff
path: root/main.c
diff options
context:
space:
mode:
authorArenM <aren@peacevolution.org>2022-07-05 12:54:33 -0400
committerZach DeCook <zachdecook@librem.one>2022-07-11 00:59:10 -0400
commit6566a7f57d695d888650d43225844f9641414919 (patch)
treebd41dae2b3add5810e7b2dbf146667a5e402f0d9 /main.c
parent1c4df6ae2b9c94feb6b65e616520275b645bfa5c (diff)
downloadsuggpicker-6566a7f57d695d888650d43225844f9641414919.tar.gz
only commit surface when it changed
This is based off of a commit in wvkbd

Previously wvkbd (and suggpicker) would commit a (usually unchanged) surface at the framerate of the compositor,
this only commits the buffer when we render something new.
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/main.c b/main.c
index 311c4e9..563baae 100644
--- a/main.c
+++ b/main.c
@@ -307,6 +307,8 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
 	}
 
 	zwlr_layer_surface_v1_ack_configure(surface, serial);
+
+	drwsurf_flip(&draw_surf);
 }
 
 void
@@ -339,10 +341,6 @@ hide(int sigint) {
 	zwlr_layer_surface_v1_destroy(layer_surface);
 	wl_surface_destroy(draw_surf.surf);
 	layer_surface = NULL;
-	if (draw_surf.cb) {
-		wl_callback_destroy(draw_surf.cb);
-		draw_surf.cb = NULL;
-	}
 }
 
 void
@@ -399,6 +397,7 @@ handle_input(FILE *fd, struct key *sugg, struct kbd *kb) {
 		key->label = NULL;
 		kbd_init_suggs(sugg, kb->w, kb->h);
 		kbd_draw_layout(kb);
+		drwsurf_flip(kb->surf);
 	}
 
 	free(line);
@@ -506,9 +505,9 @@ main(int argc, char **argv) {
 		while(layer_surface && poll(fds, 2, -1) != -1) {
 			if (fds[0].revents & POLLIN) {
 				handle_input(stdin, keyboard.suggs, &keyboard);
-			}
-			if (wl_display_dispatch(display) == -1) {
-				break;
+			} else if(fds[1].revents & POLLIN) {
+				//error check?
+				wl_display_dispatch(display);
 			}
 			wl_display_flush(display);
 		}