コード例 #1
0
ファイル: x11selection.c プロジェクト: farseerfc/fcitx
static boolean
X11TextConvertSelectionHelper(
    FcitxX11 *x11priv, Atom selection, Atom target, int format,
    size_t nitems, const void *buff, X11ConvertSelection *convert)
{
    boolean res = true;
    char *sel_str = XGetAtomName(x11priv->dpy, selection);
    if (!buff) {
        Atom new_tgt;
        if (target == x11priv->utf8Atom) {
            new_tgt = x11priv->compTextAtom;
        } else if (target == x11priv->compTextAtom) {
            new_tgt = x11priv->stringAtom;
        } else {
            new_tgt = None;
        }
        if (new_tgt != None) {
            fcitx_utils_local_cat_str(prop_str, 256, FCITX_X11_SEL, sel_str);
            Atom prop = XInternAtom(x11priv->dpy, prop_str, False);
            XConvertSelection(x11priv->dpy, selection, new_tgt, prop,
                              x11priv->eventWindow, CurrentTime);
            res = false;
            goto out;
        }
    }
    X11ConvertSelectionCallback cb;
    cb = (X11ConvertSelectionCallback)convert->func;
    char *tgt_str = XGetAtomName(x11priv->dpy, target);
    /* compound text also looks fine here, need more info.. */
    cb(convert->owner, sel_str, tgt_str, format, nitems, buff, convert->data);
    XFree(tgt_str);
out:
    XFree(sel_str);
    return res;
}
コード例 #2
0
ファイル: compzillaWindow.cpp プロジェクト: orph/pyro
nsresult
compzillaWindow::GetUTF8StringProperty (Atom prop, nsACString& utf8Value)
{
    SPEW ("GetUTF8StringProperty this=%p, prop=%s\n", this, XGetAtomName (mDisplay, prop));

    Atom actual_type;
    int format;
    unsigned long nitems;
    unsigned long bytes_after_return;
    unsigned char *data;

    if (XGetWindowProperty (mDisplay, 
                            mWindow, 
                            prop,
                            0,
                            BUFSIZ, 
                            false, 
                            AnyPropertyType,
                            &actual_type, 
                            &format, 
                            &nitems, 
                            &bytes_after_return, 
                            &data) != Success || 
        format == None) {
        SPEW (" + (Not Found)\n");
        return NS_ERROR_FAILURE;
    }

    if (actual_type == atoms.x.UTF8_STRING) {
        utf8Value = (char*)data;
    }
    else if (actual_type == XA_STRING) {
        char **list = NULL;
        int count;

        count = gdk_text_property_to_utf8_list (gdk_x11_xatom_to_atom (actual_type),
                                                format, data, nitems,
                                                &list);

        if (count == 0) {
            XFree (data);
            return NS_ERROR_FAILURE;
        }

        utf8Value = list[0];

        g_strfreev (list);
    }
    else {
        WARNING ("invalid type for string property '%s': '%s'\n",
                 XGetAtomName (mDisplay, prop),
                 XGetAtomName (mDisplay, actual_type));
        XFree (data);
        return NS_ERROR_FAILURE;
    }

    XFree (data);

    return NS_OK;
}
コード例 #3
0
ファイル: textwindow.c プロジェクト: barak/ivtools-cvs
void TextEditAppWindow::receive(const Event& e) 
{
   Atom atom;
   char* name;
   WindowRep& w = *Window::rep();
   DisplayRep& d = *w.display_->rep();
   XEvent& xe = e.rep()->xevent_;
   SelectionManager* s;
   switch (xe.type) {
   case SelectionRequest:
      // check type of selection
      atom = xe.xselectionrequest.selection;
      name = XGetAtomName(d.display_, atom);
      s = w.display_->find_selection(name);
      // request the selecton
      s->rep()->request(s, xe.xselectionrequest);
      XFree(name);
      break;
   case SelectionNotify:
      // check type of selection
      atom = xe.xselectionrequest.selection;
      name = XGetAtomName(d.display_, atom);
      s = w.display_->find_selection(name);
      // notify about the selection
      s->rep()->notify(s, xe.xselection);
      XFree(name);
   default:
      // pass everything else to Window::receive
      Window::receive(e);
      break;
   }
}
コード例 #4
0
ファイル: main.c プロジェクト: Oyatsumi/ulteo4Kode4kids
static void
cliprdr_process_selection_request(XEvent* e)
{
	XSelectionRequestEvent *req;
	XEvent respond;
	int clipboard_size;
	unsigned char* clipboard_data = NULL;

	req=&(e->xselectionrequest);
	log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_process_selection_request]: "
			"Request for %s\n", XGetAtomName(display, req->target));

	if (clipboard_format_supported(&clipboard, req->target))
	{
		if (!clipboard_current_clipboard_format_exist(&clipboard, req->target))
		{
			log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_process_selection_request]: "
					"Unable to find format %s", XGetAtomName(display, req->target));
			return;
		}

		clipboard_data = clipboard_get_current_clipboard_data(&clipboard, req->target);
		clipboard_size = clipboard_get_current_clipboard_data_size(&clipboard, req->target);
		log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_process_selection_request]: "
				"Update data with '%s'", clipboard_data);

		XChangeProperty (req->display,
			req->requestor,
			req->property,
			req->target,
			8,
			PropModeReplace,
			(unsigned char*) clipboard_data,
			clipboard_size);
		respond.xselection.property=req->property;
	}
	else if (req->target == targets_atom)
	{
		log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_process_selection_request]: "
				"Targets : '%s'", XGetAtomName(req->display, req->property));
		XChangeProperty (req->display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)clipboard.current_clipboard_formats->items, clipboard.current_clipboard_formats->count);
		respond.xselection.property=req->property;
	}
	else // Strings only please
	{
		printf ("No String %i\n",
			(int)req->target);
		respond.xselection.property= None;
	}
	respond.xselection.type= SelectionNotify;
	respond.xselection.display= req->display;
	respond.xselection.requestor= req->requestor;
	respond.xselection.selection=req->selection;
	respond.xselection.target= req->target;
	respond.xselection.time = req->time;
	XSendEvent (req->display, req->requestor,0,0,&respond);
	XFlush (req->display);
}
コード例 #5
0
JBoolean
TestWidget::WillAcceptDrop
(
    const JArray<Atom>&	typeList,
    Atom*				action,
    const Time			time,
    const JXWidget*		source
)
{
    JXDNDManager* dndMgr = GetDNDManager();

    if (typeList.GetFirstElement() == (GetSelectionManager())->GetURLXAtom())
    {
        cout << endl;
        cout << "Accepting the drop of type text/uri-list" << endl;
        cout << endl;

        *action = dndMgr->GetDNDActionPrivateXAtom();
        return kJTrue;
    }
    else if (*action == dndMgr->GetDNDActionCopyXAtom())
    {
        cout << endl;
        cout << "Accepting the drop" << endl;
        cout << endl;

        PrintSelectionText(dndMgr->GetDNDSelectionName(), time,
                           (GetSelectionManager())->GetMimePlainTextXAtom());
        return kJTrue;
    }
    else
    {
        JXDisplay* display = GetDisplay();

        cout << endl;
        cout << "Not accepting the drop because the action isn't copy" << endl;
        cout << "Action: " << XGetAtomName(*display, *action) << endl;
        cout << endl;
        cout << "Data types available from DND source:" << endl;
        cout << endl;

        const JSize typeCount = typeList.GetElementCount();
        for (JIndex i=1; i<=typeCount; i++)
        {
            const Atom type = typeList.GetElement(i);
            cout << XGetAtomName(*display, type) << endl;
        }
        cout << endl;

        PrintSelectionText(dndMgr->GetDNDSelectionName(), time,
                           (GetSelectionManager())->GetMimePlainTextXAtom());

        return kJFalse;
    }
}
コード例 #6
0
ファイル: x11_dragdrop.cpp プロジェクト: 12307/VLC-for-VS2010
void X11DragDrop::dndEnter( ldata_t data )
{
    Window src = data[0];
    m_xPos = m_yPos = -1;

    // Retrieve available data types
    list<string> dataTypes;
    if( data[1] & 1 )   // More than 3 data types ?
    {
        Atom type;
        int format;
        unsigned long nitems, nbytes;
        Atom *dataList;
        Atom typeListAtom = XInternAtom( XDISPLAY, "XdndTypeList", 0 );
        XGetWindowProperty( XDISPLAY, src, typeListAtom, 0, 65536, False,
                            XA_ATOM, &type, &format, &nitems, &nbytes,
                            (unsigned char**)&dataList );
        for( unsigned long i=0; i<nitems; i++ )
        {
            string dataType = XGetAtomName( XDISPLAY, dataList[i] );
            dataTypes.push_back( dataType );
        }
        XFree( (void*)dataList );
    }
    else
    {
        for( int i = 2; i < 5; i++ )
        {
            if( data[i] != None )
            {
                string dataType = XGetAtomName( XDISPLAY, data[i] );
                dataTypes.push_back( dataType );
            }
        }
    }

    // Find the right target
    m_target = None;
    list<string>::iterator it;
    for( it = dataTypes.begin(); it != dataTypes.end(); ++it )
    {
        if( *it == "text/uri-list" ||
            *it == "text/plain" ||
            *it == "STRING" )
        {
            m_target = XInternAtom( XDISPLAY, (*it).c_str(), 0 );
            break;
        }
    }

    // transmit DragEnter event
    EvtDragEnter evt( getIntf() );
    m_pWin->processEvent( evt );
}
コード例 #7
0
ファイル: bstxkb.c プロジェクト: whitelynx/beast
const gchar*
bst_xkb_get_symbol (gboolean physical)
{
  gchar *name;

  g_return_val_if_fail (bst_xkb_desc != NULL, NULL);

  if (physical)
    name = bst_xkb_desc->names->phys_symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->phys_symbols) : "";
  else
    name = bst_xkb_desc->names->symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->symbols) : "";

  return name;
}
コード例 #8
0
ファイル: x11selection.c プロジェクト: farseerfc/fcitx
static boolean
X11ConvertSelectionHelper(
    FcitxX11 *x11priv, Atom selection, Atom target, int format,
    size_t nitems, const void *buff, X11ConvertSelection *convert)
{
    X11ConvertSelectionCallback cb;
    cb = (X11ConvertSelectionCallback)convert->func;
    char *sel_str = XGetAtomName(x11priv->dpy, selection);
    char *tgt_str = XGetAtomName(x11priv->dpy, target);
    cb(convert->owner, sel_str, tgt_str, format, nitems, buff, convert->data);
    XFree(sel_str);
    XFree(tgt_str);
    return True;
}
コード例 #9
0
ファイル: libdark.c プロジェクト: grawity/hacks
void XSetTextProperty(Display *display, Window w, XTextProperty *text_prop, Atom property)
{
	static void (*real_XSetTextProperty)(Display *display, Window w,
						XTextProperty *text_prop,
						Atom property);
	const char *name;

	if (!real_XSetTextProperty)
		real_XSetTextProperty = dlsym(RTLD_NEXT, "XSetTextProperty");
	real_XSetTextProperty(display, w, text_prop, property);

	name = XGetAtomName(display, property);
	fprintf(stderr, "XSetTextProperty(0x%lx, '%s', '%s') = void\n",
		w, text_prop->value, XGetAtomName(display, property));
}
コード例 #10
0
ファイル: attributes.c プロジェクト: CSRedRat/mesa-1
PUBLIC
Status XvMCGetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int *value)
{
   XvMCContextPrivate *context_priv;
   const char *attr;

   assert(dpy);

   if (!context || !context->privData)
      return XvMCBadContext;

   context_priv = context->privData;

   attr = XGetAtomName(dpy, attribute);
   if (!attr)
      return XvMCBadContext;

   if (strcmp(attr, XV_BRIGHTNESS))
      *value = context_priv->procamp.brightness * 1000;
   else if (strcmp(attr, XV_CONTRAST))
      *value = context_priv->procamp.contrast * 1000 - 1000;
   else if (strcmp(attr, XV_SATURATION))
      *value = context_priv->procamp.saturation * 1000 + 1000;
   else if (strcmp(attr, XV_HUE))
      *value = context_priv->procamp.hue * 1000;
   else if (strcmp(attr, XV_COLORSPACE))
      *value = context_priv->color_standard == VL_CSC_COLOR_STANDARD_BT_709;
   else
      return BadName;

   XVMC_MSG(XVMC_TRACE, "[XvMC] Got value %d for attribute %s.\n", *value, attr);

   return Success;
}
コード例 #11
0
static void display_dndOutSend (char *bytes, int nbytes)
{
  XEvent notify;
  XSelectionEvent *res= &notify.xselection;
  Atom targetProperty= ((None == xdndOutRequestEvent.property)
			? xdndOutRequestEvent.target
			: xdndOutRequestEvent.property);

  res->type	  = SelectionNotify;
  res->display	  = xdndOutRequestEvent.display;
  res->requestor  = xdndOutRequestEvent.requestor;
  res->selection  = xdndOutRequestEvent.selection;
  res->target	  = xdndOutRequestEvent.target;
  res->time	  = xdndOutRequestEvent.time;
  res->send_event = True;
  res->property	  = targetProperty; /* override later if error */

  XChangeProperty(stDisplay, res->requestor,
		  targetProperty, xdndOutRequestEvent.target,
		  8, PropModeReplace,
		  (unsigned char *)bytes,
		  nbytes);

  XSendEvent(stDisplay, res->requestor, False, 0, &notify);
  fdebugf((stderr, "Send data for %s (output) requestor: 0x%lx\n",
           XGetAtomName(stDisplay, res->target), res->requestor));
}
コード例 #12
0
ファイル: main.c プロジェクト: dct/xvnkb
/*----------------------------------------------------------------------------*/
void VKRootWindowProcess(XEvent *event, void *data)
{
	char *name;

	if( event->type == ClientMessage ) {
		VKSystrayProcess(event);
		return;
	}

	name = XGetAtomName(display, ((XPropertyEvent *)event)->atom);
	if( name!=NULL ) { 
		if( !strcmp(name, VKP_CHARSET) )
			vk_charset = VKGetValue(display, ((XPropertyEvent *)event)->atom);
		else
		if( !strcmp(name, VKP_USING) )
			vk_using = VKGetValue(display, ((XPropertyEvent *)event)->atom);
		else
		if( !strcmp(name, VKP_METHOD) ) {
			extern void VKDrawIcon();
			vk_method = VKGetValue(display, ((XPropertyEvent *)event)->atom);
			VKDrawIcon();

			TRACE("GUI: %s\n", name);
		}
		XFree(name);
	}
}
コード例 #13
0
ファイル: properties.c プロジェクト: nowylie/space
void property_set( Display *conn, Window window, Atom property, property_t value )
{
   char *name = XGetAtomName( conn, property );
   
   XChangeProperty( conn, window, property, value.type, value.format,
         PropModeReplace, value.data, value.size );
}
コード例 #14
0
ファイル: lprop.c プロジェクト: gwowen/seismicunix
int
main(int argc, char **argv)
{
	Display *dpy;
	Atom *atom;
	int i,natoms;

	/* connect to X server */
	if ((dpy=XOpenDisplay(NULL))==NULL) {
		fprintf(stderr,"Cannot connect to display %s\n",
			XDisplayName(NULL));
		exit(-1);
	}

	/* list properties of root window */
	atom = XListProperties(dpy,DefaultRootWindow(dpy),&natoms);
	printf("Number of properties = %d\n",natoms);
	for (i=0; i<natoms; i++)
		printf("property[%d] = %s\n",i,XGetAtomName(dpy,atom[i]));

	/* close connection to X server */
	XCloseDisplay(dpy);

	return EXIT_SUCCESS;
}
コード例 #15
0
static void motDropTransferProc(Widget dropTransfer, Ihandle* ih, Atom *selType, Atom *typeAtom,
                                XtPointer targetData, unsigned long *length, int format)
{
  IFnsViii cbDropData;

  if(!targetData || !(*length))
    return;

  cbDropData = (IFnsViii)IupGetCallback(ih, "DROPDATA_CB");
  if(cbDropData)
  {
    /* TODO should we check for incompatible targets here? */
    char* type = XGetAtomName(iupmot_display, *typeAtom);
    int x = iupAttribGetInt(ih, "_IUPMOT_DROP_X");
    int y = iupAttribGetInt(ih, "_IUPMOT_DROP_Y");
    
    cbDropData(ih, type, (void*)targetData, (int)*length, x, y);

    iupAttribSet(ih, "_IUPMOT_DROP_X", NULL);
    iupAttribSet(ih, "_IUPMOT_DROP_Y", NULL);
  }

  (void)dropTransfer;
  (void)format;
  (void)selType;
}
コード例 #16
0
ファイル: sdl.c プロジェクト: AbnerChang/RiscVQemuPcat
static int check_for_evdev(void)
{
    SDL_SysWMinfo info;
    XkbDescPtr desc = NULL;
    int has_evdev = 0;
    char *keycodes = NULL;

    SDL_VERSION(&info.version);
    if (!SDL_GetWMInfo(&info)) {
        return 0;
    }
    desc = XkbGetKeyboard(info.info.x11.display,
                          XkbGBN_AllComponentsMask,
                          XkbUseCoreKbd);
    if (desc && desc->names) {
        keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
        if (keycodes == NULL) {
            fprintf(stderr, "could not lookup keycode name\n");
        } else if (strstart(keycodes, "evdev", NULL)) {
            has_evdev = 1;
        } else if (!strstart(keycodes, "xfree86", NULL)) {
            fprintf(stderr, "unknown keycodes `%s', please report to "
                    "[email protected]\n", keycodes);
        }
    }

    if (desc) {
        XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
    }
    if (keycodes) {
        XFree(keycodes);
    }
    return has_evdev;
}
コード例 #17
0
ファイル: kbdlayout.c プロジェクト: camilstaps/dotfiles
int main(void) {
    int evCode, errRet, rsnRet;
    int maj = XkbMajorVersion;
    int min = XkbMinorVersion;

    Display* disp = XkbOpenDisplay("", &evCode, &errRet, &maj, &min, &rsnRet);

    // State
    XkbStatePtr state = calloc(1, sizeof(XkbStateRec));
    XkbGetState(disp, 0x100, state);

    // Names
    XkbDescPtr desc = XkbAllocKeyboard();
    XkbGetNames(disp, XkbSymbolsNameMask, desc);

    Atom symNameAtom = desc->names->symbols;
    char* layouts = XGetAtomName(disp, symNameAtom);

    printf("%s\n", getActiveLayout(layouts, state->group));

    unsigned int mask = XkbStateNotifyMask;
    XkbSelectEvents(disp, XkbUseCoreKbd, mask, mask);

    XkbEvent event;
    while (1) {
        XNextEvent(disp, &event.core);
        if (event.state.changed & 0x90)
            printf("%s\n", getActiveLayout(layouts, event.state.group));
    }
}
コード例 #18
0
void CLowLevelKeyboard::Initialize(HWND hWnd)
{
  SDL_EnableUNICODE(1);
  // set repeat to 10ms to ensure repeat time < frame time
  // so that hold times can be reliably detected
  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 10);
