コード例 #1
0
ファイル: texture.cpp プロジェクト: AutonomicStudios/godot
bool ImageTexture::_set(const StringName& p_name, const Variant& p_value) {

	if (p_name=="image" && p_value.get_type()==Variant::IMAGE)
		create_from_image( p_value,flags );
	else if (p_name=="flags")
		if (w*h==0)
			flags=p_value;
		else
			set_flags(p_value);
	else if (p_name=="size") {
		Size2 s = p_value;
		w=s.width;
		h=s.height;
		VisualServer::get_singleton()->texture_set_size_override(texture,w,h);
	} else if (p_name=="storage") {
		storage=Storage(p_value.operator int());
	} else if (p_name=="lossy_quality") {
		lossy_storage_quality=p_value;
	} else if (p_name=="_data") {
		_set_data(p_value);
	} else
		return false;

	return true;

}
コード例 #2
0
struct OlDisplayModule*
ol_display_module_new (const char *name)
{
  ol_assert_ret (name != NULL, NULL);
  struct OlDisplayModule *module = NULL;
  struct OlDisplayClass *klass = _get_class (name);
  if (klass == NULL)
  {
    ol_error ("Module %s not exists.\n", name);
    return NULL;
  }
  module = g_new0 (struct OlDisplayModule, 1);
  module->klass = klass;
  _set_data (module, klass->init (module));
  return module;
}
コード例 #3
0
ファイル: texture.cpp プロジェクト: Ranakhamis/godot
bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {

	if (p_name == "image")
		create_from_image(p_value, flags);
	else if (p_name == "flags")
		if (w * h == 0)
			flags = p_value;
		else
			set_flags(p_value);
	else if (p_name == "size") {
		Size2 s = p_value;
		w = s.width;
		h = s.height;
		VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
	} else if (p_name == "_data") {
		_set_data(p_value);
	} else
		return false;

	return true;
}
コード例 #4
0
ファイル: scrap_x11.c プロジェクト: gdos/pgreloaded.sdl12
/**
 * \brief System message filter function -- handles X11 clipboard messages.
 *
 * \param event The SDL_Event to check.
 * \return Always 1.
 */
static int
_clipboard_filter (const SDL_Event *event)
{
    _ClipData *datalist;
    Time timestamp = CurrentTime;

    /* Post all non-window manager specific events */
    if (event->type != SDL_SYSWMEVENT)
        return 1;

    XEvent xevent = event->syswm.msg->event.xevent;

    /* Handle window manager specific clipboard events */
    switch (xevent.type)
    {
    case PropertyNotify:
    {
        /* Handled in scrap_put_x11(). */
        break;
    }
    case SelectionClear:
    {
        XSelectionClearEvent *clear = &xevent.xselectionclear;

        /* Looks like another window takes control over the clipboard.
         * Release the internally saved buffer, if any.
         */
        if (clear->selection == XA_PRIMARY)
            timestamp = _selectiontime;
        else if(clear->selection == _atom_CLIPBOARD)
            timestamp = _cliptime;
        else
            break;

        /* Do not do anything, if the times do not match. */
        if (timestamp != CurrentTime && xevent.xselectionclear.time < timestamp)
            break;

        /* Clean the dictionaries. */
        if (clear->selection == XA_PRIMARY)
            free (_selectiondata);
        else if (clear->selection != _atom_CLIPBOARD)
            free (_clipboarddata);
        break;
    }
    case SelectionNotify:
        /* This one will be handled directly in the scrap_get_x11() function.
         */
        break;

    case SelectionRequest:
    {
        XSelectionRequestEvent *req = &xevent.xselectionrequest;
        XEvent ev;
        
        /* Prepare answer. */
        ev.xselection.type      = SelectionNotify;
        ev.xselection.display   = req->display;
        ev.xselection.requestor = req->requestor;
        ev.xselection.selection = req->selection;
        ev.xselection.target    = req->target;
        ev.xselection.property  = None;
        ev.xselection.time      = req->time;

        /* Which clipboard type was requested? */
        if (req->selection == XA_PRIMARY)
        {
            datalist = _selectiondata;
            timestamp = _selectiontime;
        }
        else if (req->selection == _atom_CLIPBOARD)
        {
            datalist = _clipboarddata;
            timestamp = _cliptime;

        }
        else /* Anything else's not supported. */
        {
            XSendEvent (req->display, req->requestor, False, NoEventMask, &ev);
            return 1;
        }

        /* No data? */
        if ((sizeof (datalist) / sizeof (datalist[0])) == 0)
        {
            XSendEvent (req->display, req->requestor, False, NoEventMask, &ev);
            return 1;
        }

        /* We do not own the selection anymore. */
        if (timestamp == CurrentTime
            || (req->time != CurrentTime && timestamp > req->time))
        {
            XSendEvent (req->display, req->requestor, False, NoEventMask, &ev);
            return 1;
        }

        /* 
         * TODO: We have to make it ICCCM compatible at some point by
         * implementing the MULTIPLE atom request.
         */

        /* Old client? */
        if (req->property == None)
            ev.xselection.property = req->target;
        
        /* TODO */
        if (req->target == _atom_TARGETS)
        {
            /* The requestor wants to know, what we've got. */
            _set_targets (datalist, req->display, req->requestor,
                req->property);
        }
        else
        {
            _set_data (datalist, req->display, req->requestor, req->property,
                req->target);
        }

        ev.xselection.property = req->property;
        /* Post the event for X11 clipboard reading above */
        XSendEvent (req->display, req->requestor, False, 0, &ev);
        break;
    }
    }
    return 1;
}