/* ** Description ** Handle selected menu entry ** ** 1999-01-10 CG */ static WORD handle_menu (WORD * buffert) { switch (buffert[3]) { case MENU_FILE : switch (buffert[4]) { case MENU_LAUNCHAPP : launch_application (); break; case MENU_QUIT : return TRUE; default : fprintf (stderr, "launcher.c: handle_menu: unknown MENU_FILE entry %d\n", buffert[4]); } break; /* MENU_FILE */ case MENU_OAESIS : switch (buffert[4]) { case MENU_INFO : show_information (); break; default : fprintf (stderr, "launcher.c: handle_menu: unknown MENU_OAESIS entry %d\n", buffert[4]); } break; /* MENU_OAESIS */ default : fprintf (stderr, "launcher.c: handle_menu: unknown menu title %d\n", buffert[3]); } return FALSE; }
static void wallpaper_check_click(struct yutani_msg_window_mouse_event * evt) { if (evt->command == YUTANI_MOUSE_EVENT_CLICK) { printf("Click!\n"); if (evt->new_x > ICON_X && evt->new_x < ICON_X + ICON_WIDTH) { uint32_t i = 0; while (1) { if (!applications[i].icon) { break; } if ((evt->new_y > ICON_TOP_Y + ICON_SPACING_Y * i) && (evt->new_y < ICON_TOP_Y + ICON_SPACING_Y + ICON_SPACING_Y * i)) { printf("Launching application \"%s\"...\n", applications[i].title); launch_application(applications[i].appname); } ++i; } /* Within the icon range */ } } else if (evt->command == YUTANI_MOUSE_EVENT_MOVE || evt->command == YUTANI_MOUSE_EVENT_ENTER) { if (evt->new_x > 0 && evt->new_x < ICON_X + ICON_WIDTH + EXTRA_WIDTH) { uint32_t i = 0; while (1) { if (!applications[i].icon) { set_focused(-1); break; } if ((evt->new_y > ICON_TOP_Y + ICON_SPACING_Y * i) && (evt->new_y < ICON_TOP_Y + ICON_SPACING_Y + ICON_SPACING_Y * i)) { set_focused(i); break; } ++i; } /* Within the icon range */ } else { set_focused(-1); } } else if (evt->command == YUTANI_MOUSE_EVENT_LEAVE) { set_focused(-1); } }
int main (int argc, char ** argv) { setup_windowing(); int width = wins_globals->server_width; int height = wins_globals->server_height; win_width = width; win_height = height; event_pipe = syscall_mkpipe(); /* Do something with a window */ window_t * wina = window_create(0,0, width, height); assert(wina); window_reorder (wina, 0); ctx = init_graphics_window_double_buffer(wina); draw_fill(ctx, rgb(127,127,127)); flip(ctx); syscall_signal(2, sig_int); char f_name[512]; sprintf(f_name, "%s/.wallpaper.png", getenv("HOME")); FILE * f = fopen(f_name, "r"); if (f) { fclose(f); init_sprite_png(0, f_name); } else { init_sprite_png(0, "/usr/share/wallpaper.png"); } float x = (float)width / (float)sprites[0]->width; float y = (float)height / (float)sprites[0]->height; int nh = (int)(x * (float)sprites[0]->height); int nw = (int)(y * (float)sprites[0]->width);; if (nw > width) { draw_sprite_scaled(ctx, sprites[0], (width - nw) / 2, 0, nw, height); } else { draw_sprite_scaled(ctx, sprites[0], 0, (height - nh) / 2, width, nh); } flip(ctx); init_shmemfonts(); /* Load Application Shortcuts */ uint32_t i = 0; while (1) { if (!applications[i].icon) { break; } printf("Loading png %s\n", applications[i].icon); init_sprite_png(i+1, applications[i].icon); draw_sprite(ctx, sprites[i+1], ICON_X, ICON_TOP_Y + ICON_SPACING_Y * i); int str_w = draw_string_width(applications[i].title) / 2; int str_x = ICON_X + ICON_WIDTH / 2 - str_w; int str_y = ICON_TOP_Y + ICON_SPACING_Y * i + ICON_WIDTH + 14; draw_string_shadow(ctx, str_x, str_y, rgb(255,255,255), applications[i].title, rgb(0,0,0), 2, 1, 1, 3.0); ++i; } flip(ctx); /* Enable mouse */ win_use_threaded_handler(); mouse_action_callback = wallpaper_check_click; while (_continue) { char buf; read(event_pipe, &buf, 1); if (next_run_activate) { launch_application(next_run_activate); next_run_activate = NULL; } } teardown_windowing(); return 0; }