static void
volume_level_changed (GsdMediaKeysWindow *window)
{
        update_window (window);

        if (!window->priv->is_composited && window->priv->progress != NULL) {
                double fraction;

                fraction = (double) window->priv->volume_level / 100.0;

                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress),
                                               fraction);
        }
}
void
gsd_media_keys_window_set_action (GsdMediaKeysWindow      *window,
                                  GsdMediaKeysWindowAction action)
{
        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
        g_return_if_fail (action == GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);

        if (window->priv->action != action) {
                window->priv->action = action;
                action_changed (window);
        } else {
                update_window (window);
        }
}
Exemple #3
0
static void
active_window_changed_callback    (MatewnckScreen    *screen,
                                   MatewnckWindow    *previous_window,
                                   gpointer       data)
{
    MatewnckWindow *window;

    g_print ("Active window changed\n");

    window = matewnck_screen_get_active_window (screen);

    if (window)
        update_window (global_tree_model, window);
}
Exemple #4
0
 win3d::win3d(uint wid, const char *wname, uint height, uint width)
   : QGLWidget(), win((QWidget*) this, wid, wname, height, width) {
   if ((height != 0) && (width != 0))
     resize_window(height, width);
   // setAutoFillBackground(false);
   // setAutoBufferSwap(false);
   pixmapScale = 1.0;
   xRot = 0;
   yRot = 0;
   zRot = 0;
   rotationX = 0;//-38.0;
   rotationY = 0;//-58.0;
   rotationZ = 0.0;
   scaling = 1.0;
   update_window();
 }
Exemple #5
0
int main() {
	window *window = create_window(L"test window", -1, -1, 800, 600, on_resize, 0, 0);

	while (window->is_open) {
		unsigned char *row = (unsigned char *)window->bitmap_memory;

		int pitch = window->bitmap_width * 4; // 4 bytes per pixel

		for (int y = 0; y < window->bitmap_height; y++) {
			unsigned char *pixel = (unsigned char *)row;

			for (int x = 0; x < window->bitmap_width; x++) {
				*pixel = 255;
				pixel++;

				*pixel = 0;
				pixel++;

				*pixel = 0;
				pixel++;

				*pixel = 0;
				pixel++;
			}

			row += pitch;
		}

		if (window->mouse_state[0])
			rect(window, window->cursor_x, window->cursor_y, 30, 30, 255, 0, 0);
		if (window->mouse_state[1])
			rect(window, window->cursor_x, window->cursor_y, 30, 30, 0, 255, 0);
		if (window->mouse_state[2])
			rect(window, window->cursor_x, window->cursor_y, 30, 30, 255, 255, 0);

		for (int i = 0; i < window->num_keys; i++)
		{
			if (window->keyboard_state[i])
				printf("%d\n", i);
		}

		update_window(window);
	}

	return 0;
}
Exemple #6
0
void process_events()
{
 XEvent event;
 int winx, winy;

 XNextEvent(display, &event);
 switch(event.type)
 {
  case Expose:
   update_window();
   break;
  case ButtonPress:
   if(opt_window && (event.xbutton.button == 1))
   {
    XDefineCursor(display, mapwindow, fleur);
    moving = 1;
    oldx = event.xbutton.x;
    oldy = event.xbutton.y;
   }
   break;
  case MotionNotify:
   winx = event.xmotion.x_root - oldx;
   winy = event.xmotion.y_root - oldy;
   if(winx < 0) winx = 0;
   if(winy < 0) winy = 0;
   if(winx > (screenwidth - WINDOW_WIDTH))
    winx = screenwidth - WINDOW_WIDTH;
   if(winy > (screenheight - WINDOW_HEIGHT))
    winy = screenheight - WINDOW_HEIGHT;
   if(moving)
    XMoveWindow(display, mapwindow, winx, winy);
   break;
  case ButtonRelease:
   if(opt_window)
   {
    moving = 0;
    XUndefineCursor(display, mapwindow);
   }
   break;
  case ClientMessage:
   if(event.xclient.data.l[0] == wm_delete_window)
    exitloop = 1;
   break;
 }
}
Exemple #7
0
void
x_full_screen(int do_full)
{
	
#if 0
	WindowRef new_window;
	short	width, height;
	OSErr	ret;
	
	width = 640;
	height = 480;
	if(do_full && (g_mac_fullscreen_state == 0)) {
		g_main_window_saved = g_main_window;
		
		GetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
		ret = BeginFullScreen(&g_mac_fullscreen_state, 0,
							  &width, &height, &new_window, 0, 0);
		printf("Ret beginfullscreen: %d\n", (int)ret);
		printf("New width: %d, new height: %d\n", width, height);
		if(ret == noErr) {
			g_main_window = new_window;
		} else {
			g_mac_fullscreen_state = 0;
		}
	} else if(!do_full && (g_mac_fullscreen_state != 0)) {
		ret = EndFullScreen(g_mac_fullscreen_state, 0);
		printf("ret endfullscreen: %d\n", (int)ret);
		g_main_window = g_main_window_saved;
		g_mac_fullscreen_state = 0;
		//InitCursor();
		SetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
	}
	
	update_main_window_size();
	
	ShowWindow(g_main_window);
	BringToFront(g_main_window);
	update_window();
#endif
}
Exemple #8
0
static void
update_window_transfer_bytes (gftp_window_data * wdata)
{
  char *tempstr, *temp1str;

  if (wdata->request->gotbytes == -1)
    {
      update_window (wdata);
      wdata->request->gotbytes = 0;
    }
  else
    {
      tempstr = insert_commas (wdata->request->gotbytes, NULL, 0);
      temp1str = g_strdup_printf (_("Retrieving file names...%s bytes"), 
                                  tempstr);
      gtk_label_set (GTK_LABEL (wdata->hoststxt), temp1str);
      g_free (tempstr);
      g_free (temp1str);
    }
}
void
gsd_media_keys_window_set_action_custom (GsdMediaKeysWindow      *window,
                                         const char              *icon_name,
                                         gboolean                 show_level)
{
        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
        g_return_if_fail (icon_name != NULL);

        if (window->priv->action != GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM ||
            g_strcmp0 (window->priv->icon_name, icon_name) != 0 ||
            window->priv->show_level != show_level) {
                window->priv->action = GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM;
                g_free (window->priv->icon_name);
                window->priv->icon_name = g_strdup (icon_name);
                window->priv->show_level = show_level;
                action_changed (window);
        } else {
                update_window (window);
        }
}
//process the current window, and advance to the next one.
//Returns a negative number on a failure, a zero when there are still more windows to go, and a 1 when done.
static inline int process_window(ctr_crypto_interface *io, write_window *window, size_t sector_size, size_t block_size, void (*input_function)(void *io, void *buffer, uint64_t block, size_t block_count), void (*output_function)(void *io, void *buffer, uint64_t block, size_t block_count))
{
	//FIXME what if we try to read more than there is disk? Return zeros?
	size_t sectors_to_read = (window->window_size - window->window_offset) / sector_size;
	int res = ctr_io_read_sector(io->lower_io, window->window + window->window_offset, window->window_size - window->window_offset, window->current_sector, sectors_to_read);
	if (res)
		return -1;

	size_t block_start_offset = window->block_offset;
	uint8_t *pos = window->window + block_start_offset;

	size_t amount_to_copy = window->window_size - window->window_offset;
	if (amount_to_copy > window->buffer_size - window->buffer_offset)
		amount_to_copy = window->buffer_size - window->buffer_offset;

	//In the case that blocks are aligned to sectors, this is not necessary... FIXME
	//only process parts that won't be overwritten completely
	//	from block_start_offset to window->window_offset
	size_t blocks_to_process = CEIL(window->window_offset - block_start_offset, block_size);
	if (!blocks_to_process) blocks_to_process = 1;
	output_function(io, pos, window->block, blocks_to_process);

	//now copy data from buffer
	memcpy(window->window + window->window_offset, window->buffer + window->buffer_offset, amount_to_copy);
	window->buffer_offset += amount_to_copy;

	blocks_to_process = CEIL(amount_to_copy + window->window_offset - block_start_offset, block_size);
	input_function(io, pos, window->block, blocks_to_process);

	//We need to write out the full blocks processed actually, not just the sectors
	size_t sectors_processed = (amount_to_copy + window->window_offset) / sector_size;
	size_t sectors_to_copy = CEIL(blocks_to_process * block_size, sector_size);
	res = ctr_io_write_sector(io->lower_io, window->window, sectors_to_copy * sector_size, window->sector);
	if (res)
		return -2;

	//Copy sector that contain part of next block
	update_window(window, sectors_processed);

	return window->buffer_offset >= window->buffer_size;
}
Exemple #11
0
int main()
{
    size_t n = 1000;
    std::vector<double> x, y;

    const double w = 0.05;
    const double a = n/2;

    for (size_t i=0; i<n; i++) {
        x.push_back(i);
        y.push_back(a*sin(w*i));
    }

    std::vector<double> xt(2), yt(2);

    plt::title("Tangent of a sine curve");
    plt::xlim(x.front(), x.back());
    plt::ylim(-a, a);
    plt::axis("equal");

    // Plot sin once and for all.
    plt::named_plot("sin", x, y);

    // Prepare plotting the tangent.
    plt::Plot plot("tangent");

    plt::legend();

    for (size_t i=0; i<n; i++) {
        if (i % 10 == 0) {
            update_window(x[i], y[i], a*w*cos(w*x[i]), xt, yt);

            // Just update data for this plot.
            plot.update(xt, yt);

            // Small pause so the viewer has a chance to enjoy the animation.
            plt::pause(0.1);
        }
   }
}
Exemple #12
0
void itemdetail::on_item_complete(Item it)
{
    ui->item_href->setText(QString("http:")+it.href);
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(QString("http:")+it.href);
    emit log_changed("已复制特卖推广链接到剪切板...\r\n");
    log_ch("特卖生成成功\r\n");
    log_ch("特卖复制成功\r\n");

    item.auctionPrice=it.auctionPrice;
    item.commissionRate=it.commissionRate;
    item.discountPrice=it.discountPrice;
    item.discountRate=it.discountRate;
    item.isSoldOut=it.isSoldOut;
    item.itemTitle=it.itemTitle;
    item.soldQuantity=it.soldQuantity;
    item.sellerId=it.sellerId;
    item.mall=it.mall;
    item.picUrl=it.picUrl;

    update_window();
}
Exemple #13
0
int main(int argc, char *argv[])
{
    init_freetype(
        argc >= 2
            ? argv[1]
            : default_font_path
    );

    freetype_render_glyph(0x41);

    init_gl(800, 600, "Text Test");

    while(!glfwWindowShouldClose(window))
    {
        update_viewport_and_projection();

        gl_render_glyph();

        update_window();
    }

    return 0;
}
Exemple #14
0
mux_dialog::mux_dialog(wxWindow *parent):
    wxDialog(parent, -1, Z("mkvmerge is running"), wxDefaultPosition,
#ifdef SYS_WINDOWS
             wxSize(700, 560),
#else
             wxSize(700, 520),
#endif
             wxDEFAULT_FRAME_STYLE)
