Beispiel #1
0
static Bool
ResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve,
		       XawIcTableList p)
{
    XVaNestedList		pe_attr, st_attr;
    XRectangle			pe_area, st_area;
    XRectangle			*get_pe_area = NULL, *get_st_area = NULL;

    st_area.width = 0;
    if (p->input_style & XIMStatusArea) {
	st_attr = XVaCreateNestedList(0, XNArea, &get_st_area, NULL);
	XGetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
	XFree(st_attr);
	if (p->xic == NULL) {
	    return(FALSE);
	}
	st_area.x = 0;
	st_area.y = vw->core.height - ve->im.area_height;
	st_area.width = get_st_area->width;
	st_area.height = get_st_area->height;
	XFree(get_st_area);
	st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
	XSetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
	XFree(st_attr);
	if (p->xic == NULL) {
	    return(FALSE);
	}
    }
    if (p->input_style & XIMPreeditArea) {
	pe_attr = XVaCreateNestedList(0, XNArea, &get_pe_area, NULL);
	XGetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
	XFree(pe_attr);
	if (p->xic == NULL) {
	    return(FALSE);
	}
	pe_area.x = st_area.width;
	pe_area.y = vw->core.height - ve->im.area_height;
	pe_area.width = vw->core.width;
	pe_area.height = get_pe_area->height;
	if (p->input_style & XIMStatusArea) {
	    pe_area.width -= st_area.width;
	}
	XFree(get_pe_area);
	pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
	XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
	XFree(pe_attr);
    }
    return(TRUE);
}
void
CXWindowsPrimaryScreen::onPostOpen()
{
	assert(m_window != None);

	// get cursor info
	m_screen->getCursorPos(m_x, m_y);
	m_screen->getCursorCenter(m_xCenter, m_yCenter);

	// get the input method
	CDisplayLock display(m_screen);
	m_im = XOpenIM(display, NULL, NULL, NULL);
	if (m_im == NULL) {
		return;
	}

	// find the appropriate style.  synergy supports XIMPreeditNothing
	// only at the moment.
	XIMStyles* styles;
	if (XGetIMValues(m_im, XNQueryInputStyle, &styles, NULL) != NULL ||
		styles == NULL) {
		LOG((CLOG_WARN "cannot get IM styles"));
		return;
	}
	XIMStyle style = 0;
	for (unsigned short i = 0; i < styles->count_styles; ++i) {
		style = styles->supported_styles[i];
		if ((style & XIMPreeditNothing) != 0) {
			if ((style & (XIMStatusNothing | XIMStatusNone)) != 0) {
				break;
			}
		}
	}
	XFree(styles);
	if (style == 0) {
		LOG((CLOG_WARN "no supported IM styles"));
		return;
	}

	// create an input context for the style and tell it about our window
	m_ic = XCreateIC(m_im, XNInputStyle, style, XNClientWindow, m_window, NULL);
	if (m_ic == NULL) {
		LOG((CLOG_WARN "cannot create IC"));
		return;
	}

	// find out the events we must select for and do so
	unsigned long mask;
	if (XGetICValues(m_ic, XNFilterEvents, &mask, NULL) != NULL) {
		LOG((CLOG_WARN "cannot get IC filter events"));
		return;
	}
	XWindowAttributes attr;
	XGetWindowAttributes(display, m_window, &attr);
	XSelectInput(display, m_window, attr.your_event_mask | mask);

	// no previous keycode
	m_lastKeycode = 0;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_setupIMEventMask(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong xic_ptr) {
	Display *disp = (Display *)(intptr_t)display_ptr;
	Window win = (Window)window_ptr;
	XIC xic = (XIC)(intptr_t)xic_ptr;
	long im_event_mask;
	XWindowAttributes win_attributes;

	XGetWindowAttributes(disp, win, &win_attributes);
	XGetICValues(xic, XNFilterEvents, &im_event_mask, NULL);
	XSelectInput(disp, win, win_attributes.your_event_mask | im_event_mask);
	XSetICFocus(xic);
}
Beispiel #4
0
void
rxvt_term::IMSetPosition ()
{
  XRectangle preedit_rect, status_rect, *needed_rect;
  XVaNestedList preedit_attr, status_attr;

  if (!Input_Context
      || !focus
      || !(input_style & (XIMPreeditArea | XIMPreeditPosition))
      || !IMisRunning ())
    return;

  if (input_style & XIMPreeditPosition)
    {
      im_set_size (preedit_rect);
      preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL);

      XSetICValues (Input_Context,
                    XNPreeditAttributes, preedit_attr, NULL);
    }
  else
    {
      /* Getting the necessary width of preedit area */
      status_attr = XVaCreateNestedList (0, XNAreaNeeded, &needed_rect, NULL);
      XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL);
      XFree (status_attr);

      im_set_preedit_area (preedit_rect, status_rect, *needed_rect);
      XFree (needed_rect);

      preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL);
      status_attr  = XVaCreateNestedList (0, XNArea, &status_rect,  NULL);

      XSetICValues (Input_Context,
                    XNPreeditAttributes, preedit_attr,
                    XNStatusAttributes,  status_attr,
                    NULL);

      XFree (status_attr);
    }

   XFree (preedit_attr);
}
Beispiel #5
0
/* get_im_height: returns height of the input method status area in pixels.
 *
 * This function assumes that if any XIM related information cannot be
 * queried then the app must not have an input method status area in the
 * current locale and returns zero as the status area height
 */
