Browse Source

Decorator can handle checking for menus

K. Lange 2 years ago
parent
commit
03d6199af7
6 changed files with 16 additions and 27 deletions
  1. 3 1
      apps/about.c
  2. 2 8
      apps/file-browser.c
  3. 2 8
      apps/help-browser.c
  4. 5 1
      apps/julia.c
  5. 1 6
      apps/terminal.c
  6. 3 3
      lib/decorations.c

+ 3 - 1
apps/about.c

@@ -132,7 +132,9 @@ int main(int argc, char * argv[]) {
 	while (playing) {
 		yutani_msg_t * m = yutani_poll(yctx);
 		while (m) {
-			menu_process_event(yctx, m);
+			if (menu_process_event(yctx, m)) {
+				redraw();
+			}
 			switch (m->type) {
 				case YUTANI_MSG_KEY_EVENT:
 					{

+ 2 - 8
apps/file-browser.c

@@ -125,7 +125,6 @@ int main(int argc, char * argv[]) {
 		yutani_msg_t * m = yutani_poll(yctx);
 		while (m) {
 			if (menu_process_event(yctx, m)) {
-				main_window->focused = 0;
 				redraw_window();
 			}
 			switch (m->type) {
@@ -142,13 +141,8 @@ int main(int argc, char * argv[]) {
 						struct yutani_msg_window_focus_change * wf = (void*)m->data;
 						yutani_window_t * win = hashmap_get(yctx->windows, (void*)wf->wid);
 						if (win == main_window) {
-							if (!hashmap_is_empty(menu_get_windows_hash())) {
-								win->focused = 1;
-								redraw_window();
-							} else {
-								win->focused = wf->focused;
-								redraw_window();
-							}
+							win->focused = wf->focused;
+							redraw_window();
 						}
 					}
 					break;

+ 2 - 8
apps/help-browser.c

@@ -116,7 +116,6 @@ int main(int argc, char * argv[]) {
 		yutani_msg_t * m = yutani_poll(yctx);
 		while (m) {
 			if (menu_process_event(yctx, m)) {
-				main_window->focused = 0;
 				redraw_window();
 			}
 			switch (m->type) {
@@ -133,13 +132,8 @@ int main(int argc, char * argv[]) {
 						struct yutani_msg_window_focus_change * wf = (void*)m->data;
 						yutani_window_t * win = hashmap_get(yctx->windows, (void*)wf->wid);
 						if (win == main_window) {
-							if (!hashmap_is_empty(menu_get_windows_hash())) {
-								win->focused = 1;
-								redraw_window();
-							} else {
-								win->focused = wf->focused;
-								redraw_window();
-							}
+							win->focused = wf->focused;
+							redraw_window();
 						}
 					}
 					break;

+ 5 - 1
apps/julia.c

@@ -258,7 +258,11 @@ int main(int argc, char * argv[]) {
 	while (playing) {
 		yutani_msg_t * m = yutani_poll(yctx);
 		while (m) {
-			menu_process_event(yctx, m);
+			if (menu_process_event(yctx, m)) {
+				/* just decorations should be fine */
+				decors();
+				yutani_flip(yctx, window);
+			}
 			switch (m->type) {
 				case YUTANI_MSG_KEY_EVENT:
 					{

+ 1 - 6
apps/terminal.c

@@ -1587,7 +1587,6 @@ void * handle_incoming(void) {
 	yutani_msg_t * m = yutani_poll(yctx);
 	while (m) {
 		if (menu_process_event(yctx, m)) {
-			window->focused = 0;
 			render_decors();
 		}
 		switch (m->type) {
@@ -1603,11 +1602,7 @@ void * handle_incoming(void) {
 					struct yutani_msg_window_focus_change * wf = (void*)m->data;
 					yutani_window_t * win = hashmap_get(yctx->windows, (void*)wf->wid);
 					if (win == window) {
-						if (!hashmap_is_empty(menu_get_windows_hash())) {
-							win->focused = 1;
-						} else {
-							win->focused = wf->focused;
-						}
+						win->focused = wf->focused;
 						render_decors();
 					}
 				}

+ 3 - 3
lib/decorations.c

@@ -96,10 +96,10 @@ static void initialize_simple() {
 void render_decorations(yutani_window_t * window, gfx_context_t * ctx, char * title) {
 	if (!window) return;
 	window->decorator_flags |= DECOR_FLAG_DECORATED;
-	if (!window->focused) {
-		decor_render_decorations(window, ctx, title, DECOR_INACTIVE);
-	} else {
+	if (window->focused || !hashmap_is_empty(menu_get_windows_hash())) {
 		decor_render_decorations(window, ctx, title, DECOR_ACTIVE);
+	} else {
+		decor_render_decorations(window, ctx, title, DECOR_INACTIVE);
 	}
 }