#if defined(SYS_WINDOWS)
    , pid(0)
    , m_taskbar_progress(NULL)
    , m_abort_button_changed(false)
#endif  // SYS_WINDOWS
    , m_exit_code(0)
    , m_progress(0)
{
    char c;
    std::string arg_utf8, line;
    long value;
    wxString wx_line, tmp;
    wxInputStream *out;
    wxFile *opt_file;
    uint32_t i;
    wxArrayString *arg_list;
    wxBoxSizer *siz_all, *siz_buttons, *siz_line;
    wxStaticBoxSizer *siz_status, *siz_output;

    m_window_disabler = new wxWindowDisabler(this);

    c = 0;
    siz_status = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Status and progress")), wxVERTICAL);
    st_label = new wxStaticText(this, -1, wxEmptyString);
    st_remaining_time_label = new wxStaticText(this, -1, Z("Remaining time:"));
    st_remaining_time       = new wxStaticText(this, -1, Z("is being estimated"));
    siz_line = new wxBoxSizer(wxHORIZONTAL);
    siz_line->Add(st_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time);
    siz_status->Add(siz_line, 0, wxGROW | wxALIGN_LEFT | wxALL, 5);
    g_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxSize(250, 15));
    siz_status->Add(g_progress, 1, wxALL | wxGROW, 5);

    siz_output = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Output")), wxVERTICAL);
    siz_output->Add(new wxStaticText(this, -1, Z("mkvmerge output:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_output = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_output, 2, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Warnings:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_warnings = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_warnings, 1, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Errors:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_errors = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_errors, 1, wxGROW | wxALL, 5);

    siz_buttons = new wxBoxSizer(wxHORIZONTAL);
    siz_buttons->AddStretchSpacer();
    b_ok = new wxButton(this, ID_B_MUX_OK, Z("Ok"));
    b_ok->Enable(false);
    siz_buttons->Add(b_ok, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_abort = new wxButton(this, ID_B_MUX_ABORT, Z("Abort"));
    siz_buttons->Add(b_abort, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_save_log = new wxButton(this, ID_B_MUX_SAVELOG, Z("Save log"));
    siz_buttons->Add(b_save_log, 0, wxGROW);
    siz_buttons->AddStretchSpacer();

    siz_all = new wxBoxSizer(wxVERTICAL);
    siz_all->Add(siz_status, 0, wxGROW | wxALL, 5);
    siz_all->Add(siz_output, 1, wxGROW | wxALL, 5);
    siz_all->Add(siz_buttons, 0, wxGROW | wxALL, 10);
    SetSizer(siz_all);

    update_window(Z("Muxing in progress."));
    Show(true);

    process = new mux_process(this);

    opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime());
    try {
        const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
        opt_file = new wxFile(opt_file_name, wxFile::write);
        opt_file->Write(utf8_bom, 3);
    } catch (...) {
        wxString error;
        error.Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(strerror(errno)));
        wxMessageBox(error, Z("File creation failed"), wxOK | wxCENTER | wxICON_ERROR);
        throw 0;
    }
    arg_list = &static_cast<mmg_dialog *>(parent)->get_command_line_args();
    for (i = 1; i < arg_list->Count(); i++) {
        if ((*arg_list)[i].Length() == 0)
            opt_file->Write(wxT("#EMPTY#"));
        else {
            arg_utf8 = escape(wxMB((*arg_list)[i]));
            opt_file->Write(arg_utf8.c_str(), arg_utf8.length());
        }
        opt_file->Write(wxT("\n"));
    }
    delete opt_file;

#if defined(SYS_WINDOWS)
    if (get_windows_version() >= WINDOWS_VERSION_7) {
        m_taskbar_progress = new taskbar_progress_c(mdlg);
        m_taskbar_progress->set_state(TBPF_NORMAL);
        m_taskbar_progress->set_value(0, 100);
    }
#endif  // SYS_WINDOWS

    m_start_time                 = get_current_time_millis();
    m_next_remaining_time_update = m_start_time + 8000;

    wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str());
    pid = wxExecute(command_line, wxEXEC_ASYNC, process);
    if (0 == pid) {
        wxLogError(wxT("Execution of '%s' failed."), command_line.c_str());
        done(2);
        return;
    }
    out = process->GetInputStream();

    line = "";
    log = wxEmptyString;
    while (1) {
        while (app->Pending())
            app->Dispatch();

        if (!out->CanRead() && !out->Eof()) {
            wxMilliSleep(5);
            continue;
        }

        if (!out->Eof())
            c = out->GetC();
        else
            c = '\n';

        if ((c == '\n') || (c == '\r') || out->Eof()) {
            wx_line = wxU(line);
            log += wx_line;
            if (c != '\r')
                log += wxT("\n");
            if (wx_line.Find(Z("Warning:")) == 0)
                tc_warnings->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Error:")) == 0)
                tc_errors->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Progress")) == 0) {
                if (wx_line.Find(wxT("%")) != 0) {
                    wx_line.Remove(wx_line.Find(wxT("%")));
                    tmp = wx_line.AfterLast(wxT(' '));
                    tmp.ToLong(&value);
                    if ((value >= 0) && (value <= 100))
                        update_gauge(value);
                }
            } else if (wx_line.Length() > 0)
                tc_output->AppendText(wx_line + wxT("\n"));
            line = "";

            update_remaining_time();

        } else if ((unsigned char)c != 0xff)
            line += c;

        if (out->Eof())
            break;
    }
}
Exemple #15
0
int GeoMapEditor::processEvents()
{
  update_window();
  return processKeys();
}
Exemple #16
0
result_t widget_wndproc(handle_t hwnd, const canmsg_t *msg)
  {
  bool changed = false;
  hsi_window_t *wnd;
  get_wnddata(hwnd, (void **)&wnd);

  switch (msg->id)
    {
    case id_magnetic_heading:
    {
    int16_t direction;
    get_param_int16(msg, 0, &direction);

    while (direction < 0)
      direction += 360;
    while (direction > 359)
      direction -= 360;

    changed = wnd->direction != direction;
    wnd->direction = direction;
    }
    break;
    case id_heading:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->heading_bug != value;
    wnd->heading_bug = value;
    }
    break;
    case id_heading_angle:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->heading != value;
    wnd->heading = value;
    }
    break;
    case id_deviation:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->deviation != value;
    wnd->deviation = value;
    // the deviation is +/- * 10
    }
    break;
    case id_selected_course:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->course != value;
    wnd->course = value;
    }
    break;
    case id_track:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->track != value;
    wnd->track = value;
    }
    break;
    case id_wind_speed:
    {
    float v;
    get_param_float(msg, &v);
    int16_t value = (int16_t)meters_per_second_to_knots(v);
    changed = wnd->wind_speed != value;
    wnd->wind_speed = value;
    }
    break;
    case id_wind_direction:
    {
    float v;
    get_param_float(msg, &v);
    int16_t value = (int16_t)radians_to_degrees(v);
    changed = wnd->wind_direction != value;
    wnd->wind_direction != value;
    }
    break;
    case id_distance_to_next:
    {
    float v;
    get_param_float(msg, &v);
    int16_t value = (int16_t)meters_to_nm(v);
    changed = wnd->distance_to_waypoint != value;
    wnd->distance_to_waypoint = value;
    }
    break;
    case id_magnetic_variation:
    {
    float v;
    get_param_float(msg, &v);
    int16_t value = (int16_t)radians_to_degrees(v);
    changed = wnd->magnetic_variation != value;
    wnd->magnetic_variation = value;
    }
    break;
    case id_estimated_time_to_next:
    {
    int16_t value;
    get_param_int16(msg, 0, &value);
    changed = wnd->time_to_waypoint != value;
    wnd->time_to_waypoint = value;
    }
    break;
    case id_paint:
      begin_paint(hwnd);
      update_window(hwnd, wnd);
      end_paint(hwnd);
      break;
    default:
      return defwndproc(hwnd, msg);
    }

  if (changed)
    invalidate_rect(hwnd, 0);

  return s_ok;
  }