int32_t
awt_motif_getIMStatusHeight(Widget w, jobject tc)
{
    XIC xic = NULL;
    XRectangle *im_rect=NULL;
    int32_t im_height = 0;
    char *ret;

    xic = XmImGetXIC(getTextWidget(tc), XmPER_SHELL, NULL, 0);

    if(xic != NULL) {
        /* finally query the server for the status area geometry */
        xic_vlist[0].name = XNArea;
        xic_vlist[0].value = (XtArgVal)&im_rect;
        xic_vlist[1].name = NULL;
        ret=XGetICValues(xic, XNStatusAttributes, &xic_vlist[0], NULL);
        if (ret == NULL && im_rect != NULL) {
            im_height = im_rect->height;
            if (im_height > 0) {
                im_height += SEPARATOR_HEIGHT;
            }
            XFree(im_rect);
        } else {
            im_height = 0;
        }
    }

    if (im_height == 0) {
        im_height = _XmImGetGeo(w);
    }

#if defined(DEBUG)
    jio_fprintf(stderr,"awt_motif_getIMStatusHeight: Height = %d",im_height);
#endif
    return im_height;
}
Beispiel #6
0
static void
_ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx)
{
   EINA_LOG_DBG("%s in", __FUNCTION__);
#ifdef ENABLE_XIM
   XIC ic;
   Ecore_IMF_Context_Data *imf_context_data;
   char *result;

   /* restore conversion state after resetting ic later */
   XIMPreeditState preedit_state = XIMPreeditUnKnown;
   XVaNestedList preedit_attr;
   Eina_Bool have_preedit_state = EINA_FALSE;

   imf_context_data = ecore_imf_context_data_get(ctx);
   EINA_SAFETY_ON_NULL_RETURN(imf_context_data);

   ic = imf_context_data->ic;
   if (!ic)
     return;

   if (imf_context_data->preedit_length == 0)
     return;

   preedit_attr = XVaCreateNestedList(0,
                                      XNPreeditState, &preedit_state,
                                      NULL);
   if (!XGetICValues(ic,
                     XNPreeditAttributes, preedit_attr,
                     NULL))
     have_preedit_state = EINA_TRUE;

   XFree(preedit_attr);

   result = XmbResetIC(ic);

   preedit_attr = XVaCreateNestedList(0,
                                      XNPreeditState, preedit_state,
                                      NULL);
   if (have_preedit_state)
     XSetICValues(ic,
                  XNPreeditAttributes, preedit_attr,
                  NULL);

   XFree(preedit_attr);

   if (imf_context_data->feedbacks)
     {
        free(imf_context_data->feedbacks);
        imf_context_data->feedbacks = NULL;
     }

   if (imf_context_data->preedit_length)
     {
        imf_context_data->preedit_length = 0;
        free(imf_context_data->preedit_chars);
        imf_context_data->preedit_chars = NULL;

        ecore_imf_context_preedit_changed_event_add(ctx);
        ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL);
     }

   if (result)
     {
        char *result_utf8 = strdup(result);
        if (result_utf8)
          {
             ecore_imf_context_commit_event_add(ctx, result_utf8);
             ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_COMMIT, result_utf8);
             free(result_utf8);
          }
     }

   XFree(result);
#else
   (void)ctx;
