Esempio n. 1
0
        void button::draw()
        {
            color old_fg = get_foreground();
            color old_bg = get_background();

            if (down_tick)
            {
                if ((SDL_GetTicks() - down_tick) < 100)
                {
                    get_foreground() = old_bg;
                    get_background() = old_fg;
                }
                else
                {
                    down_tick = 0;
                }
            }

            textbox::draw();

            // border
            display::scoped_color fg(get_screen(), get_foreground());
            get_screen().draw_line_2d(0, 0, get_w(), 0);
            get_screen().draw_line_2d(get_w(), 0, get_w(), get_h());
            get_screen().draw_line_2d(get_w(), get_h(), 0, get_h());
            get_screen().draw_line_2d(0, get_h(), 0, 0);

            if (down_tick)
            {
                get_foreground() = old_fg;
                get_background() = old_bg;
            }
        } // button::draw()
Esempio n. 2
0
        void widget::draw()
        {
            display::scoped_state state(get_screen(), display::ENABLE_ORTHO_2D);
            display::scoped_color bg(get_screen(), get_background());
            display::scoped_texture t(get_screen(), tex);

            get_screen().draw_rect_2d(0, 0, static_cast<float>(w), static_cast<float>(h));
        } // widget::draw()
Esempio n. 3
0
int
main(int argc, char **argv)
{
	int listmask = 0, rootflag = 0;

	ARGBEGIN {
		case 'a': listmask |= LIST_ALL; break;
		case 'u': listmask |= LIST_HIDDEN; break;
		case 'o': listmask |= LIST_IGNORE; break;
		case 'r': rootflag = 1; break;
		default : usage();
	} ARGEND;

	init_xcb(&conn);
	get_screen(conn, &scrn);

	if (rootflag == 1) {
		printf("0x%08x\n", scrn->root);
		return 0;
	}

	if (argc == 0)
		list_windows(scrn->root, listmask);

	while (*argv)
		list_windows(strtoul(*argv++, NULL, 16), listmask);

	kill_xcb(&conn);

	return 0;
}
Esempio n. 4
0
int
main(int argc, char **argv)
{
	int x, y, mode = RELATIVE;
	if (argc < 4)
		usage(argv[0]);

	init_xcb(&conn);
	get_screen(conn, &scr);

	if (argv[1][0] == '-' && argv[1][1] == 'a') {
		mode = ABSOLUTE;
		argv++;
	}

	x = atoi(*(++argv));
	y = atoi(*(++argv));

	while (*argv)
		move(strtoul(*argv++, NULL, 16), mode, x, y);

	xcb_flush(conn);

	kill_xcb(&conn);

	return 0;
}
Esempio n. 5
0
File: wew.c Progetto: laserswald/opt
int
main (int argc, char **argv)
{

	char *argv0;

	ARGBEGIN {
		case 'l':
			list_events();
			exit(0);
		case 'm':
			  mask = strtoul(EARGF(usage(argv0)), NULL, 10);
			  break;
		default: usage(argv0);
	} ARGEND;

	init_xcb(&conn);
	get_screen(conn, &scr);

	handle_events();

	kill_xcb(&conn);

	return 0;
}
Esempio n. 6
0
int
main(int argc, char **argv)
{
    char ch = 0; // character pressed
    int wn = 0;  // number of windows
    
    // Setup connection to X and grab screen
    init_xcb(&conn);
    get_screen(conn, &scrn);

    // Get a list of windows via _NET_CLIENT_LIST of the root screen
    wn = client_list(scrn->root, &ws);

    // Save original stdin settings into torig
    if (-1 == tcgetattr(0, &torig)) {
	perror("tcgetattr");
	return -1;
    }
    
    // Unbuffer terminal input to watch for key presses
    if (unbuf_stdin()) {
	perror("can't unbuffer terminal");
	return -1;
    }

    // Invocation: start window selection at zero, or the first window
    cycle_selection(0, wn, ws, 0);
    
    // Cycle window selection forward when TAB or j is press and
    // backwards when ` or k is pressed. Return activates window.
    while (1) {
	ch = fgetc(stdin);
	switch (ch) {
	case '\t':
	    cycle_selection(NEXT, wn, ws, 0);
	    break;
	case 'j':
	    cycle_selection(NEXT, wn, ws, 0);
	    break;
	case '`':
	    cycle_selection(PREV, wn, ws, 0);
	    break;
	case 'k':
	    cycle_selection(PREV, wn, ws, 0);
	    break;
	case 'q':
	    cleanup();
	    return 0;
	case '\r':
	    cycle_selection(0, wn, ws, 1);
	    cleanup();
	    return 0;
	}
    }
}
/**
 * Checks to see if the display supports alpha channels
 */