Exemple #17
0
gboolean pipe_event(GIOChannel chan, GIOCondition cond, gpointer data) {
    static char *path;
    char name[TMPNAMELEN];
    ssize_t rr;
    int nimgs = 0;

    if (!path)
        path = xmalloc(strlen(tmpdir) + 64);

    /* We are sent messages of size TMPNAMELEN containing a null-terminated
     * file name. */
    while (nimgs < 4 && (rr = xread(dpychld_fd, name, sizeof name)) == sizeof name) {
        int saveimg = 0;
        struct stat st;

        ++nimgs;
        
        sprintf(path, "%s/%s", tmpdir, name);

        if (stat(path, &st) == -1)
            continue;
           
        if (verbose)
            fprintf(stderr, PROGNAME": received image %s of size %d\n", name, (int)st.st_size);
        /* Check to see whether this looks like an image we're interested in. */
        if (st.st_size > 100) {
            /* Small images are probably bollocks. */
            img i = img_new();
            if (!img_load_file(i, path, header, unknown))
                fprintf(stderr, PROGNAME": %s: bogus image (err = %d)\n", name, i->err);
            else {
                if (i->width > 8 && i->height > 8) {
                    if (img_load(i, full, i->type)) {
                        /* slot in the new image at some plausible place. */
                        int w, h;
                        if (i->width > width - 2 * BORDER) w = width - 2 * BORDER;
                        else w = i->width;
                        if (i->height > height - 2 * BORDER) h = height - 2 * BORDER;
                        else h = i->height;

                        /* is there space on this row? */
                        if (width - wrx < w) {
                            /* no */
                            scroll_backing_image(h + BORDER);
                            wrx = BORDER;
                            rowheight = h + BORDER;
                        }
                        if (rowheight < h + BORDER) {
                            scroll_backing_image(h + BORDER - rowheight);
                            rowheight = h + BORDER;
                        }

                        img_simple_blt(backing_image, wrx, wry - h, i, 0, 0, w, h);
                        add_image_rectangle(path, wrx, wry - h, w, h);
                        saveimg = 1;

                        if (beep)
                            write(1, "\a", 1);

                        update_window();

                        wrx += w + BORDER;
                    } else fprintf(stderr, PROGNAME": %s: bogus image (err = %d)\n", name, i->err);
                } else if (verbose) fprintf(stderr, PROGNAME": %s: image dimensions (%d x %d) too small to bother with\n", name, i->width, i->height);
            }

            img_delete(i);
        } else if (verbose) fprintf(stderr, PROGNAME": image data too small (%d bytes) to bother with\n", (int)st.st_size);

        if (!saveimg)
            unlink(name);
    }
    if (rr == -1 && errno != EINTR && errno != EAGAIN) {
        perror(PROGNAME": read");
        gtk_main_quit();
    } else if (rr == 0) {
        /* pipe closed, exit. */
        gtk_main_quit();
    }
    return TRUE;
}
Exemple #18
0
/* this is really aimed at the lcd panel. That said, there are two display
 * devices on this part and we may someday want to extend it for other boards.
 */