#endif
}
Beispiel #7
0
void
x_window_rep::initialize () {
  SI min_w= Min_w, min_h= Min_h;
  SI def_w= Def_w, def_h= Def_h;
  SI max_w= Max_w, max_h= Max_h;

  dpy= gui->dpy;
  gc = gui->gc;
  full_screen_flag= false;

  // time_t start_1= texmacs_time ();
  ren->set_origin (0, 0);
  ren->decode (def_w, def_h); def_h= -def_h;
  ren->decode (min_w, min_h); min_h= -min_h;
  ren->decode (max_w, max_h); max_h= -max_h;
  // cout << "Size computation required " << (texmacs_time ()-start_1) << " ms\n";

  // time_t start_2= texmacs_time ();
  unsigned long valuemask= CWOverrideRedirect | CWSaveUnder;
  //unsigned long valuemask= CWOverrideRedirect | CWSaveUnder | CWBackingStore;
  XSetWindowAttributes setattr;
  setattr.override_redirect= (name==NULL);
  setattr.save_under       = True; // (name==NULL);
  // setattr.backing_store    = Always;
  // FIXME: backing store does not seem to work correctly
  if (win_w == 0) win_w= def_w;
  if (win_h == 0) win_h= def_h;
  if ((win_x+ win_w) > gui->screen_width) win_x= gui->screen_width- win_w;
  if (win_x < 0) win_x= 0;
  if ((win_y+ win_h) > gui->screen_height) win_y= gui->screen_height- win_h;
  if (win_y < 0) win_y=0;
  win= XCreateWindow (dpy, gui->root, win_x, win_y, win_w, win_h, 0,
		      gui->depth, InputOutput, CopyFromParent,
		      valuemask, &setattr);
  ren->win= (Drawable) win;
  // cout << "XWindow creation required " << (texmacs_time ()-start_2) << " ms\n";

  //cout << "Hints: "
  //     << min_w << ", " << min_h << " --- "
  //     << def_w << ", " << def_h << " --- "
  //     << max_w << ", " << max_h << "\n";
  if (name == NULL) name= const_cast<char*> ("popup");
  if (the_name == "") {
    the_name= name;
    mod_name= name;
  }
  set_hints (min_w, min_h, max_w, max_h);

  unsigned long ic_mask= 0;
  ic_ok= false;
  if (gui->im_ok) {
    ic= XCreateIC (gui->im,
		   XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
		   XNClientWindow, win,
		   NULL);
    if (ic == NULL)
      cout << "TeXmacs] Warning: couldn't create input context\n";
    else {
      ic_ok= true;
      XGetICValues (ic, XNFilterEvents, &ic_mask, NULL);
    }
  }

  XSelectInput (dpy, win,
		ExposureMask | StructureNotifyMask |
		SubstructureNotifyMask | FocusChangeMask |
		PointerMotionMask | EnterWindowMask | LeaveWindowMask |
		ButtonPressMask | ButtonReleaseMask |
		KeyPressMask | ic_mask);

  Atom wm_protocols     = XInternAtom(dpy, "WM_PROTOCOLS", 1);
  Atom wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", 1);
  XSetWMProtocols (dpy, win, &wm_protocols, 1);
  XSetWMProtocols (dpy, win, &wm_delete_window, 1);

  nr_windows++;
  Window_to_window (win)= (void*) this;
  set_identifier (w, (int) win);
  notify_position (w, 0, 0);
  notify_size (w, Def_w, Def_h);
}
Beispiel #8
0
int main_loop(int argc, char *argv[])
{
    setup_language();
    se_env* env = se_env_init();
    se_text_xviewer* viewer = se_text_xviewer_create( env );
    
    long im_event_mask;
    XGetICValues( viewer->xic, XNFilterEvents, &im_event_mask, NULL );

    int mask = ExposureMask | ButtonPressMask | ButtonReleaseMask
        | KeyPressMask | KeyReleaseMask | SubstructureNotifyMask
        | FocusChangeMask
        | im_event_mask;
    XSelectInput( env->display, viewer->view, mask );
    XSetICFocus( viewer->xic );
    
    viewer->repaint( viewer );    
    viewer->show( viewer );
    
    while ( 1 ) { // sync the first expose event
        XEvent ev;
        XNextEvent( env->display, &ev );
        if ( ev.xany.window == viewer->view && ev.type == Expose ) {
            viewer->redisplay( viewer );
            break;
        }
    }

    while( !env->exitLoop ) {
        XEvent ev;
        XNextEvent( env->display, &ev );
        if ( XFilterEvent( &ev, None ) == True ) {
            se_debug("IM filtered event: %s", XEventTypeString(ev.type) );
            continue;
        }
        
        if ( ev.xany.window != viewer->view ) {
            se_msg( "skip event does not forward to view" );
            continue;
        }
        
        switch( ev.type ) {
        case Expose:
            se_debug( "Expose" );
            if ( ev.xexpose.count > 0 )
                break;

            viewer->redisplay( viewer );
            break;

        case KeyPress:
        case KeyRelease:
            viewer->key_handler( viewer, &ev );
            break;

        case ConfigureNotify:
        case MapNotify:
            se_debug( "confiugration changed" );
            viewer->configure_change_handler( viewer, &ev );
            break;

        default:
            break;
        }
    }

    se_debug( "exit loop" );

    XUnsetICFocus( viewer->xic );
    XDestroyIC( viewer->xic );
    se_env_release( env );
    return 0;
}
int32_t
awt_motif_getIMStatusHeight(Widget vw, jobject tc)
{
    XmICStruct *icp;
    XmVendorShellExtObject ve;
    XmWidgetExtData extData;
    XmImInfo *im_info;
    int32_t width = 0;
    int32_t height = 0;
    XRectangle rect;
    XRectangle *rp;
    int32_t old_height;
    Arg args[1];
    int32_t base_height;
    XFontSet fs;
    XFontSet fss = NULL;
    XFontSet fsp = NULL;

    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) vw, XmSHELL_EXTENSION);
    ve = (XmVendorShellExtObject) extData->widget;

    if ((icp = get_iclist(vw)) == NULL) {
	ve->vendor.im_height = 0;
	return 0;
    }
    im_info = (XmImInfo *) ve->vendor.im_info;
    if (im_info->xic == NULL) {
	ve->vendor.im_height = 0;
	return 0;
    }
    status_vlist[0].name = XNFontSet;
    status_vlist[1].name = NULL;
    preedit_vlist[0].name = XNFontSet;
    preedit_vlist[1].name = NULL;

    xic_vlist[0].name = XNAreaNeeded;
    xic_vlist[1].name = NULL;

    im_info->status_width = 0;
    im_info->status_height = 0;
    im_info->preedit_width = 0;
    im_info->preedit_height = 0;
    for (; icp != NULL; icp = icp->next) {
	if (im_info->input_style & XIMStatusArea) {
	    if (icp->status_height == 0) {
		char *ret;

		if (icp->font_list == NO_ARG_VAL ||
		    (fss = extract_fontset((XmFontList) icp->font_list)) == NULL)
		    continue;

		status_vlist[0].value = (XtArgVal) fss;
		XSetICValues(im_info->xic,
			     XNStatusAttributes, &status_vlist[0],
			     NULL);

		xic_vlist[0].value = (XtArgVal) & rp;
		ret = XGetICValues(im_info->xic,
				   XNStatusAttributes, &xic_vlist[0],
				   NULL);

		if (ret) {
		    /* Cannot obtain XIC value. IM server may be gone. */
		    ve->vendor.im_height = 0;
		    return 0;
		} else {
		    icp->status_width = rp->width;
		    icp->status_height = rp->height;
		    XFree(rp);
		}
	    }
	    if (icp->status_width > im_info->status_width)
		im_info->status_width = icp->status_width;
	    if (icp->status_height > im_info->status_height)
		im_info->status_height = icp->status_height;
	}
	if (im_info->input_style & XIMPreeditArea) {
	    if (icp->preedit_height == 0) {
		if (icp->font_list == NO_ARG_VAL ||
		    (fsp = extract_fontset((XmFontList) icp->font_list)) == NULL)
		    continue;

		preedit_vlist[0].value = (XtArgVal) fsp;
		XSetICValues(im_info->xic,
			     XNPreeditAttributes, &preedit_vlist[0],
			     NULL);

		xic_vlist[0].value = (XtArgVal) & rp;
		XGetICValues(im_info->xic,
			     XNPreeditAttributes, &xic_vlist[0],
			     NULL);

		icp->preedit_width = rp->width;
		icp->preedit_height = rp->height;
		XFree(rp);
	    }
	    if (icp->preedit_width > im_info->preedit_width)
		im_info->preedit_width = icp->preedit_width;
	    if (icp->preedit_height > im_info->preedit_height)
		im_info->preedit_height = icp->preedit_height;
	}
    }

    if (im_info->current != NULL && (fss != NULL || fsp != NULL)) {
	if (im_info->current->font_list != NO_ARG_VAL &&
	    (fs = extract_fontset((XmFontList) im_info->current->font_list))
	    != NULL) {
	    if (fss != NULL)
		status_vlist[0].value = (XtArgVal) fs;
	    else
		status_vlist[0].name = NULL;
	    if (fsp != NULL)
		preedit_vlist[0].value = (XtArgVal) fs;
	    else
		preedit_vlist[0].name = NULL;
	    XSetICValues(im_info->xic,
			 XNStatusAttributes, &status_vlist[0],
			 XNPreeditAttributes, &preedit_vlist[0],
			 NULL);
	}
    }
    if (im_info->status_height > im_info->preedit_height)
	height = im_info->status_height;
    else
	height = im_info->preedit_height;
    old_height = ve->vendor.im_height;
    if (height)
	height += SEPARATOR_HEIGHT;

    ve->vendor.im_height = height;

    XtSetArg(args[0], XtNbaseHeight, &base_height);
    XtGetValues(vw, args, 1);
    if (base_height < 0)
	base_height = 0;
    XtSetArg(args[0], XtNbaseHeight, base_height);
    XtSetValues(vw, args, 1);
    return height;
}
Beispiel #10
0
XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc)
{
    XIC xic;

    XRectangle *im_rect;
    XFontSet   *im_font;

    Pixel bg ;
    Pixel fg ;
    Dimension height, width ;
    Position x,y ;

    XVaNestedList list = NULL;

    char *ret;
    Widget p=w;

    while (!XtIsShell(p)) {
        p = XtParent(p);
    }

    XtVaGetValues(p,
        XmNx, &x,
        XmNy, &y,
        XmNwidth, &width,
        XmNheight, &height,
        XmNbackgroundPixmap, &bpm,
        NULL);



    xic = XmImGetXIC(getTextWidget(tc), XmPER_SHELL, NULL, 0);
    if(xic == NULL)
    {
#if defined DEBUG
        jio_fprintf(stderr,"Could not get XIC");
#endif
        return list ;
    }

   /* finally query the server for the required attributes area geometry */
    xic_vlist[0].name = XNFontSet ;
    xic_vlist[0].value =  (XtArgVal) &im_font ;
    xic_vlist[1].name = XNArea;
    xic_vlist[1].value = (XtArgVal) &im_rect;
    xic_vlist[2].name = XNBackground ;
    xic_vlist[2].value = (XtArgVal) &bg ;
    xic_vlist[3].name = XNForeground ;
    xic_vlist[3].value = (XtArgVal) &fg ;
    xic_vlist[4].name = NULL;


    if(ret=XGetICValues(xic, XNStatusAttributes, &xic_vlist[0], NULL))
    {
        return list ;
    } else {
        geomRect.x = 0 ;
        geomRect.y = height - im_rect->height ;
        geomRect.width = im_rect->width ;
        geomRect.height = im_rect->height ;
        XFree(im_rect) ;

        list = XVaCreateNestedList(0 ,
                        XNFontSet, im_font ,
                        XNArea, &geomRect ,
                        XNBackground, bg ,
                        XNForeground, fg ,
                        XNBackgroundPixmap, &bpm ,
                        NULL );
    }
#if defined(DEBUG)
    jio_fprintf(stderr,"awt_motif_getXICStatusAreaList:\n");
    jio_fprintf(stderr,"XNArea:x=%d,y=%d,width=%d,height=%d\n", \
         geomRect.x,geomRect.y,geomRect.width,geomRect.height);
    jio_fprintf(stderr,"XNBackground=0x%x\n",bg);
    jio_fprintf(stderr,"XNForeground=0x%x\n",fg);
    jio_fprintf(stderr,"XNBackgroundPixmap=0x%x\n",bpm);
#endif
    return list ;

}
Beispiel #11
0
static int
window_open(glw_x11_t *gx11, int fullscreen)
{
  XSetWindowAttributes winAttr;
  unsigned long mask;
  XTextProperty text;
  char buf[60];
  int fevent, x, y, w, h;

  winAttr.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask |
    ButtonPressMask | ButtonReleaseMask |
    PointerMotionMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask;

  winAttr.background_pixmap = None;
  winAttr.background_pixel  = 0;
  winAttr.border_pixel      = 0;

  winAttr.colormap = gx11->colormap = 
    XCreateColormap(gx11->display, gx11->root,
		    gx11->xvi->visual, AllocNone);
  
  mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;

  if(fullscreen) {

    x = 0;
    y = 0;
    w = gx11->screen_width;
    h = gx11->screen_height;

    winAttr.override_redirect = True;
    mask |= CWOverrideRedirect;

  } else {

    x = gx11->screen_width  / 4;
    y = gx11->screen_height / 4;
    w = gx11->req_width  ?: 853;
    h = gx11->req_height ?: 480;
  }

  gx11->win = 
    XCreateWindow(gx11->display,
		  gx11->root,
		  x, y, w, h,
		  0,
		  gx11->xvi->depth, InputOutput,
		  gx11->xvi->visual, mask, &winAttr
		  );

  gx11->gr.gr_width  = w;
  gx11->gr.gr_height = h;

  gx11->glxctx = glXCreateContext(gx11->display, gx11->xvi, NULL, 1);

  if(gx11->glxctx == NULL) {
    TRACE(TRACE_ERROR, "GLW", "Unable to create GLX context on \"%s\"\n",
	    gx11->displayname_real);
    return 1;
  }


  glXMakeCurrent(gx11->display, gx11->win, gx11->glxctx);

  XMapWindow(gx11->display, gx11->win);

  /* Set window title */
  snprintf(buf, sizeof(buf), "Showtime");

  text.value = (unsigned char *)buf;
  text.encoding = XA_STRING;
  text.format = 8;
  text.nitems = strlen(buf);
  
  XSetWMName(gx11->display, gx11->win, &text);

  /* Create the window deletion atom */
  XSetWMProtocols(gx11->display, gx11->win, &gx11->atom_deletewindow, 1);

  if(fullscreen)
    fullscreen_grab(gx11);

  glw_opengl_init_context(&gx11->gr);

  if(gx11->glXSwapIntervalSGI != NULL && gx11->force_no_vsync ==0)
    gx11->glXSwapIntervalSGI(1);

  gx11->working_vsync = check_vsync(gx11);

  if(!gx11->working_vsync) {

    if(strstr((const char *)glGetString(GL_VENDOR) ?: "", "NVIDIA")) {
      TRACE(TRACE_ERROR, "GLW", 
	    "OpenGL on \"%s\" does not sync to vertical blank.\n"
	    "This is required for Showtime's OpenGL interface to\n"
	    "function property. Please fix this.\n",
	    gx11->displayname_real);
      return 1;
    }

    TRACE(TRACE_INFO, "GLW", 
	  "OpenGL driver does not provide adequate vertical sync "
	  "capabilities. Using soft timers");
  }

  hide_cursor(gx11);
  
  /* X Input method init */
  if(gx11->im != NULL) {
    gx11->ic = XCreateIC(gx11->im,
			 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
			 XNClientWindow, gx11->win,
			 NULL);
    XGetICValues(gx11->ic, XNFilterEvents, &fevent, NULL);

    XSelectInput(gx11->display, gx11->win, fevent | winAttr.event_mask);
  } else {
    TRACE(TRACE_INFO, "GLW", "Unable to enable keyboard input compositioning");
  }
  return 0;
}
Beispiel #12
0
void emX11WindowPort::PreConstruct()
{
	XSetWindowAttributes xswa;
	XWMHints xwmh;
	XClassHint xch;
	XSizeHints xsh;
	XGCValues xgcv;
	long eventMask,extraEventMask;
	double vrx,vry,vrw,vrh,d;
	int border;
	bool haveBorder;

	if ((GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0) {
		Screen.LeaveFullscreenModes(&GetWindow());
		Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh);
		MinPaneW=1;
		MinPaneH=1;
		PaneX=(int)(vrx+0.5);
		PaneY=(int)(vry+0.5);
		PaneW=(int)(vrw+0.5);
		PaneH=(int)(vrh+0.5);
		BorderL=0;
		BorderT=0;
		BorderR=0;
		BorderB=0;
		haveBorder=false;
		Focused=true;
	}
	else if ((GetWindowFlags()&(emWindow::WF_POPUP|emWindow::WF_UNDECORATED))!=0) {
		Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh);
		MinPaneW=1;
		MinPaneH=1;
		PaneX=(int)(vrx+vrw*emGetDblRandom(0.22,0.28)+0.5);
		PaneY=(int)(vry+vrh*emGetDblRandom(0.22,0.28)+0.5);
		PaneW=(int)(vrw*0.5+0.5);
		PaneH=(int)(vrh*0.5+0.5);
		BorderL=0;
		BorderT=0;
		BorderR=0;
		BorderB=0;
		haveBorder=false;
		Focused=true;
	}
	else {
		Screen.LeaveFullscreenModes(&GetWindow());
		Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh);
		MinPaneW=32;
		MinPaneH=32;
		if (!Owner && (GetWindowFlags()&emWindow::WF_MODAL)==0) {
			d=emMin(vrw,vrh)*0.08;
			PaneX=(int)(vrx+d*emGetDblRandom(0.5,1.5)+0.5);
			PaneY=(int)(vry+d*emGetDblRandom(0.8,1.2)+0.5);
			PaneW=(int)(vrw-d*2.0+0.5);
			PaneH=(int)(vrh-d*2.0+0.5);
		}
		else {
			PaneX=(int)(vrx+vrw*emGetDblRandom(0.22,0.28)+0.5);
			PaneY=(int)(vry+vrh*emGetDblRandom(0.22,0.28)+0.5);
			PaneW=(int)(vrw*0.5+0.5);
			PaneH=(int)(vrh*0.5+0.5);
		}
		// Some window managers seem to expect that we would expect this:
		BorderL=3;
		BorderT=18;
		BorderR=3;
		BorderB=3;
		haveBorder=true;
		if ((GetWindowFlags()&emWindow::WF_MODAL)!=0) Focused=true;
		else Focused=false;
	}
	ClipX1=PaneX;
	ClipY1=PaneY;
	ClipX2=PaneX+PaneW;
	ClipY2=PaneY+PaneH;
	PosForced=false;
	PosPending=false;
	SizeForced=false;
	SizePending=false;
	InvalidRects.Set(PaneX,PaneY,PaneX+PaneW,PaneY+PaneH);
	Title.Empty();
	TitlePending=true;
	IconPending=true;
	Cursor=-1;
	CursorPending=true;
	PostConstructed=false;
	Mapped=false;
	InputStateClock=0;
	LastButtonPress=EM_KEY_NONE;
	RepeatKey=EM_KEY_NONE;
	memset(&ComposeStatus,0,sizeof(ComposeStatus));

	memset(&xsh,0,sizeof(xsh));
	xsh.flags     =PMinSize;
	xsh.min_width =MinPaneW;
	xsh.min_height=MinPaneH;

	eventMask=
		ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|
		KeyPressMask|KeyReleaseMask|StructureNotifyMask|SubstructureNotifyMask|
		VisibilityChangeMask|FocusChangeMask
	;

	memset(&xswa,0,sizeof(xswa));
	xswa.bit_gravity=ForgetGravity;
	xswa.colormap=Screen.Colmap;
	xswa.event_mask=eventMask;

	if (haveBorder) {
		xswa.override_redirect=False;
		border=1;
	}
	else {
		xswa.override_redirect=True;
		border=0;
	}

	XMutex.Lock();
	Win=XCreateWindow(
		Disp,
		Screen.RootWin,
		PaneX-BorderL,
		PaneY-BorderT,
		PaneW,
		PaneH,
		border,
		Screen.VisuDepth,
		InputOutput,
		Screen.Visu,
		CWBitGravity|CWColormap|CWEventMask|CWOverrideRedirect,
		&xswa
	);
	XMutex.Unlock();

	Screen.WCThread->AddWindow(Win);

	if (Owner) {
		XMutex.Lock();
		XSetTransientForHint(Disp,Win,Owner->Win);
		XMutex.Unlock();
	}

	if (Screen.InputMethod) {
		XMutex.Lock();
		InputContext=XCreateIC(
			Screen.InputMethod,
			XNInputStyle,XIMPreeditNothing|XIMStatusNothing,
			XNClientWindow,Win,
			(char*)NULL
		);
		XMutex.Unlock();
		if (InputContext==NULL) {
			emFatalError("Failed to create X input context.");
		}
	}
	else {
		InputContext=NULL;
	}

	if (InputContext) {
		XMutex.Lock();
		XGetICValues(InputContext,XNFilterEvents,&extraEventMask,(char*)NULL);
		XMutex.Unlock();
		eventMask|=extraEventMask;
	}
	XMutex.Lock();
	XSelectInput(Disp,Win,eventMask);
	XMutex.Unlock();

	memset(&xwmh,0,sizeof(xwmh));
	xwmh.flags=(InputHint|StateHint);
	xwmh.input=True;
	xwmh.initial_state=NormalState;

	memset(&xch,0,sizeof(xch));
	xch.res_name =(char*)GetWMResName().Get();
	xch.res_class=(char*)"EagleMode";

	XMutex.Lock();
	XmbSetWMProperties(Disp,Win,Title.Get(),NULL,NULL,0,&xsh,&xwmh,&xch);
	XMutex.Unlock();

	XMutex.Lock();
	XChangeProperty(
		Disp,
		Win,
		Screen.WM_PROTOCOLS,
		XA_ATOM,
		32,
		PropModeReplace,
		(const unsigned char*)&Screen.WM_DELETE_WINDOW,
		1
	);
	XMutex.Unlock();

	memset(&xgcv,0,sizeof(xgcv));
	XMutex.Lock();
	Gc=XCreateGC(Disp,Win,0,&xgcv);
	XMutex.Unlock();

	SetViewFocused(Focused);
	SetViewGeometry(PaneX,PaneY,PaneW,PaneH,Screen.PixelTallness);

	WakeUp();
}
Beispiel #13
0
static void
SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
{
    XRectangle		pe_area, st_area;
    XVaNestedList	pe_attr = NULL, st_attr = NULL;
    int			ic_cnt = 0;
    XRectangle		*pe_area_needed = NULL, *st_area_needed = NULL;
    XPointer		ic_a[5];

    if (p->input_style & XIMPreeditArea) {
	pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
    }
    if (p->input_style & XIMStatusArea) {
	st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
    }
    ic_a[ic_cnt] = (XPointer) NULL;

    if (ic_cnt > 0) {
	XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
	if (pe_attr) XFree(pe_attr);
	if (st_attr) XFree(st_attr);
	if (p->xic == NULL) {
	    p->openic_error = True;
	    return;
	}
	pe_attr = st_attr = NULL;
	ic_cnt = 0;
	if (p->input_style & XIMStatusArea) {
	    st_area.height = st_area_needed->height;
	    st_area.x = 0;
	    st_area.y = height - st_area.height;
	    if (p->input_style & XIMPreeditArea) {
		st_area.width = st_area_needed->width;
	    } else {
		st_area.width = width;
	    }

	    XFree(st_area_needed);
	    st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
	    ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
	    ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
	}
	if (p->input_style & XIMPreeditArea) {
	    if (p->input_style & XIMStatusArea) {
		pe_area.x = st_area.width;
		pe_area.width = width - st_area.width;
	    } else {
		pe_area.x = 0;
		pe_area.width = width;
	    }
	    pe_area.height = pe_area_needed->height;
	    XFree(pe_area_needed);
	    pe_area.y = height - pe_area.height;
	    pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
	    ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
	    ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
	}
	ic_a[ic_cnt] = (XPointer) NULL;
	XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
	if (pe_attr) XFree(pe_attr);
	if (st_attr) XFree(st_attr);
	if (p->xic == NULL) {
	    p->openic_error = True;
	    return;
	}
    }
}
Beispiel #14
0
/*
 * Try to open a XIM with the current modifiers, then see if we can
 * open a suitable preedit type
 */
