Browse Source

Pass a requested center coordinate to 'about'

K. Lange 2 years ago
parent
commit
d37d5fc16f
4 changed files with 28 additions and 4 deletions
  1. 10 1
      apps/about.c
  2. 6 1
      apps/file-browser.c
  3. 6 1
      apps/help-browser.c
  4. 6 1
      apps/terminal.c

+ 10 - 1
apps/about.c

@@ -78,11 +78,13 @@ static void init_default(void) {
 }
 
 int main(int argc, char * argv[]) {
+	int req_center_x, req_center_y;
 	yctx = yutani_init();
 	init_decorations();
 
 	window = yutani_window_create(yctx, width + decor_width(), height + decor_height());
-	yutani_window_move(yctx, window, yctx->display_width / 2 - window->width / 2, yctx->display_height / 2 - window->height / 2);
+	req_center_x = yctx->display_width / 2;
+	req_center_y = yctx->display_height / 2;
 
 	if (argc < 2) {
 		init_default();
@@ -105,8 +107,15 @@ int main(int argc, char * argv[]) {
 				me = end+1;
 			}
 		} while (end);
+
+		if (argc > 6) {
+			req_center_x = atoi(argv[5]);
+			req_center_y = atoi(argv[6]);
+		}
 	}
 
+	yutani_window_move(yctx, window, req_center_x - window->width / 2, req_center_y - window->height / 2);
+
 	yutani_window_advertise_icon(yctx, window, title_str, "star");
 
 	ctx = init_graphics_yutani_double_buffer(window);

+ 6 - 1
apps/file-browser.c

@@ -75,7 +75,12 @@ static void _menu_action_help(struct MenuEntry * entry) {
 static void _menu_action_about(struct MenuEntry * entry) {
 	/* Show About dialog */
 	if (!fork()) {
-		system("about \"About File Browser\" /usr/share/icons/48/folder.bmp \"ToaruOS File Browser\" \"(C) 2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\"");
+		char about_cmd[1024] = "\0";
+		strcat(about_cmd, "about \"About File Browser\" /usr/share/icons/48/folder.bmp \"ToaruOS File Browser\" \"(C) 2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\" ");
+		char coords[100];
+		sprintf(coords, "%d %d", (int)main_window->x + (int)main_window->width / 2, (int)main_window->y + (int)main_window->height / 2);
+		strcat(about_cmd, coords);
+		system(about_cmd);
 		exit(0);
 	}
 	redraw_window();

+ 6 - 1
apps/help-browser.c

@@ -66,7 +66,12 @@ static void _menu_action_forward(struct MenuEntry * entry) {
 static void _menu_action_about(struct MenuEntry * entry) {
 	/* Show About dialog */
 	if (!fork()) {
-		system("about \"About Help Browser\" /usr/share/icons/48/help.bmp \"ToaruOS Help Browser\" \"(C) 2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\"");
+		char about_cmd[1024] = "\0";
+		strcat(about_cmd, "about \"About Help Browser\" /usr/share/icons/48/help.bmp \"ToaruOS Help Browser\" \"(C) 2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\" ");
+		char coords[100];
+		sprintf(coords, "%d %d", (int)main_window->x + (int)main_window->width / 2, (int)main_window->y + (int)main_window->height / 2);
+		strcat(about_cmd, coords);
+		system(about_cmd);
 		exit(0);
 	}
 	redraw_window();

+ 6 - 1
apps/terminal.c

@@ -1794,7 +1794,12 @@ void _menu_action_hide_borders(struct MenuEntry * self) {
 
 void _menu_action_show_about(struct MenuEntry * self) {
 	if (!fork()) {
-		system("about \"About Terminal\" /usr/share/icons/48/utilities-terminal.bmp \"ToaruOS Terminal\" \"(C) 2013-2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\"");
+		char about_cmd[1024] = "\0";
+		strcat(about_cmd, "about \"About Terminal\" /usr/share/icons/48/utilities-terminal.bmp \"ToaruOS Terminal\" \"(C) 2013-2018 K. Lange\n-\nPart of ToaruOS, which is free software\nreleased under the NCSA/University of Illinois\nlicense.\n-\n%https://toaruos.org\n%https://github.com/klange/toaru-nih\" ");
+		char coords[100];
+		sprintf(coords, "%d %d", (int)window->x + (int)window->width / 2, (int)window->y + (int)window->height / 2);
+		strcat(about_cmd, coords);
+		system(about_cmd);
 		exit(0);
 	}
 	render_decors();