void TransparentSlider::on_screen_changed(const Glib::RefPtr<Gdk::Screen>& previous_screen) {
	auto screen = get_screen();
    auto visual = screen->get_rgba_visual();

    if (!visual) {
    	std::cout << "Transparency is not supported." << std::endl;
    } else {
        std::cout << "Transparency is supported." << std::endl;
        _SUPPORTS_ALPHA = TRUE;
    }

    set_visual(visual);
}
Esempio n. 8
0
bool check_input ()
{
	if (_switch == OSD_SWITCH_OFF || !telemetry::input::connected) return false;

	uint8_t old_screen = cur_screen;

	cur_screen = _switch == OSD_SWITCH_FLIGHT_MODE
		? telemetry::input::flight_mode_switch
		: get_screen (telemetry::input::channels [_channel]);

	if (cur_screen >= _screens_enabled) cur_screen = _screens_enabled - 1;

	return cur_screen != old_screen;
}
Esempio n. 9
0
xcb_randr_get_output_primary_reply_t *
get_primary_output(xcb_connection_t * conn)
{
	xcb_screen_t   *scrn;
	xcb_window_t    root;
	xcb_randr_get_output_primary_cookie_t c;
	xcb_randr_get_output_primary_reply_t *primary_output;

	get_screen(conn, &scrn);
	root = scrn->root;

	c = xcb_randr_get_output_primary(conn, root);
	primary_output = xcb_randr_get_output_primary_reply(conn, c, NULL);

	return primary_output;
}
Esempio n. 10
0
void runReplay(char *name) {
	printf("Loading replay: %s\n", name);
	Replay replay = loadReplay(name);

	if (replay.items>0) {
		//GameInfo info;
		replayRunning = 1;
		SCREEN *screen = get_screen(SCREEN_GAME);
		GameInfo *info = screen->data;
		info->passage = passages[replay.passage];
		info->passageID = replay.passage;
		info->time = replay.time;
		set_screen(screen);
		//setEventHandler(gameEvent, &info);

		thread = SDL_CreateThread(replay_thread, "replay", (void*)(&replay));
	}
}
Esempio n. 11
0
int
main(int argc, char **argv)
{
	int x, y;
	if (argc < 4)
		usage(argv[0]);

	init_xcb(&conn);
	get_screen(conn, &scr);

	x = atoi(*(++argv));
	y = atoi(*(++argv));

	while (*argv)
		resize(strtoul(*argv++, NULL, 16), x, y);

	xcb_flush(conn);

	kill_xcb(&conn);

	return 0;
}
Esempio n. 12
0
int main(int argc, char* argv[])
{
  char* path_to_config;
  char* path_to_errors;
  int   is_batch_mode;
  int key = 0;
  int list_scr = 0;
  struct process_list* proc_list;
  screen_t* screen = NULL;
  int screen_num = 0;
  int q;
  int paranoia_level;

  /* Check OS to make sure we can run. */
  paranoia_level = check();

  init_options(&options);
  options.paranoia_level = paranoia_level;

  path_to_config = get_path_to_config(argc, argv);
  path_to_errors = get_path_to_error(argc, argv);
  is_batch_mode = get_batch_mode(argc, argv);

  init_errors(is_batch_mode, path_to_errors);

  q = read_config(path_to_config, &options);
  if (q == 0) {
    debug_printf("Config file successfully parsed.\n");
    options.config_file = 1;
  }
  else
    debug_printf("Could not parse config file.\n");

  /* Parse command line arguments. */
  parse_command_line(argc, argv, &options, &list_scr, &screen_num);


  /* Add default screens */
  if (options.default_screen == 1)
    init_screen();

  /* Remove unused but declared counters */
  tamp_counters();

  if (list_scr) {
    list_screens();
    delete_screens();
    exit(0);
  }

  if (options.spawn_pos) {
    /* monitor only spawned process */
    int child = spawn(argv + options.spawn_pos);
    options.only_pid = child;
    options.idle = 1;
  }

  do {
    if (screen_num >= 0)
      screen = get_screen(screen_num);
    else
      screen = get_screen_by_name(argv[-screen_num]);

    if (!screen) {
      fprintf(stderr, "No such screen.\n");
      exit(EXIT_FAILURE);
    }

    /* initialize the list of processes, and then run */
    proc_list = init_proc_list();

    if (options.spawn_pos) {
      options.spawn_pos = 0;  /* do this only once */
      new_processes(proc_list, screen, &options);
      start_child();
    }

    if (options.batch) {
      batch_mode(proc_list, screen);
      key = 'q';
    }
#ifdef HAVE_LIBCURSES
    else {
      key = live_mode(proc_list, screen);
      if ((key == '+')  || (key == KEY_RIGHT)) {
        screen_num = (screen_num + 1) % get_num_screens();
        active_col = 0;
        done_proc_list(proc_list);
        free(header);
      }
      if ((key == '-') || (key == KEY_LEFT)) {
        int n = get_num_screens();
        screen_num = (screen_num + n - 1) % n;
        active_col = 0;
        done_proc_list(proc_list);
        free(header);
      }
      if ((key == 'u') || (key == 'K') || (key == 'p')) {
        done_proc_list(proc_list);
      }
    }
#endif
  } while (key != 'q');

  /* done, free memory (makes valgrind happy) */
  close_error();
  delete_screens();
  done_proc_list(proc_list);
  free_options(&options);
  return 0;
}
Esempio n. 13
0
int
align (Display *display,
       int argc,
       const char *argv[],
       const char *funcname,
       const char *usage)
{
    RROutput outputid;
    XRROutputInfo *output;
    int ret;
    const char *inputarg;
    int screen;
    const char *pre_script;
    const char *post_script;

    ret = get_screen (display, argc, argv, funcname, usage, &screen);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "input", funcname, usage, "Virtual core pointer", &inputarg);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_output (display, argc, argv, funcname, usage, &outputid, &output);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "pre-script", funcname, usage, "", &pre_script);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "post-script", funcname, usage, "", &post_script);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    if (ret != EXIT_FAILURE) {
        Window root;

        if (verbose) {
            fprintf (stderr, "Output: %s\n", output->name);
        }

        root = RootWindow (display, screen);

        ret = run_script (pre_script);
        if (ret != EXIT_FAILURE) {
            ret = apply_transform (display, root, output->crtc, inputarg);
            if (ret != EXIT_FAILURE) {
                ret = run_script (post_script);
            }
        }
    }

    XRRFreeOutputInfo (output);
    return ret;
}
Esempio n. 14
0
void background::show()
{
    bg = get_screen();

    SDL_Flip(bg);
}
TransparentSlider::TransparentSlider() :
    _redInit(0.5),
    _greenInit(1),
    _blueInit(0.5),
    _alphaInit(0.5),
	_buttonLabel("Close"),
	_box(Gtk::ORIENTATION_VERTICAL),
	_inner_box(Gtk::ORIENTATION_HORIZONTAL),
	_alignment(Gtk::ALIGN_END, Gtk::ALIGN_END, 0.0, 0.0),
    _button(_buttonLabel),
    _adjustmentRed(Gtk::Adjustment::create(_redInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentGreen(Gtk::Adjustment::create(_greenInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentBlue(Gtk::Adjustment::create(_blueInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentAlpha(Gtk::Adjustment::create(_alphaInit, 0, 1.0, 0.1, 0.1, 0)),
    _scaleRed(_adjustmentRed, Gtk::ORIENTATION_VERTICAL),
    _scaleGreen(_adjustmentGreen, Gtk::ORIENTATION_VERTICAL),
    _scaleBlue(_adjustmentBlue, Gtk::ORIENTATION_VERTICAL),
    _scaleAlpha(_adjustmentAlpha, Gtk::ORIENTATION_VERTICAL)
{

    // Set up the top-level window.
	set_border_width(10);
    set_title("Color Slider Test");
    set_default_size(400,400);
    set_decorated(false);
    add_events(Gdk::BUTTON_PRESS_MASK);
    set_position(Gtk::WIN_POS_CENTER);
    set_app_paintable(true);

    // Signal handlers
    signal_draw().connect(sigc::mem_fun(*this, &TransparentSlider::on_draw));
    signal_screen_changed().connect(sigc::mem_fun(*this, &TransparentSlider::on_screen_changed));
    signal_button_press_event().connect(sigc::mem_fun(*this, &TransparentSlider::on_window_clicked));
    _button.signal_clicked().connect(sigc::mem_fun(*this, &TransparentSlider::on_button_clicked));

    // Widgets

    // Add the box and pack it.
    add(_box);
    _box.pack_start(_inner_box);
    _box.pack_start(_alignment);

    // Pack the inner box
    _inner_box.set_homogeneous();
    _inner_box.pack_start(_scaleRed);
    _inner_box.pack_start(_scaleGreen);
    _inner_box.pack_start(_scaleBlue);
    _inner_box.pack_start(_scaleAlpha);

    // Set up the scales:
    _scaleRed.set_digits(3);
    _scaleRed.set_inverted();
    _scaleGreen.set_digits(3);
    _scaleGreen.set_inverted();
    _scaleBlue.set_digits(3);
    _scaleBlue.set_inverted();
    _scaleAlpha.set_digits(3);
    _scaleAlpha.set_inverted();

    // Set up the close button
    _alignment.add(_button);
    _button.set_size_request(100, 10);

    // Initialize the process of drawing the colored part.
    on_screen_changed(get_screen());

    // Show the window and all its children.
    show_all_children();
}
Esempio n. 16
0
    void simulation_tab::draw()
    {
        int eighth = get_h() / 8;

        // initialize children on first draw (since the parent has handled sizing...)
        if (!title_box)
        {
            int baseline = 7 * eighth;

            title_box = new textbox(get_screen(), this, 
                                    BUTTON_SPACE, baseline + BUTTON_SPACE, 
                                    get_w() - 2*BUTTON_SPACE, eighth - 2*BUTTON_SPACE, 
                                    main_window::FOREGROUND, main_window::BACKGROUND, 
                                    main_window::FONT_FACE, main_window::FONT_SIZE);
            title_box->get_text() = L"<simulation description>";
        }


        if (!time_box)
        {
            int baseline = 6 * eighth + eighth/2;

            time_box = new datetime_box(get_screen(), this,
                                        BUTTON_SPACE, baseline + BUTTON_SPACE,
                                        get_w() - 2*BUTTON_SPACE, main_window::FONT_SIZE*4/3,
                                        main_window::FOREGROUND, main_window::BACKGROUND);                                        

            //time_box->get_text() = L"1988-6-19 12:0:0";
            //time_box->get_jdn() = 2026871.8;
            //time_box->get_jdn() = julian_day::now().get_jdn();
            time_box->set_text(L"2007-03-20 12:0:0"); // vernal equinox, for testing
        }

        
        if (!view_box)
        {
            int baseline = eighth/2 + BUTTON_SPACE/2;

            view_box = new sim_view_box(get_screen(), this,
                                        BUTTON_SPACE, baseline + BUTTON_SPACE,
                                        get_w()/2 - 2*BUTTON_SPACE, 6*eighth - 2*BUTTON_SPACE,
                                        main_window::FOREGROUND, main_window::BACKGROUND);
            treebox *view_tree = view_box->get_scenery_box();
            treebox_node *temp_node = new treebox_node(get_screen(), view_tree, 0, main_window::FOREGROUND, main_window::BACKGROUND, L"Loading...", 0);

            waiting_for_scenery = true;
        }

        //if (!vehicle_box)
        //{
        //    int baseline = eight/2 + BUTTON_SPACE/2;

        //    vehicle_box = new sim_vehicle_box(this,
        //                                      BUTTON_SPACE, baseline + BUTTON_SPACE,
        //                                      get_w() / 2 - 2 * BUTTON_SPACE, 6 * eighth - 2*BUTTON_SPACE,
        //                                      main_window::FOREGROUND, main_window::BACKGROUND);
        //    treebox *vehicle_tree = vehicle_box->get_vehicle_box();
        //    treebox_node *temp_node = new treebox_node(vehicle_tree, 0, main_window::FOREGROUND, main_window::BACKGROUND, L"Loading...", 0);

        //    waiting_for_vehicles = true;
        //}


        if (!load_button)
        {
            load_button = new button(get_screen(), this, 
                                     BUTTON_SPACE, BUTTON_SPACE, 
                                     (get_w() / 3) - 2*BUTTON_SPACE, main_window::FONT_SIZE * 4 / 3, 
                                     main_window::FOREGROUND, main_window::BACKGROUND, 
                                     main_window::FONT_FACE, main_window::FONT_SIZE, 
                                     L"Load Simulation");
        }

        if (!save_button)
        {
            save_button = new button(get_screen(), this,
                                     (get_w() / 3) + BUTTON_SPACE, BUTTON_SPACE,
                                     (get_w() / 3) - 2*BUTTON_SPACE, main_window::FONT_SIZE * 4 / 3,
                                     main_window::FOREGROUND, main_window::BACKGROUND,
                                     main_window::FONT_FACE, main_window::FONT_SIZE,
                                     L"Save Simulation");
        }

        if (!go_button)
        {
            go_button = new button(get_screen(), this,
                                   (get_w() * 2 / 3) + BUTTON_SPACE, BUTTON_SPACE,
                                   (get_w() / 3) - 2*BUTTON_SPACE, main_window::FONT_SIZE * 4 / 3,
                                   main_window::FOREGROUND, main_window::BACKGROUND,
                                   main_window::FONT_FACE, main_window::FONT_SIZE,
                                   L"Run Simulation");
            go_button->set_on_click_handler(&handle_run_simulation);
        }

        // check for scenery & sim
        if (waiting_for_scenery)
        {
            if (application::global_instance()->get_global_scenery())
            {
                view_box->load_scenery_info();
                waiting_for_scenery = false;
            }
        }

        // check for vehicles
        if (waiting_for_vehicles)
        {

        }

        // check for simulation
        sim_is_ready = (time_box->get_jdn() != 0) && (view_box->get_scenery_box()->get_selected_node() != 0);

        node *n = sim_is_ready ? reinterpret_cast<node *>(view_box->get_scenery_box()->get_selected_node()->get_user_data()) : 0;
        if (!dynamic_cast<space::celestial_body *>(n))
            sim_is_ready = false;

        if (sim_is_ready)
        {
            go_button->set_flags(widget::WIDGET_INACTIVE, false);
        }
        else
        {
            go_button->set_flags(widget::WIDGET_INACTIVE, true);
        }

        // now draw per usual
        //widget::draw();
    } // simulation_tab::draw()
Esempio n. 17
0
static grub_err_t
grub_cmd_popup (grub_extcmd_t cmd, int argc, char **args)
{
  struct grub_arg_list *state = cmd->state;
  grub_uitree_t root, node, menu, save;
  int edit, i, r;
  char *parm, *parm1;
  char *name;

  if (! argc)
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "not enough parameter");

  if (! grub_widget_current_node)
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "no current node");

  root = get_screen ();
  if (! root)
    return grub_errno;

  name = args[0];
  if (name[0] == ':')
    {
      name = grub_uitree_get_prop (grub_widget_current_node, name + 1);
      if (! name)
	return 0;
    }

  menu = save = 0;
  if (state[0].set)
    node = grub_uitree_load_string (root, name,
				    GRUB_UITREE_LOAD_FLAG_SINGLE |
				    GRUB_UITREE_LOAD_FLAG_ROOT);
  else if (state[1].set)
    node = grub_uitree_load_file (root, name,
				  GRUB_UITREE_LOAD_FLAG_SINGLE |
				  GRUB_UITREE_LOAD_FLAG_ROOT);
  else if (state[5].set)
    {
      grub_uitree_t p;

      node = grub_dialog_create (state[5].arg, 1, 0, 0, 0);
      if (! node)
	{
	  node = grub_dialog_create ("template_submenu", 1, 0, 0, 0);
	  if (! node)
	    return 0;
	}

      p = grub_uitree_find_id (node, "__child__");
      if (! p)
	p = node;

      grub_tree_add_child (GRUB_AS_TREE (root), GRUB_AS_TREE (node), -1);
      add_sys_menu (name, node, 0, -1, 0);
    }
  else
    {
      node = grub_dialog_create (name, state[2].set, (state[3].set) ?
				 grub_strtoul (state[3].arg, 0, 0) : 0,
				 &menu, &save);
      if (node)
	grub_tree_add_child (GRUB_AS_TREE (root), GRUB_AS_TREE (node), -1);
    }

  if (! node)
    return grub_errno;

  edit = (cmd->cmd->name[5] == 'e');
  parm = grub_uitree_get_prop (node, "parameters");
  parm1 = grub_uitree_get_prop (grub_widget_current_node, "parameters");

  for (i = 1; i < argc; i++)
    {
      char *p, *s;

      p = grub_menu_next_field (args[i], '=');
      if (! p)
	continue;

      s = (edit) ?
	grub_dialog_get_parm (grub_widget_current_node, parm1, p) : p;
      if (s)
	{
	  if (! grub_dialog_set_parm (node, parm, args[i], s))
	    {
	      grub_menu_restore_field (p, '=');
	      grub_dialog_free (node, menu, save);
	      return grub_error (GRUB_ERR_BAD_ARGUMENT,
				 "can\'t set parameter");
	    }
	}

      grub_menu_restore_field (p, '=');
    }

  if (state[4].set)
    set_position (root, node);

  r = grub_dialog_popup (node);

  if ((r == 0) && (edit))
    for (i = 1; i < argc; i++)
      {
	char *p, *s;

	p = grub_menu_next_field (args[i], '=');
	if (! p)
	  continue;

	s = grub_dialog_get_parm (node, parm, args[i]);
	if (s)
	  grub_dialog_set_parm (grub_widget_current_node, parm1, p, s);
	grub_menu_restore_field (p, '=');
      }

  grub_dialog_free (node, menu, save);
  grub_errno = r;
  return r;
}
Esempio n. 18
0
 void widget::draw_line(int x0, int y0, int x1, int y1)
 {
     get_abs(x0, y0);
     get_abs(x1, y1);
     get_screen().draw_line_2d(x0, y0, x1, y1);
 } // widget::draw_line()
Esempio n. 19
0
 void widget::draw_box(int x, int y, int w, int h)
 {
     get_abs(x, y);
     get_screen().draw_rect_2d(static_cast<float>(x), static_cast<float>(y), static_cast<float>(x+w), static_cast<float>(y+h));
 } // widget::draw_box()