bool
rxvt_term::IM_get_IC (const char *modifiers)
{
  int i, j, found;
  XIM xim;
  XPoint spot;
  XRectangle rect, status_rect, needed_rect;
  unsigned long fg, bg;
  const char *p;
  char **s;
  XIMStyles *xim_styles;
#ifdef ENABLE_XIM_ONTHESPOT
  XIMCallback xcb[4];
#endif

  set_environ (envv);

  if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
    return false;

  input_method = display->get_xim (locale, modifiers);
  if (input_method == NULL)
    return false;

  xim = input_method->xim;
  spot.x = spot.y = -1;

  xim_styles = NULL;
  if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
      || !xim_styles || !xim_styles->count_styles)
    {
      im_destroy ();
      return false;
    }

  const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" };

  for (int pi = 0; pi < 2; pi++)
    {
      p = pet[pi];

      if (!p)
        continue;

      s = rxvt_splitcommastring (p);

      for (i = found = 0; !found && s[i]; i++)
        {
          if (!strcmp (s[i], "OverTheSpot"))
            input_style = XIMPreeditPosition | XIMStatusNothing;
          else if (!strcmp (s[i], "OffTheSpot"))
            input_style = XIMPreeditArea | XIMStatusArea;
          else if (!strcmp (s[i], "Root"))
            input_style = XIMPreeditNothing | XIMStatusNothing;
          else if (!strcmp (s[i], "None"))
            input_style = XIMPreeditNone | XIMStatusNone;
#ifdef ENABLE_XIM_ONTHESPOT
          else if (SHOULD_INVOKE (HOOK_XIM_PREEDIT_START) && !strcmp (s[i], "OnTheSpot"))
            input_style = XIMPreeditCallbacks | XIMStatusNothing;
#endif
          else
            input_style = XIMPreeditNothing | XIMStatusNothing;

          for (j = 0; j < xim_styles->count_styles; j++)
            if (input_style == xim_styles->supported_styles[j])
              {
                rxvt_freecommastring (s);

                found = 1;
                goto foundpet;
              }

        }

      rxvt_freecommastring (s);
    }