#if defined(_LINUX) && !defined(__APPLE__)
  Display* dpy = XOpenDisplay(NULL);
  if (!dpy)
    return;

  XkbDescPtr desc;
  char* symbols;

  desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
  if(!desc)
  {
    XCloseDisplay(dpy);
    return;
  }

  symbols = XGetAtomName(dpy, desc->names->symbols);
  if(symbols)
  {
    CLog::Log(LOGDEBUG, "CLowLevelKeyboard::Initialize - XKb symbols %s", symbols);
    if(strstr(symbols, "(evdev)"))
      m_bEvdev = true;
  }

  XFree(symbols);
  XkbFreeKeyboard(desc, XkbAllComponentsMask, True);
  XCloseDisplay(dpy);
#endif
}
コード例 #19
0
ファイル: gnomekbd.c プロジェクト: carriercomm/VICE-Core
/* FIXME: add more languages, then copy to x11kbd.c */
int kbd_arch_get_host_mapping(void)
{

    int n;
    int maps[KBD_MAPPING_NUM] = {
        KBD_MAPPING_US, KBD_MAPPING_UK, KBD_MAPPING_DE, KBD_MAPPING_DA,
        KBD_MAPPING_NO, KBD_MAPPING_FI, KBD_MAPPING_IT };
    char str[KBD_MAPPING_NUM][3] = {
        "us", "uk", "de", "da", "no", "fi", "it"};

    Display* _display;
    char* displayName = "";
    _display = XOpenDisplay(displayName);

    XkbDescRec* _kbdDescPtr = XkbAllocKeyboard();
    XkbGetNames(_display, XkbSymbolsNameMask, _kbdDescPtr);
    Atom symName = _kbdDescPtr -> names -> symbols;
    char* layoutString = XGetAtomName(_display, symName);

    XCloseDisplay(_display);
    char *p = layoutString;

    if (memcmp(p, "pc+", 3) == 0) {
        p += 3;
        if (p && (strlen(p) > 1)) {
            for (n = 1; n < KBD_MAPPING_NUM; n++) {
                if (memcmp(p, str[n], 2) == 0) {
                    return maps[n];
                }
            }
        }
    }
    return KBD_MAPPING_US;
}
コード例 #20
0
ファイル: fontobject.c プロジェクト: kindlychung/sk1
static PyObject *
GetPropertyDict(PaxFontObject *self, PyObject *args)
{
    PyObject * dict = PyDict_New();
    XFontStruct * fs = self->font_struct;
    int nprop = fs->n_properties;
    int idx;
    char * name;
    PyObject * val;
    int result;

    if (!dict)
	return NULL;

    for (idx = 0; idx < nprop; idx++)
    {
	name = XGetAtomName(self->display, fs->properties[idx].name);
	val = PyInt_FromLong(fs->properties[idx].card32);
	if (!val)
	{
	    Py_DECREF(dict);
	    return NULL;
	}

	result = PyMapping_SetItemString(dict, name, val);
	Py_DECREF(val);
	if (result == -1)
	{
	    Py_DECREF(dict);
	    return NULL;
	}
    }
    return dict;
}
コード例 #21
0
static char*
atom_name (Display *display,
           Atom     atom)
{
  if (atom == None)
    {
      return my_strdup ("None");
    }
  else
    {
      char *xname;
      char *ret;

      error_trap_push (display);
      xname = XGetAtomName (display, atom);
      error_trap_pop (display);
      if (xname == NULL)
        return my_strdup ("[unknown atom]");

      ret = my_strdup (xname);
      XFree (xname);

      return ret;
    }
}
コード例 #22
0
static sqInt display_dndOutStart(char *types, int ntypes)
{
  int pos, i;
  int typesSize= 0;

  if (xdndOutTypes != 0)
    {
      free(xdndOutTypes);
      xdndOutTypes= 0;
    }

  for (pos= 0; pos < ntypes; pos += strlen(types + pos) + 1)
    typesSize++;

  if (typesSize > 3) return 0; /* Supported types are up to 3 now */

  xdndOutTypes= xmalloc(sizeof(Atom) * (typesSize + 1));
  xdndOutTypes[typesSize]= None;

  for (pos= 0, i= 0; pos < ntypes; pos += strlen(types + pos) + 1, i++)
    xdndOutTypes[i]= XInternAtom(stDisplay, types + pos, False);

  for (i= 0; i < typesSize; i++)
    fdebugf((stderr, "dndOutStart: %s\n", XGetAtomName(stDisplay, xdndOutTypes[i])));
  dndHandleEvent(DndOutStart, 0);

  return 1;
}
コード例 #23
0
ファイル: rotated.c プロジェクト: JeffersonLab/clas12-coda
static RotatedTextItem *XRotRetrieveFromCache(Display* dpy, 
					      XFontStruct* font, 
					      float angle, 
					      char* text, 
					      int align)
{
    Font fid;
    char *font_name = NULL;
    long unsigned int    name_value;
    RotatedTextItem *item=NULL;
    RotatedTextItem *i1=first_text_item;
    
    /* get font name, if it exists */
    if(XGetFontProperty(font, XA_FONT, &name_value)) {
	  DEBUG_PRINT1("got font name OK\n");
	  font_name=XGetAtomName(dpy, name_value);
	  fid=0;
    }
#ifdef CACHE_FID
    /* otherwise rely (unreliably?) on font ID */
    else {
	  DEBUG_PRINT1("can't get fontname, caching FID\n");
	  font_name=NULL;
	  fid=font->fid;
    }
#else
    /* not allowed to cache font ID's */
    else {
コード例 #24
0
static gboolean
utf8_string_from_results (GetPropertyResults *results,
                          char              **str_p)
{
  *str_p = NULL;
  
  if (!validate_or_free_results (results, 8,
                                 results->display->atom_UTF8_STRING, FALSE))
    return FALSE;

  if (results->n_items > 0 &&
      !g_utf8_validate ((gchar *)results->prop, results->n_items, NULL))
    {
      char *name;

      name = XGetAtomName (results->display->xdisplay, results->xatom);
      meta_warning (_("Property %s on window 0x%lx contained invalid UTF-8\n"),
                    name, results->xwindow);
      meta_XFree (name);
      XFree (results->prop);
      results->prop = NULL;
      
      return FALSE;
    }
  
  *str_p = (char*) results->prop;
  results->prop = NULL;
  
  return TRUE;
}
コード例 #25
0
ファイル: python-virtkey.c プロジェクト: Dhiru/Inputability-1
/* returns a plus-sign separated string of all keyboard layouts */
static PyObject * virtkey_get_layout_symbols(PyObject * self,
                                             PyObject * noargs)
{
    PyObject * result = NULL;
    virtkey * cvirt  = (virtkey *)self;
    Display * display = cvirt->display;

    if (!cvirt->kbd->names || !cvirt->kbd->names->symbols)
        PyErr_SetString(virtkey_error, "no symbols names available");
    else{
        char * symbols = XGetAtomName(display, cvirt->kbd->names->symbols);
        if (symbols){
            result = PyString_FromString(symbols);
            XFree(symbols);
        }
    }

    if (PyErr_Occurred())
        return NULL;

    if (!result)
        Py_RETURN_NONE;

    return result;
}
コード例 #26
0
ファイル: xevil.c プロジェクト: enadam/various
/* Get the name of $atom and cache it. */
static char *get_atom(Display *dpy, Atom atom)
{
	static GHashTable *cache;
	char *name;

	if (!atom)
		return "None";
	if (!cache)
	{	/* Make sure we can store Atom:s in $cache. */
		typedef int ass[-!(sizeof(gint) == sizeof(atom))];
		cache = g_hash_table_new(g_int_hash, g_int_equal);
	} else if ((name = g_hash_table_lookup(cache, &atom)) != NULL)
		/* $cache hit */
		return name;

	Error = 0;
	name = XGetAtomName(dpy, atom);
	if (Error)
	{
		name = g_strdup_printf("%lx", atom);
	} else if (name[0] == '\0')
	{
		XFree(name);
		name = "\"\"";
	} else if (strspn(name, " ,"))
	{
		char *tmp;
		name = g_strdup_printf("\"%s\"", tmp = name);
		XFree(tmp);
	}

	g_hash_table_insert(cache, &atom, name);
	return name;
} /* get_atom */
コード例 #27
0
ファイル: dragsource.c プロジェクト: cneira/wmaker-crm
/* ----- selection procs ----- */
static WMData *convertSelection(WMView * view, Atom selection, Atom target, void *cdata, Atom * type)
{
	WMScreen *scr;
	WMData *data;
	char *typeName;

	/* Parameter not used, but tell the compiler that it is ok */
	(void) selection;
	(void) cdata;

	scr = W_VIEW_SCREEN(view);
	typeName = XGetAtomName(scr->display, target);

	*type = target;

	if (view->dragSourceProcs->fetchDragData != NULL) {
		data = view->dragSourceProcs->fetchDragData(view, typeName);
	} else {
		data = NULL;
	}

	if (typeName != NULL)
		XFree(typeName);

	return data;
}
コード例 #28
0
ファイル: sdl.c プロジェクト: cailiwei/mini2440-qemu
static int check_for_evdev(void)
{
    SDL_SysWMinfo info;
    XkbDescPtr desc;
    int has_evdev = 0;
    const char *keycodes;

    SDL_VERSION(&info.version);
    if (!SDL_GetWMInfo(&info))
        return 0;

    desc = XkbGetKeyboard(info.info.x11.display,
                          XkbGBN_AllComponentsMask,
                          XkbUseCoreKbd);
    if (desc == NULL || desc->names == NULL)
        return 0;

    keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
    if (keycodes == NULL)
        fprintf(stderr, "could not lookup keycode name\n");
    else if (strstart(keycodes, "evdev", NULL))
        has_evdev = 1;
    else if (!strstart(keycodes, "xfree86", NULL))
        fprintf(stderr,
                "unknown keycodes `%s', please report to [email protected]\n",
                keycodes);

    XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);

    return has_evdev;
}
コード例 #29
0
ファイル: xfitman.cpp プロジェクト: Devoter/razor-qt
QString XfitMan::debugWindow(Window wnd)
{
    if (!wnd)
        return QString("[%1]").arg(wnd,8, 16);

    QString typeStr;
    int  format;
    unsigned long type, length, rest, *data;
    length=0;
    if (XGetWindowProperty(QX11Info::display(), wnd, XInternAtom(QX11Info::display(), "_NET_WM_WINDOW_TYPE", False),
                           0, 4096, FALSE, AnyPropertyType, &type, &format,
                           &length, &rest,(unsigned char**) &data) == Success)
    {
        for (unsigned int i = 0; i < length; i++)
        {
            char* aname = XGetAtomName(QX11Info::display(), data[i]);
            typeStr = typeStr + " " + aname;
            XFree(aname);
        }
    }
    else
        typeStr ="ERROR";

    return QString("[%1] %2 %3").arg(wnd,8, 16).arg(xfitMan().getName(wnd)).arg(typeStr);
}
コード例 #30
0
ファイル: DropTrans.c プロジェクト: att/uwin
static void
terminate_transfer(Widget dt, Atom *select)
{
    Atom how;

    DEBUGOUT(_LtDebug(__FILE__, dt, "%s:terminate_transfer(%d) - drag context %s receiver info %s %s\n",
    	__FILE__, __LINE__,
    	DT_DragContext(dt) ? "Yes" : "No",
    	DC_CurrReceiverInfo(DT_DragContext(dt)) ?  "Yes" : "No",
    	XGetAtomName(XtDisplay(dt), *select)
    	));

    if (DT_TransferStatus(dt) == XmTRANSFER_SUCCESS)
    {
	how = XmInternAtom(XtDisplay(dt), _XA_XmTRANSFER_SUCCESS, False);
    }
    else
    {
	how = XmInternAtom(XtDisplay(dt), _XA_XmTRANSFER_FAILURE, False);
    }

    if (DT_DragContext(dt) && DC_CurrReceiverInfo(DT_DragContext(dt)) && DC_CurrReceiverInfo(DT_DragContext(dt))->shell)
    {
	XtGetSelectionValue(DC_CurrReceiverInfo(DT_DragContext(dt))->shell,
			*select, how, notified_callback, (XtPointer)dt,
			DT_Timestamp(dt));
    }
}