void display_startup(device_t dev)
{
	struct soc_nvidia_tegra124_config *config = dev->chip_info;
	struct display_controller *disp_ctrl = (void *)config->display_controller;
	struct pwm_controller 	*pwm = (void *)TEGRA_PWM_BASE;
	struct tegra_dc		*dc = &dc_data;
	u32 plld_rate;

	/* init dc */
	dc->base = (void *)TEGRA_ARM_DISPLAYA;
	dc->config = config;
	config->dc_data = dc;

	/* Note dp_init may read EDID and change some config values. */
	dp_init(config);

	/* should probably just make it all MiB ... in future */
	u32 framebuffer_size_mb = config->framebuffer_size / MiB;
	u32 framebuffer_base_mb= config->framebuffer_base / MiB;

	/* light it all up */
	/* This one may have been done in romstage but that's ok for now. */
	if (config->panel_vdd_gpio){
		gpio_output(config->panel_vdd_gpio, 1);
		printk(BIOS_SPEW,"%s: panel_vdd setting gpio %08x to %d\n",
			__func__, config->panel_vdd_gpio, 1);
	}
	udelay(config->vdd_delay_ms * 1000);
	if (config->backlight_vdd_gpio){
		gpio_output(config->backlight_vdd_gpio, 1);
		printk(BIOS_SPEW,"%s: backlight vdd setting gpio %08x to %d\n",
			__func__, config->backlight_vdd_gpio, 1);
	}
	if (config->lvds_shutdown_gpio){
		gpio_output(config->lvds_shutdown_gpio, 0);
		printk(BIOS_SPEW,"%s: lvds shutdown setting gpio %08x to %d\n",
			__func__, config->lvds_shutdown_gpio, 0);
	}

	if (framebuffer_size_mb == 0){
		framebuffer_size_mb = ALIGN_UP(config->xres * config->yres *
			(config->framebuffer_bits_per_pixel / 8), MiB)/MiB;
	}

	if (! framebuffer_base_mb)
		framebuffer_base_mb = fb_base_mb();

	config->framebuffer_size = framebuffer_size_mb * MiB;
	config->framebuffer_base = framebuffer_base_mb * MiB;

	mmu_config_range(framebuffer_base_mb, framebuffer_size_mb,
		config->cache_policy);

	printk(BIOS_SPEW, "LCD frame buffer at %dMiB to %dMiB\n", framebuffer_base_mb,
		   framebuffer_base_mb + framebuffer_size_mb);

	/* GPIO magic here if needed to start powering up things. You
	 * really only want to enable vdd, wait a bit, and then enable
	 * the panel. However ... the timings in the tegra20 dts make
	 * no sense to me. I'm pretty sure they're wrong.
	 * The panel_vdd is done in the romstage, so we need only
	 * light things up here once we're sure it's all working.
	 */

	/* The plld is programmed with the assumption of the SHIFT_CLK_DIVIDER
	 * and PIXEL_CLK_DIVIDER are zero (divide by 1). See the
	 * update_display_mode() for detail.
	 */
	plld_rate = clock_display(config->pixel_clock * 2);
	if (plld_rate == 0) {
		printk(BIOS_ERR, "dc: clock init failed\n");
		return;
	} else if (plld_rate != config->pixel_clock * 2) {
		printk(BIOS_WARNING, "dc: plld rounded to %u\n", plld_rate);
		config->pixel_clock = plld_rate / 2;
	}

	/* Init dc */
	if (tegra_dc_init(disp_ctrl)) {
		printk(BIOS_ERR, "dc: init failed\n");
		return;
	}

	/* Configure dc mode */
	if (update_display_mode(disp_ctrl, config)) {
		printk(BIOS_ERR, "dc: failed to configure display mode.\n");
		return;
	}

	/* Enable dp */
	dp_enable(dc->out);

	/* Init frame buffer */
	memset((void *)(framebuffer_base_mb*MiB), 0x00,
			framebuffer_size_mb*MiB);

	update_window(disp_ctrl, config);

	/* Set up Tegra PWM n (where n is specified in config->pwm) to drive the
	 * panel backlight.
	 */
	printk(BIOS_SPEW, "%s: enable panel backlight pwm\n", __func__);
	WRITEL(((1 << NV_PWM_CSR_ENABLE_SHIFT) |
		(220 << NV_PWM_CSR_PULSE_WIDTH_SHIFT) | /* 220/256 */
		0x02e), /* frequency divider */
	       &pwm->pwm[config->pwm].csr);

	udelay(config->pwm_to_bl_delay_ms * 1000);
	if (config->backlight_en_gpio){
		gpio_output(config->backlight_en_gpio, 1);
		printk(BIOS_SPEW,"%s: backlight enable setting gpio %08x to %d\n",
			__func__, config->backlight_en_gpio, 1);
	}

	printk(BIOS_INFO, "%s: display init done.\n", __func__);

	/* tell depthcharge ...
	 */
	struct edid edid;
	edid.bytes_per_line = ((config->xres * config->framebuffer_bits_per_pixel / 8 + 31) /
				32 * 32);
	edid.x_resolution = edid.bytes_per_line / (config->framebuffer_bits_per_pixel / 8);
	edid.y_resolution = config->yres;
	edid.framebuffer_bits_per_pixel = config->framebuffer_bits_per_pixel;
	set_vbe_mode_info_valid(&edid, (uintptr_t)(framebuffer_base_mb*MiB));
}
Exemple #19
0
static LRESULT CALLBACK
startup_wnd_proc(
	HWND		hWnd,
	UINT		uMsg,
	WPARAM		wParam,
	LPARAM		lParam)
{
	MSG				msg;
	Sint32			screenType;
	Sint32			drawMode;
	Sint32			drawMethod;
	Sint32			vsync;
	Sint32			psgType;
	Sint32			soundBuffer;

	switch (uMsg)
	{
	case WM_CREATE:
		EnableWindow(WINMAIN_GetHwnd(), FALSE);//メインウィンドウを無効化してモーダルに。
		_hFontB = CreateFont(  0,						// 高さ。0 = デフォルト
		                       0,						// 幅。0なら高さに合った幅
    		                   0,						// 角度
        		               0,						// ベースラインとの角度
            		           FW_NORMAL,				// 太さ
                		       FALSE,					// イタリック
	                    	   FALSE,					// アンダーライン
		                       FALSE,					// 打ち消し線
    		                   0,						// 日本語を取り扱うときはSHIFTJIS_CHARSETにする。
        		               0,						// 出力精度
            		           0,						// クリッピング精度
                		       0,						// 出力品質
                    		   0,						// ピッチとファミリー
		                       ""						// 書体名
							); //英語のデフォルトフォントに設定
		_FontWidth	= get_font_width(hWnd);
		_FontHeight = get_font_height(hWnd);
		set_window_size(hWnd);
		break;

	case WM_PAINT:
		update_window(hWnd);
		break;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
			case BUTTON_CDROM:
				_CDorHu = 1; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_CUE:
				_CDorHu = 2; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_HUCARD:
				_CDorHu = 3; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_REPLAY:
				_CDorHu = 4; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_OPTION:
				soundBuffer = 0; //全項目の値が設定されたかどうかの判断にも使用。
				OPTION_Init(_hInstance, &screenType, &drawMode, &drawMethod, &vsync, &psgType, &soundBuffer); //Optionウィンドウを表示
				//メッセージループ
				while (soundBuffer == 0) //ダイアログが結果を返すまでループ
				{ 
					GetMessage(&msg ,NULL, 0, 0);
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
				//Ok(SET)ボタンが押されていた場合、スクリーン設定を変更する。
				if (screenType > 0)
				{
					switch (screenType)
					{
						case 1:	APP_SetStartFullScreen(FALSE); break;
						case 2:
							APP_SetMagnification(2); //x2倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 3:
							APP_SetMagnification(3); //x3倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 4:
							APP_SetMagnification(4); //x4倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 5:	APP_SetStartFullScreen(TRUE); break;
						case 6:
							APP_SetFullScreen640(); //640x480に設定
							APP_SetStartFullScreen(TRUE);
							break;
					}
				}
				//Ok(SET)ボタンが押されていた場合、DrawMode設定を変更する。
				if (drawMode > 0)
				{
					switch (drawMode)
					{
						case 1: APP_SetScanLineType(1,TRUE); break;
						case 2: APP_SetScanLineType(4,TRUE); break;
						case 3: APP_SetScanLineType(2,TRUE); break;
						case 4: APP_SetScanLineType(0,TRUE); break;
					}
				}
				//Ok(SET)ボタンが押されていた場合、DrawMethod設定を変更する。
				if (drawMethod > 0)
				{
					APP_SetDrawMethod(drawMethod);
				}
				//Ok(SET)ボタンが押されていた場合、V-Sync設定を変更する。
				if (screenType > 0)
				{
					if (vsync == 2)
						APP_SetSyncTo60HzScreen(FALSE);
					else //==1
						APP_SetSyncTo60HzScreen(TRUE);
				}
				//Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。
				if (psgType > 0)
				{
					if (psgType == 3)
						APP_SetPsgQuality(1);
					else if (psgType == 2)
						APP_SetPsgQuality(2);
					else //==1
						APP_SetPsgQuality(4);
				}
				//Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。
				if (soundBuffer > 0)
				{
					switch (soundBuffer)
					{
						case  1: APP_SetSoundBufferSize(1024); break;
						case  2: APP_SetSoundBufferSize(1152); break;
						case  3: APP_SetSoundBufferSize(1280); break;
						case  4: APP_SetSoundBufferSize(1408); break;
						case  5: APP_SetSoundBufferSize(1536); break;
						case  7: APP_SetSoundBufferSize(1792); break;
						case  8: APP_SetSoundBufferSize(2048); break;
						case  9: APP_SetSoundBufferSize(2176); break;
						case 10: APP_SetSoundBufferSize(2304); break;
						case 11: APP_SetSoundBufferSize(2560); break;
						case 12: APP_SetSoundBufferSize(3072); break;
						default: //==6
							APP_SetSoundBufferSize(1664); break;
					}
				}
				break;
		}
		break;

	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		if ((wParam == 'C')||(wParam == VK_RETURN)) //「C」キーまたは 「Enter」キー
		{
			_CDorHu = 1; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if (wParam == 'P') //「P」キー
		{
			_CDorHu = 2; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if ((wParam == 'H')||(wParam == 'O')||(wParam == VK_SPACE)) //「H」キー「O」キーまたは スペースキー
		{
			_CDorHu = 3; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if (wParam == 'R') //「R」キー
		{
			_CDorHu = 4; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		break;

	case WM_CLOSE:
		STARTUP_Deinit();
		return 0;
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
    //------------------------------------------------------------------------
    int platform_support::run()
    {
        SDL_Event event;
        bool ev_flag = false;

        for(;;)
        {
            if(m_specific->m_update_flag)
            {
                on_draw();
                update_window();
                m_specific->m_update_flag = false;
            }

            ev_flag = false;
            if(m_wait_mode)
            {
                SDL_WaitEvent(&event);
                ev_flag = true;
            }
            else
            {
                if(SDL_PollEvent(&event))
                {
                    ev_flag = true;
                }
                else
                {
                    on_idle();
                }
            }

            if(ev_flag)
            {
                if(event.type == SDL_QUIT)
                {
                    break;
                }

                int y;
                unsigned flags = 0;

                switch (event.type) 
                {
                case SDL_VIDEORESIZE:
                    if(!init(event.resize.w, event.resize.h, m_window_flags)) return false;
                    on_resize(m_rbuf_window.width(), m_rbuf_window.height());
                    trans_affine_resizing(event.resize.w, event.resize.h);
                    m_specific->m_update_flag = true;
                    break;

                case SDL_KEYDOWN:
                    {
                        flags = 0;
                        if(event.key.keysym.mod & KMOD_SHIFT) flags |= kbd_shift;
                        if(event.key.keysym.mod & KMOD_CTRL)  flags |= kbd_ctrl;

                        bool left  = false;
                        bool up    = false;
                        bool right = false;
                        bool down  = false;

                        switch(event.key.keysym.sym)
                        {
                        case key_left:
                            left = true;
                            break;

                        case key_up:
                            up = true;
                            break;

                        case key_right:
                            right = true;
                            break;

                        case key_down:
                            down = true;
                            break;
                        }

                        if(m_ctrls.on_arrow_keys(left, right, down, up))
                        {
                            on_ctrl_change();
                            force_redraw();
                        }
                        else
                        {
                            on_key(m_specific->m_cur_x,
                                   m_specific->m_cur_y,
                                   event.key.keysym.sym,
                                   flags);
                        }
                    }
                    break;

                case SDL_MOUSEMOTION:
                    y = m_flip_y ? 
                        m_rbuf_window.height() - event.motion.y : 
                        event.motion.y;

                    m_specific->m_cur_x = event.motion.x;
                    m_specific->m_cur_y = y;
                    flags = 0;
                    if(event.motion.state & SDL_BUTTON(1)) flags |= mouse_left;
                    if(event.motion.state & SDL_BUTTON(3)) flags |= mouse_right;

                    if(m_ctrls.on_mouse_move(m_specific->m_cur_x, 
                                             m_specific->m_cur_y,
                                             (flags & mouse_left) != 0))
                    {
                        on_ctrl_change();
                        force_redraw();
                    }
                    else
                    {
                        on_mouse_move(m_specific->m_cur_x, 
                                      m_specific->m_cur_y, 
                                      flags);
                    }
		    SDL_Event eventtrash;
		    while (SDL_PeepEvents(&eventtrash, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION))!=0){;}
                    break;

                case SDL_MOUSEBUTTONDOWN:
                    y = m_flip_y ? 
                        m_rbuf_window.height() - event.motion.y : 
                        event.motion.y;

                    m_specific->m_cur_x = event.motion.x;
                    m_specific->m_cur_y = y;
                    flags = 0;
                    if(event.button.button == SDL_BUTTON_LEFT)  flags = mouse_left;
                    if(event.button.button == SDL_BUTTON_RIGHT) flags = mouse_right;

                    if(flags & mouse_left)
                    {
                        if(m_ctrls.on_mouse_button_down(m_specific->m_cur_x, 
                                                        m_specific->m_cur_y))
                        {
                            m_ctrls.set_cur(m_specific->m_cur_x, 
                                            m_specific->m_cur_y);
                            on_ctrl_change();
                            force_redraw();
                        }
                        else
                        {
                            if(m_ctrls.in_rect(m_specific->m_cur_x, 
                                               m_specific->m_cur_y))
                            {
                                if(m_ctrls.set_cur(m_specific->m_cur_x, 
                                                   m_specific->m_cur_y))
                                {
                                    on_ctrl_change();
                                    force_redraw();
                                }
                            }
                            else
                            {
                                on_mouse_button_down(m_specific->m_cur_x, 
                                                     m_specific->m_cur_y, 
                                                     flags);
                            }
                        }
                    }
                    if(flags & mouse_right)
                    {
                        on_mouse_button_down(m_specific->m_cur_x, 
                                             m_specific->m_cur_y, 
                                             flags);
                    }
                    break;

                case SDL_MOUSEBUTTONUP:
                    y = m_flip_y ? 
                        m_rbuf_window.height() - event.motion.y : 
                        event.motion.y;

                    m_specific->m_cur_x = event.motion.x;
                    m_specific->m_cur_y = y;
                    flags = 0;
                    if(m_ctrls.on_mouse_button_up(m_specific->m_cur_x, 
                                                  m_specific->m_cur_y))
                    {
                        on_ctrl_change();
                        force_redraw();
                    }
                    on_mouse_button_up(m_specific->m_cur_x, 
                                       m_specific->m_cur_y, 
                                       flags);
                    break;
                }
            }
        }
        return 0;
    }
Exemple #21
0
/*
 * Tests if a progress bar repaints itself immediately when it receives
 * some specific messages.
 */
static void test_redraw(void)
{
    RECT client_rect, rect;
    HWND hProgressWnd;
    LRESULT ret;

    GetClientRect(hProgressParentWnd, &rect);
    hProgressWnd = CreateWindowExA(0, PROGRESS_CLASSA, "", WS_CHILD | WS_VISIBLE,
      0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
    ok(hProgressWnd != NULL, "Failed to create progress bar.\n");
    progress_wndproc = (WNDPROC)SetWindowLongPtrA(hProgressWnd, GWLP_WNDPROC, (LPARAM)progress_subclass_proc);

    ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
    ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
    flush_events();
    update_window(hProgressParentWnd);

    SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
    update_window(hProgressWnd);

    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 50, 0) == 10, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");

    /* PBM_DELTAPOS */
    ok(SendMessageA(hProgressWnd, PBM_DELTAPOS, 15, 0) == 50, "PBM_DELTAPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_DELTAPOS: The progress bar should be redrawn immediately\n");

    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 80, 0) == 65, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");

    /* PBM_STEPIT */
    ok(SendMessageA(hProgressWnd, PBM_STEPIT, 0, 0) == 80, "PBM_STEPIT must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_STEPIT: The progress bar should be redrawn immediately\n");
    ret = SendMessageA(hProgressWnd, PBM_GETPOS, 0, 0);
    if (ret == 0)
        win_skip("PBM_GETPOS needs comctl32 > 4.70\n");
    else
        ok(ret == 100, "PBM_GETPOS returned a wrong position : %d\n", (UINT)ret);

    /* PBM_SETRANGE and PBM_SETRANGE32:
    Usually the progress bar doesn't repaint itself immediately. If the
    position is not in the new range, it does.
    Don't test this, it may change in future Windows versions. */

    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    update_window(hProgressWnd);

    /* increase to 10 - no background erase required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(!erased, "Progress bar shouldn't have erased the background\n");

    /* decrease to 0 - background erase will be required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(erased, "Progress bar should have erased the background\n");

    DestroyWindow(hProgressWnd);
}
Exemple #22
0
static void process_event(
	EventRecord *event)
{
	WindowPtr window;
	short part_code;
	Rect size_rect;
	long new_size;
	GrafPtr old_port;

	switch(event->what)
	{
		case kHighLevelEvent:
				AEProcessAppleEvent(event);
			break;
	
		case mouseDown:
			/* Did we hit one of the floaters? */
			part_code= FindWindow(event->where, &window);
			
			switch (part_code)
			{
				case inSysWindow:
					break;
					
				case inMenuBar:
					do_menu_command(MenuSelect(event->where));
					break;
					
				case inContent:
					if(window != FrontWindow())
						SelectWindow(window);
					click_in_log_window(window,event->where,(event->modifiers & shiftKey) != 0);
					break;

				case inDrag:
			#ifdef OP_PLATFORM_MAC_CARBON_FLAG
					{
						Rect	tempRect;
						GetRegionBounds(GetGrayRgn(), &tempRect);
						DragWindow(window, event->where, &tempRect);
					}
					#else
						DragWindow(window, event->where, &qd.screenBits.bounds);
					#endif
					break;

				case inGrow:
			#ifdef OP_PLATFORM_MAC_CARBON_FLAG
						GetRegionBounds(GetGrayRgn(), &size_rect);
					#else
						size_rect = qd.screenBits.bounds;
					#endif
					InsetRect(&size_rect, 4, 4);
					new_size= GrowWindow(window, event->where, &size_rect);
					if(new_size) 
					{
						/* Resize the window */
						SizeWindow(window, LoWord(new_size), HiWord(new_size), true);
					}
					break;

				case inGoAway:
					if(TrackGoAway(window, event->where)) 
					{
						/* Close the window... */
						handle_close(window);
					}
					break;

				case inZoomIn:
				case inZoomOut:
					if(TrackBox(window, event->where, part_code)) 
					{
						GetPort(&old_port);
						SetPortWindowPort(window);
					#ifdef OP_PLATFORM_MAC_CARBON_FLAG
						{
							Rect windowBounds;
                                                
							GetWindowPortBounds(window, &windowBounds);
							EraseRect(&windowBounds);
						}
						#else
							EraseRect(&window->portRect);
						#endif
						
						ZoomWindow(window, part_code, true);
						SetPort(old_port);
					}
					break;
			}
			break;
		
		case keyDown:
		case autoKey:
			if(!process_key(event, event->message&charCodeMask))
			{
				/* Not handled by anyone.. */
				SysBeep(-1);
			}
			break;
			
		case updateEvt:
			/* Update the window.. */
			update_window((WindowPtr)event->message);
			break;
			
		case activateEvt:
			/* Activate event->message, event->modifiers&activeFlag.. */
			break;

		case osEvt:
			switch ((event->message>>24) & 0xff)
			{
				case suspendResumeMessage:
					if (event->message&resumeFlag)
					{
						/* resume */
					#ifdef OP_PLATFORM_MAC_CARBON_FLAG
						{
							Cursor		arrowCursor;
							SetCursor(GetQDGlobalsArrow(&arrowCursor));
						}
						#else
							SetCursor(&qd.arrow);
						#endif
					}
					else
					{
						/* suspend */
					}
					break;

				case mouseMovedMessage:
					break;
 			}
			break;
	}

	return;
}
	//------------------------------------------------------------------------
	void platform_support::force_redraw()
	{
		on_draw();
		update_window();
	}
Exemple #24
0
/**
 * Forwards message data to UDP receiver/server. Then takes in
 * and handles a UDP reply (ack)
 * 
 * @param[in] msg  Message to forward to the reciever
 * @param[in] receiver_ip  Host name of server (UDP)
 * @param[in] receiver_port  Server's port number (UDP)
 * @param[in] timeout Amount of time to wait for response before timing out and moving on
 */
void handle(char msg[], char *receiver_ip, char *receiver_port, struct timeval *timeout)
{
    int receiver_sock;
    struct addrinfo hints;
    struct addrinfo *serv_info;
    struct addrinfo *p;
    int rv;
    uint32_t *reply_seq;

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_DGRAM;

    /* Get the receiver's address information */
    if ((rv = getaddrinfo(receiver_ip, receiver_port, &hints, &serv_info)) != 0)
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        
        exit(1);
    }

    /* Loop through the results and make the first available socket */
    for(p = serv_info; p != NULL; p = p->ai_next)
    {
        if ((receiver_sock = socket(p->ai_family, p->ai_socktype,
                              p->ai_protocol)) == -1)
        {
            perror("talker: socket");
            
            continue;
        }

        break;
    }

    if (p == NULL)
    {
        fprintf(stderr, "talker: failed to create socket\n");
        
        exit(1);
    }
    
    /* Transfer the message to the receiver via UDP */
    transfer_msg_to_receiver(msg, receiver_sock, p);
    
    /* Make space for the reply sequence number */
    reply_seq = calloc(1, sizeof(*reply_seq));
    
    /* Get the ack (reply) from the receiver */
    if (get_reply_from_receiver(reply_seq, receiver_sock, p, timeout))
    {
        /* If we got a valid reply, print the ack value received */
        printf("Ack received: %i\n", *reply_seq);
    }
    else
    {
        /* If the reply failed, set the reply sequence number to NULL */
        reply_seq = NULL;
    }
    
    /* Then update the sliding window */
    update_window(reply_seq, (struct message *)msg);
    
    freeaddrinfo(serv_info);

    close(receiver_sock);
    
    free(reply_seq);
}
Exemple #25
0
int display_init(void *lcdbase, int fb_bits_per_pixel,
		 struct display_timing *timing)
{
	struct dc_ctlr *dc_ctlr;
	const void *blob = gd->fdt_blob;
	struct udevice *dp_dev;
	const int href_to_sync = 1, vref_to_sync = 1;
	int panel_bpp = 18;	/* default 18 bits per pixel */
	u32 plld_rate;
	struct gpio_desc vdd_gpio, enable_gpio;
	int pwm;
	int node;
	int ret;

	ret = uclass_get_device(UCLASS_DISPLAY, 0, &dp_dev);
	if (ret)
		return ret;

	node = fdtdec_next_compatible(blob, 0, COMPAT_NVIDIA_TEGRA124_DC);
	if (node < 0)
		return -ENOENT;
	dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
	if (fdtdec_decode_display_timing(blob, node, 0, timing))
		return -EINVAL;

	ret = display_update_config_from_edid(dp_dev, &panel_bpp, timing);
	if (ret) {
		debug("%s: Failed to decode EDID, using defaults\n", __func__);
		dump_config(panel_bpp, timing);
	}

	if (!get_backlight_info(blob, &vdd_gpio, &enable_gpio, &pwm)) {
		dm_gpio_set_value(&vdd_gpio, 1);
		debug("%s: backlight vdd setting gpio %08x to %d\n",
		      __func__, gpio_get_number(&vdd_gpio), 1);
	}

	/*
	 * The plld is programmed with the assumption of the SHIFT_CLK_DIVIDER
	 * and PIXEL_CLK_DIVIDER are zero (divide by 1). See the
	 * update_display_mode() for detail.
	 */
	plld_rate = clock_set_display_rate(timing->pixelclock.typ * 2);
	if (plld_rate == 0) {
		printf("dc: clock init failed\n");
		return -EIO;
	} else if (plld_rate != timing->pixelclock.typ * 2) {
		debug("dc: plld rounded to %u\n", plld_rate);
		timing->pixelclock.typ = plld_rate / 2;
	}

	/* Init dc */
	ret = tegra_dc_init(dc_ctlr);
	if (ret) {
		debug("dc: init failed\n");
		return ret;
	}

	/* Configure dc mode */
	ret = update_display_mode(dc_ctlr, timing, href_to_sync, vref_to_sync);
	if (ret) {
		debug("dc: failed to configure display mode\n");
		return ret;
	}

	/* Enable dp */
	ret = display_enable(dp_dev, panel_bpp, timing);
	if (ret)
		return ret;

	ret = update_window(dc_ctlr, (ulong)lcdbase, fb_bits_per_pixel, timing);
	if (ret)
		return ret;

	/* Set up Tegra PWM to drive the panel backlight */
	pwm_enable(pwm, 0, 220, 0x2e);
	udelay(10 * 1000);

	if (dm_gpio_is_valid(&enable_gpio)) {
		dm_gpio_set_value(&enable_gpio, 1);
		debug("%s: backlight enable setting gpio %08x to %d\n",
		      __func__, gpio_get_number(&enable_gpio), 1);
	}

	return 0;
}
Exemple #26
0
int GeoMapEditor::processKeys() // здесь обработка клавиш до выхода из цикла обработки данного кадра 
{
  //while (1)
  {
    int key = kNoKeyPressed;
    if (pressed_keys.size() > 0)
    {
      key = pressed_keys.front(); // пока не извлекаем...
    }
    // здесь обработка клавиш до выхода из цикла обработки данного кадра 

    if (key == kBackSpace)
    {
      pressed_keys.pop_front();
      if (gm.objects.size() > 0)
      {
        gm.objects.pop_back();
      }
//       FrameData& frame_data = marked_frames[iframe];
//       if (frame_data.objects.size()>0)
//       {
//         deleteFrameObjectImage(frame_data.objects.size()-1);
//         frame_data.objects.pop_back();
//       }
      update_image_to_draw();
      //draw();
      update_window();
      //continue;
    }
//     if (key == kF1)
//     {
//       pressed_keys.pop_front();
//       help();
//       continue;
//     }
//     if (key == kF2)
//     {
//       pressed_keys.pop_front();
//       saveMarkupData();
//       continue;
//     }
//     if (key == kF3)
//     {
//       pressed_keys.pop_front();
//       saveFrameImage();
//       continue;
//     }
//     if (key == kF4)
//     {
//       pressed_keys.pop_front();
//       saveFrameObjectsImages();
//       continue;
//     }
    if (key == kTab)
    {
      pressed_keys.pop_front();
      iObjType = (iObjType+1)% agmTypes.objTypes.size();
      cout << "G size " << pressed_keys.size() << endl;
      update_image_to_draw();
      update_window();
      //continue;
    }
// 
//     if (key == kEnter || key == kCtrlEnter 
//       || (key == kSpace && tracking_object) 
//       ) // start-stop tracking
//     {
//       pressed_keys.pop_front();
//       if (tracking_object) // stop tracking
//       {
//         tracking_object = false;
//         non_stop_mode = false;
//         update_image_to_draw();
//         update_window();
//         continue;
//       }
// 
//       if (!non_stop_mode && !tracking_object) // start tracking
//       { // start tracking mode
//         if (key == kEnter)
//           track_forward = true;
//         else if (key == kCtrlEnter)
//           track_forward = false;
//         else
//           assert(0); //третьего не дано
// 
//         FrameData& frame_data = marked_frames[iframe];
//         if (frame_data.objects.size() > 0)
//         {
//           AFrameObject* afo = frame_data.objects.back(); // или взять последний добавленный в undo() ?
//           non_stop_mode = true;
//           tracked_rect = afo->rect;
//           tracking_object = true;
//           cout << "Start tracking " << afo->type << afo->rect << endl;
//         }
// 
//         //vector< Rect > track_result;
//         //trackRectangle( video, afo->rect, 20, track_result );
//         // тут надо выгружать результаты track_result, 
//         // но пока не дотянут файл разметки до MarkupEditor.
//         // ...
//         update_image_to_draw();
//         //??update_window();
//         continue;
//       }
//     } // (key == kEnter)
    return key; // неизвестная клавиша -- снаружи разберутся
  } // while (1)
  return kNoKeyPressed;
}
Exemple #27
0
int
#ifdef ACTIVEGS
macmain
#else
main
#endif
  (int argc, char* argv[]) {
  ProcessSerialNumber my_psn;

  IBNibRef nibRef;
  EventHandlerUPP handlerUPP;
  EventTypeSpec cmd_event[3];
  GDHandle g_gdhandle;
  Rect win_rect;
  OSStatus err;
  char    *argptr;
  int slash_cnt;
  int i;

#ifndef ACTIVEGS
  /* Prepare argv0 */
  slash_cnt = 0;
  argptr = argv[0];
  for(i = strlen(argptr); i >= 0; i--) {
    if(argptr[i] == '/') {
      slash_cnt++;
      if(slash_cnt == 3) {
        strncpy(&(g_argv0_path[0]), argptr, i);
        g_argv0_path[i] = 0;
      }
    }
  }

  printf("g_argv0_path is %s\n", g_argv0_path);

  g_mac_argv[0] = argv[0];
  g_mac_argc = 1;
  i = 1;
  while((i < argc) && (g_mac_argc < MAX_MAC_ARGS)) {
    if(!strncmp(argv[i], "-psn", 4)) {
      /* skip this argument */
    } else {
      g_mac_argv[g_mac_argc++] = argv[i];
    }
    i++;
  }
#endif

  InitCursor();
  g_event_rgnhandle = NewRgn();
  g_status_font_family = FMGetFontFamilyFromName("\pCourier");

  SetRect(&win_rect, 0, 0, X_A2_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT
          // OG Remove status line from ActiveGS window
#ifndef ACTIVEGS
          + MAX_STATUS_LINES*16 + 8
#endif
          );
  OffsetRect(&win_rect, 64, 50);


  // Create a Nib reference passing the name of the nib file
  // CreateNibReference only searches into the application bundle.
  err = CreateNibReference(CFSTR("main"), &nibRef);
  require_noerr( err, CantGetNibRef );
  // Once the nib reference is created, set the menu bar.
  err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
  require_noerr( err, CantSetMenuBar );


#ifndef ACTIVEGS
  err = CreateNewWindow(kDocumentWindowClass,
                        kWindowStandardDocumentAttributes |
                        kWindowStandardHandlerAttribute,
                        &win_rect, &g_main_window);

  err = SetWindowTitleWithCFString(g_main_window, CFSTR("GSport"));
#else
  err = CreateNewWindow(kDocumentWindowClass,
                        (kWindowCloseBoxAttribute /*| kWindowFullZoomAttribute */| kWindowCollapseBoxAttribute /*| kWindowResizableAttribute*/) /*kWindowStandardDocumentAttributes*/ |
                        kWindowStandardHandlerAttribute,
                        &win_rect, &g_main_window);
  extern CFStringRef activeGSversionSTR;
  err = SetWindowTitleWithCFString(g_main_window, activeGSversionSTR);
#endif

  //printf("CreateNewWindow ret: %d, g_main_window: %p\n", (int)err, g_main_window);


  // We don't need the nib reference anymore.
  DisposeNibReference(nibRef);

  SysBeep(120);

  handlerUPP = NewEventHandlerUPP( my_cmd_handler );

  cmd_event[0].eventClass = kEventClassCommand;
  cmd_event[0].eventKind = kEventProcessCommand;
  InstallWindowEventHandler(g_main_window, handlerUPP, 1, &cmd_event[0],
                            (void *)g_main_window, NULL);

  handlerUPP = NewEventHandlerUPP(my_win_handler);
  cmd_event[0].eventClass = kEventClassWindow;
  cmd_event[0].eventKind = kEventWindowDrawContent;
  cmd_event[1].eventClass = kEventClassWindow;
  cmd_event[1].eventKind = kEventWindowUpdate;
  cmd_event[2].eventClass = kEventClassWindow;
  cmd_event[2].eventKind = kEventWindowClose;
  err = InstallWindowEventHandler(g_main_window, handlerUPP, 3,
                                  &cmd_event[0], (void *)g_main_window, NULL);
  require_noerr(err, CantCreateWindow);

  // Get screen depth
  g_gdhandle = GetGDevice();
  g_screen_mdepth = (**((**g_gdhandle).gdPMap)).pixelSize;

  g_screen_depth = g_screen_mdepth;

  if(g_screen_depth > 16) {
    /* 32-bit display */
    g_red_mask = 0xff;
    g_green_mask = 0xff;
    g_blue_mask = 0xff;

    /*
       if (macUsingCoreGraphics)
       {
            g_red_left_shift = 0;
            g_green_left_shift = 8;
            g_blue_left_shift = 16;
       }
       else
     */
    {
      g_red_left_shift = 16;
      g_green_left_shift = 8;
      g_blue_left_shift = 0;

    }

    g_red_right_shift = 0;
    g_green_right_shift = 0;
    g_blue_right_shift = 0;
  } else if(g_screen_depth > 8) {
    /* 16-bit display */
    g_red_mask = 0x1f;
    g_green_mask = 0x1f;
    g_blue_mask = 0x1f;
    g_red_left_shift = 10;
    g_green_left_shift = 5;
    g_blue_left_shift = 0;
    g_red_right_shift = 3;
    g_green_right_shift = 3;
    g_blue_right_shift = 3;
  }

  // show_alert("About to show window", (int)g_main_window);
  update_main_window_size();

  update_window();


  // The window was created hidden so show it.
  ShowWindow( g_main_window );
  BringToFront( g_main_window );

  update_window();

  // Make us pop to the front a different way
  err = GetCurrentProcess(&my_psn);
  if(err == noErr) {
    (void)SetFrontProcess(&my_psn);
  }

  // Call the event loop
  temp_run_application_event_loop();


CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
  show_simple_alert("ending", "", "error code", err);
  return err;
}
int main(int argc, char **argv){
    double time_io = 0, time_compute_build = 0, time_build = 0;
    double begin, end;
    
    // init
    begin = omp_get_wtime(); // io time

    load_arguements(argc, argv);
    read_body_file();
    if(X_enable){
        init_X();
    }

    end = omp_get_wtime(); // io time
    time_io = end - begin;

    // distribute simulation parts
    begin = omp_get_wtime(); // compute time

    if(body_num < thread_num){
        thread_num = body_num;
    }
    
    // simulate
    if(DEBUG){
        printf("start simulation......\n");
    }
    omp_set_num_threads(thread_num);
    next_bodies = new body_t[body_num]; 
    #pragma omp parallel
    {
        // T times simulation
        for(int t=0; t<T; t++){
            // build HB tree
            #pragma omp single
            {
                double b_begin, b_end;
                b_begin = omp_get_wtime(); // build time
                
                tree_clean(root);
                tree_get_range();
                root = tree_create_node(
                    body_max_x, body_min_x, body_max_y, body_min_y);
                for(int i=0; i<body_num; i++){
                    tree_insert_node(root, bodies+i);
                }

                b_end = omp_get_wtime(); // build time
                time_build += b_end - b_begin;
            }

            // next position
            #pragma omp for schedule(static)
            for(int n=0; n<body_num; n++){
                next_bodies[n].p_x = bodies[n].p_x + bodies[n].v_x * interval;
                next_bodies[n].p_y = bodies[n].p_y + bodies[n].v_y * interval;
            }
            
            // next velocity
            #pragma omp for schedule(static)
            for(int n=0; n<body_num; n++){
                double total_a_x = 0;
                double total_a_y = 0;
                tree_compute_a(&bodies[n], root, &total_a_x, &total_a_y);
                next_bodies[n].v_x = bodies[n].v_x + total_a_x * interval;
                next_bodies[n].v_y = bodies[n].v_y + total_a_y * interval;
            }

            // synchronize
            #pragma omp barrier

            // update bodies
            #pragma omp for schedule(static)
            for(int n=0; n<body_num; n++){
                bodies[n] = next_bodies[n];
            }

            // synchronize
            #pragma omp barrier

            // display
            #pragma omp single
            {
                if(X_enable){
                    update_window();
                }
            }
        }
    }
    if(DEBUG){
        printf("done\n");
    }

    delete [] next_bodies;
    delete [] bodies;

    end = omp_get_wtime(); // compute time
    time_compute_build = end - begin;

    printf("( Thread , Step , Body , IO , Build , Compute , Total ) -> ");
    printf("( %d , %d , %d , %lf , %lf , %lf , %lf )\n", thread_num, T, body_num, time_io, time_build, time_compute_build - time_build, time_io + time_compute_build);

    return 0;
}
int macmain(int argc, char* argv[])
{	
	update_window();
	return kegsmain(0,NULL);
}
Exemple #30
0
static int display_init(struct udevice *dev, void *lcdbase,
			int fb_bits_per_pixel, struct display_timing *timing)
{
	struct display_plat *disp_uc_plat;
	struct dc_ctlr *dc_ctlr;
	struct udevice *dp_dev;
	const int href_to_sync = 1, vref_to_sync = 1;
	int panel_bpp = 18;	/* default 18 bits per pixel */
	u32 plld_rate;
	int ret;

	/*
	 * Before we probe the display device (eDP), tell it that this device
	 * is the source of the display data.
	 */
	ret = uclass_find_first_device(UCLASS_DISPLAY, &dp_dev);
	if (ret) {
		debug("%s: device '%s' display not found (ret=%d)\n", __func__,
		      dev->name, ret);
		return ret;
	}

	disp_uc_plat = dev_get_uclass_platdata(dp_dev);
	debug("Found device '%s', disp_uc_priv=%p\n", dp_dev->name,
	      disp_uc_plat);
	disp_uc_plat->src_dev = dev;

	ret = uclass_get_device(UCLASS_DISPLAY, 0, &dp_dev);
	if (ret) {
		debug("%s: Failed to probe eDP, ret=%d\n", __func__, ret);
		return ret;
	}

	dc_ctlr = (struct dc_ctlr *)dev_read_addr(dev);
	if (ofnode_decode_display_timing(dev_ofnode(dev), 0, timing)) {
		debug("%s: Failed to decode display timing\n", __func__);
		return -EINVAL;
	}

	ret = display_update_config_from_edid(dp_dev, &panel_bpp, timing);
	if (ret) {
		debug("%s: Failed to decode EDID, using defaults\n", __func__);
		dump_config(panel_bpp, timing);
	}

	/*
	 * The plld is programmed with the assumption of the SHIFT_CLK_DIVIDER
	 * and PIXEL_CLK_DIVIDER are zero (divide by 1). See the
	 * update_display_mode() for detail.
	 */
	plld_rate = clock_set_display_rate(timing->pixelclock.typ * 2);
	if (plld_rate == 0) {
		printf("dc: clock init failed\n");
		return -EIO;
	} else if (plld_rate != timing->pixelclock.typ * 2) {
		debug("dc: plld rounded to %u\n", plld_rate);
		timing->pixelclock.typ = plld_rate / 2;
	}

	/* Init dc */
	ret = tegra_dc_init(dc_ctlr);
	if (ret) {
		debug("dc: init failed\n");
		return ret;
	}

	/* Configure dc mode */
	ret = update_display_mode(dc_ctlr, timing, href_to_sync, vref_to_sync);
	if (ret) {
		debug("dc: failed to configure display mode\n");
		return ret;
	}

	/* Enable dp */
	ret = display_enable(dp_dev, panel_bpp, timing);
	if (ret) {
		debug("dc: failed to enable display: ret=%d\n", ret);
		return ret;
	}

	ret = update_window(dc_ctlr, (ulong)lcdbase, fb_bits_per_pixel, timing);
	if (ret) {
		debug("dc: failed to update window\n");
		return ret;
	}
	debug("%s: ready\n", __func__);

	return 0;
}