foundpet:

  XFree (xim_styles);

  if (!found)
    {
      im_destroy ();
      return false;
    }

  XFontSet fs = 0;
  XVaNestedList preedit_attr = 0, status_attr = 0;

  if (input_style & (XIMPreeditPosition | XIMPreeditArea))
    {
      // fake us a font-set, please
      char **missing_charset_list;
      int missing_charset_count;
      char *def_string;
      char pat[512];

      sprintf (pat,
               "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
               "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
               "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
               "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
               "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
               "*",
               fheight,
               fheight + 1, fheight - 1,
               fheight - 2, fheight + 2);

      fs = XCreateFontSet (dpy, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
                           &missing_charset_list, &missing_charset_count, &def_string);

      if (missing_charset_list)
        XFreeStringList (missing_charset_list);

      if (!fs)
        {
          input_style &= ~(XIMPreeditPosition | XIMPreeditArea);
          rxvt_warn ("unable to create fontset for input method, try \"-pt Root\". Continuing.\n");
        }
    }

  if (input_style & XIMPreeditPosition)
    {
      im_set_size (rect);
      im_set_position (spot);
      im_set_color (fg, bg);

      preedit_attr = XVaCreateNestedList (0,
                                          XNForeground, fg,
                                          XNBackground, bg,
                                          XNArea, &rect,
                                          XNSpotLocation, &spot,
                                          XNFontSet, fs,
                                          NULL);
    }
  else if (input_style & XIMPreeditArea)
    {
      im_set_color (fg, bg);

      /*
       * The necessary width of preedit area is unknown
       * until create input context.
       */
      needed_rect.width = 0;
      im_set_preedit_area (rect, status_rect, needed_rect);

      preedit_attr = XVaCreateNestedList (0,
                                          XNForeground, fg,
                                          XNBackground, bg,
                                          XNArea, &rect,
                                          XNFontSet, fs,
                                          NULL);
      status_attr = XVaCreateNestedList (0,
                                         XNForeground, fg,
                                         XNBackground, bg,
                                         XNArea, &status_rect,
                                         XNFontSet, fs,
                                         NULL);
    }
#if ENABLE_XIM_ONTHESPOT
  else if (input_style & XIMPreeditCallbacks)
    {
      im_set_position (spot);

      xcb[0].client_data = (XPointer)this; xcb[0].callback = (XIMProc)xim_preedit_start;
      xcb[1].client_data = (XPointer)this; xcb[1].callback = (XIMProc)xim_preedit_done;
      xcb[2].client_data = (XPointer)this; xcb[2].callback = (XIMProc)xim_preedit_draw;
# if 0
      xcb[3].client_data = (XPointer)this; xcb[3].callback = (XIMProc)xim_preedit_caret;
# endif

      preedit_attr = XVaCreateNestedList (0,
                                          XNSpotLocation, &spot,
                                          XNPreeditStartCallback, &xcb[0],
                                          XNPreeditDoneCallback , &xcb[1],
                                          XNPreeditDrawCallback , &xcb[2],
# if 0
                                          XNPreeditCaretCallback, &xcb[3],
# endif
                                          NULL);
    }
#endif

  Input_Context = XCreateIC (xim,
                             XNInputStyle, input_style,
                             XNClientWindow, vt,
                             XNFocusWindow, parent[0],
                             preedit_attr ? XNPreeditAttributes : NULL,
                             preedit_attr,
                             status_attr ? XNStatusAttributes : NULL,
                             status_attr, NULL);

  if (preedit_attr) XFree (preedit_attr);
  if (status_attr)  XFree (status_attr);
  if (fs)           XFreeFontSet (dpy, fs);

  if (Input_Context == NULL)
    {
      rxvt_warn ("failed to create input context, continuing without XIM.\n");
      im_destroy ();
      return false;
    }

#if 0
  // unfortunately, only the focus window is used by XIM, hard to fix
  if (!XGetICValues (Input_Context, XNFilterEvents, &vt_emask_xim, NULL))
    vt_select_input ();
#endif

  IMSetPosition ();

  return true;
}
Beispiel #15
0
CStdWindow *CStdWindow::Init(CStdApp *pApp, const char *Title,
                             CStdWindow *pParent, bool HideCursor) {
#ifndef USE_X11
  return this;
#else
  Active = true;
  dpy = pApp->dpy;

  if (!FindInfo()) return 0;

  // Various properties
  XSetWindowAttributes attr;
  attr.border_pixel = 0;
  attr.background_pixel = 0;
  // Which events we want to receive
  attr.event_mask =
      // EnterWindowMask |
      // LeaveWindowMask |
      StructureNotifyMask | FocusChangeMask | KeyPressMask | KeyReleaseMask |
      PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
  attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy),
                                  ((XVisualInfo *)Info)->visual, AllocNone);
  unsigned long attrmask =
      CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  Pixmap bitmap;
  if (HideCursor) {
    // Hide the mouse cursor
    XColor cursor_color;
    // We do not care what color the invisible cursor has
    memset(&cursor_color, 0, sizeof(cursor_color));
    bitmap = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), "\000", 1, 1);
    attr.cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &cursor_color,
                                      &cursor_color, 0, 0);
    attrmask |= CWCursor;
  }

  wnd = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 640, 480, 0,
                      ((XVisualInfo *)Info)->depth, InputOutput,
                      ((XVisualInfo *)Info)->visual, attrmask, &attr);
  if (HideCursor) {
    XFreeCursor(dpy, attr.cursor);
    XFreePixmap(dpy, bitmap);
  }
  if (!wnd) {
    Log("Error creating window.");
    return 0;
  }
  // Update the XWindow->CStdWindow-Map
  CStdAppPrivate::SetWindow(wnd, this);
  if (!pApp->Priv->xic && pApp->Priv->xim) {
    pApp->Priv->xic = XCreateIC(
        pApp->Priv->xim, XNClientWindow, wnd, XNFocusWindow, wnd, XNInputStyle,
        XIMPreeditNothing | XIMStatusNothing, XNResourceName, STD_PRODUCT,
        XNResourceClass, STD_PRODUCT, NULL);
    if (!pApp->Priv->xic) {
      Log("Failed to create input context.");
      XCloseIM(pApp->Priv->xim);
      pApp->Priv->xim = 0;
    } else {
      long ic_event_mask;
      if (XGetICValues(pApp->Priv->xic, XNFilterEvents, &ic_event_mask, NULL) ==
          NULL)
        attr.event_mask |= ic_event_mask;
      XSelectInput(dpy, wnd, attr.event_mask);
      XSetICFocus(pApp->Priv->xic);
    }
  }
  // We want notification of closerequests and be killed if we hang
  Atom WMProtocols[2];
  char *WMProtocolnames[] = {"WM_DELETE_WINDOW", "_NET_WM_PING"};
  XInternAtoms(dpy, WMProtocolnames, 2, false, WMProtocols);
  XSetWMProtocols(dpy, wnd, WMProtocols, 2);
  // Let the window manager know our pid so it can kill us
  Atom PID = XInternAtom(pApp->dpy, "_NET_WM_PID", false);
  int32_t pid = getpid();
  if (PID != None)
    XChangeProperty(pApp->dpy, wnd, PID, XA_CARDINAL, 32, PropModeReplace,
                    reinterpret_cast<const unsigned char *>(&pid), 1);
  // Title and stuff
  XTextProperty title_property;
  StdStrBuf tbuf;
  tbuf.Copy(Title ? Title : "");
  char *tbufstr = tbuf.getMData();
  // char * title = "Clonk Endeavour";
  XStringListToTextProperty(&tbufstr, 1, &title_property);
  // State and Icon
  XWMHints *wm_hint = XAllocWMHints();
  wm_hint->flags = StateHint | InputHint | IconPixmapHint | IconMaskHint;
  wm_hint->initial_state = NormalState;
  wm_hint->input = True;
  // Trust XpmCreatePixmapFromData to not modify the xpm...
  XpmCreatePixmapFromData(dpy, wnd, const_cast<char **>(c4x_xpm),
                          &wm_hint->icon_pixmap, &wm_hint->icon_mask, 0);
  // Window class
  XClassHint *class_hint = XAllocClassHint();
  class_hint->res_name = STD_PRODUCT;
  class_hint->res_class = STD_PRODUCT;
  XSetWMProperties(dpy, wnd, &title_property, &title_property, pApp->Priv->argv,
                   pApp->Priv->argc, 0, wm_hint, class_hint);
  // Set "parent". Clonk does not use "real" parent windows, but multiple
  // toplevel windows.
  if (pParent) XSetTransientForHint(dpy, wnd, pParent->wnd);
  // Show window
  XMapWindow(dpy, wnd);
  // Clean up
  // The pixmap has to stay as long as the window exists, so it does not hurt to
  // never free it.
  // XFreePixmap(dpy,xwmh->icon_pixmap);
  // XFreePixmap(dpy,xwmh->icon_mask);
  XFree(title_property.value);
  Hints = wm_hint;
  XFree(class_hint);

  // Render into whole window
  renderwnd = wnd;

  return this;
#endif  // USE_X11
}
Beispiel #16
0
static void install_grabs( void )
{
	int res;
	int fevent;

	assert( x11display.dpy && x11display.win );

	if( !x11display.features.wmStateFullscreen )
	{
		res = XGrabKeyboard( x11display.dpy, x11display.win, False, GrabModeAsync, GrabModeAsync, CurrentTime );
		if( res != GrabSuccess )
		{
			Com_Printf( "Warning: XGrabKeyboard failed\n" );
			return;
		}
	}

	XDefineCursor( x11display.dpy, x11display.win, CreateNullCursor( x11display.dpy, x11display.win ) );

	res = XGrabPointer( x11display.dpy, x11display.win, True, 0, GrabModeAsync, GrabModeAsync, x11display.win, None, CurrentTime );
	if( res != GrabSuccess )
	{
		// TODO: Find a solution to Pointer Grabs at focus changes, which sometimes result
		// in Grabbing Errors. Like switches from Windowed/Fullscreen to Hidden State.
		//Com_Printf( "Warning: XGrabPointer failed\n" );
		XUngrabKeyboard( x11display.dpy, CurrentTime );
		XUndefineCursor( x11display.dpy, x11display.win );
		return;
	}

	if( in_dgamouse->integer )
	{
		int MajorVersion, MinorVersion;

		if( XF86DGAQueryVersion( x11display.dpy, &MajorVersion, &MinorVersion ) )
		{
			XF86DGADirectVideo( x11display.dpy, x11display.scr, XF86DGADirectMouse );
			XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0,
				x11display.win_width/2, x11display.win_height/2 );
			dgamouse = qtrue;
		}
		else
		{
			// unable to query, probalby not supported
			Com_Printf( "Failed to detect XF86DGA Mouse\n" );
			Cvar_Set( "in_dgamouse", "0" );
			dgamouse = qfalse;
		}
	}
	else
	{
		XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0,
			x11display.win_width/2, x11display.win_height/2 );
	}

	ignore_one = qtrue; // first mouse update after install_grabs is ignored
	mx = my = 0;
	mouse_active = qtrue;

	in_dgamouse->modified = qfalse;

	input_active = qtrue;

	// init X Input method, needed by Xutf8LookupString
	x11display.im = XOpenIM( x11display.dpy, NULL, NULL, NULL );
	x11display.ic = XCreateIC( x11display.im,
		XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
		XNClientWindow, x11display.win,
		NULL );
	if ( x11display.ic )
	{
		XGetICValues( x11display.ic, XNFilterEvents, &fevent, NULL );
		XSelectInput( x11display.dpy, x11display.win, fevent | x11display.wa.event_mask );
	}
}