void CL_DisplayWindow_OpenGL::destroy_window()
{
	install_event_handler(0, 1);

	if (context)
		aglSetCurrentContext(0);

	if (fs_context)
	{
		aglDestroyContext(fs_context);
		fs_context = 0;
	}

	if (win_context)
	{
		aglDestroyContext(win_context);
		win_context = 0;
	}

	keyboard = CL_InputDevice();
	mouse = CL_InputDevice();
	get_ic()->clear();

	if (window_ref)
		ReleaseWindow(window_ref);
	window_ref = 0;
}
Esempio n. 2
0
static bool
get_ic_option(int option)
{
    HangulInputContext* ic = get_ic("2");
    bool value = hangul_ic_get_option(ic, option);
    return value;
}
void CL_DisplayWindow_OpenGL::destroy_window()
{
	set_windowed();

	if (context)
	{
		if (!glXMakeCurrent(disp, None, NULL))
		{
			printf("Could not release drawing context.\n");
		}

		glXDestroyContext(disp, context);
		context = NULL;
	}

	keyboard = CL_InputDevice();
	mouse = CL_InputDevice();
	get_ic()->clear();

	if (window) XDestroyWindow(disp, window);
	window = 0;
	
	if (disp_ref_count > 0)
	{
		disp_ref_count--;
		if (disp_ref_count == 0)
		{
			XCloseDisplay(disp);
			disp = 0;
		}
	}
}
void
CL_DisplayWindow_OpenGL::setup_xinput()
{
	if (!xinput_is_present())
	{
		CL_Log::log("debug", "XInput extentsion not found");
	}
	else
	{
		XDeviceInfo		*info;
		int			loop;

		int		num_devices;
    
		info = XListInputDevices(disp, &num_devices);
	
		for(loop=0; loop<num_devices; loop++) {
			// FIXME: Xinput isn't necesarrily a mouse, could be anything
			if (info[loop].use == IsXExtensionDevice)
			{
				get_ic()->add_mouse(CL_InputDevice(new CL_InputDevice_XInput(this, info + loop)));
			}
		}
	}
}
void CL_DisplayWindow_OpenGL::setup_usb_mice()
{
	char pathname[256];
	bool done = false;

	for(int i = 0; !done; ++i)
	{
		snprintf(pathname, sizeof(pathname), "/dev/input/mouse%d", i);
		if (access(pathname, R_OK) == 0)
		{
			try
			{
				get_ic()->add_mouse(CL_InputDevice(new CL_InputDevice_LinuxUSBMouse(this, pathname)));
			}
			catch (CL_Error& err)
			{
				CL_Log::log("debug", "Mouse Error: %1", err.message);
				done = true;
			}
		}
		else
		{
			CL_Log::log("debug", "Mouse Error: %1: %2", pathname, strerror(errno));
			done = true;
		}
	}
}
Esempio n. 6
0
void do_sh_range(double *ystart, double *yend) {
  double parlo, parhi, dpar, temp;
  int npar, i, j, ierr;
  int side, cycle, icol, color;
  char bob[50];

  if (set_up_sh_range() == 0)
    return;
  swap_color(&color, 0);
  parhi = shoot_range.phigh;
  parlo = shoot_range.plow;
  npar = shoot_range.steps;
  dpar = (parhi - parlo) / (double)npar;
  side = shoot_range.side;
  cycle = shoot_range.cycle;
  storind = 0;
  icol = 0;
  if (shoot_range.movie == 1)
    reset_film();
  for (i = 0; i <= npar; i++) {
    temp = parlo + dpar * (double)i;
    set_val(shoot_range.item, temp);
    sprintf(bob, "%s=%.16g", shoot_range.item, temp);
    x11_status_bar_set_text(main_status_bar, bob);
    if (shoot_range.movie == 1)
      clr_scrn();

    bvshoot(ystart, yend, BVP_TOL, BVP_EPS, BVP_MAXIT, &ierr, NODE, 0, 0, 0, 0,
            0.0);
    if (ierr == ABORT)
      continue;
    if (ierr < 0) {
      bad_shoot(ierr);

      set_browser_data(storage, storind, NEQ + 1);
      swap_color(&color, 1);
      return;
    }
    storage[0][storind] = temp;
    if (side == 0)
      for (j = 0; j < NODE; j++)
        storage[j + 1][storind] = ystart[j];
    else
      for (j = 0; j < NODE; j++)
        storage[j + 1][storind] = yend[j];
    storind++;
    set_cycle(cycle, &icol);
    get_ic(0, ystart);
    last_shot(0);
    if (shoot_range.movie == 1)
      film_clip();
    ping();
  }
  set_browser_data(storage, storind, NEQ + 1);
  auto_freeze_it();
  swap_color(&color, 1);
}
Esempio n. 7
0
static bool
check_commit(const char* keyboard, const char* input, const wchar_t* output)
{
    HangulInputContext* ic;
    int res;

    ic = get_ic(keyboard);

    res = check_commit_with_ic(ic, input, output);

    return res;
}
Esempio n. 8
0
void last_shot(int flag) {
  int i;
  double *x;
  x = &MyData[0];
  MyStart = 1;
  get_ic(2, x);
  STORFLAG = flag;
  MyTime = T0;
  if (flag) {
    storage[0][0] = (float)T0;
    extra(x, T0, NODE, NEQ);
    for (i = 0; i < NEQ; i++)
      storage[1 + i][0] = (float)x[i];
    storind = 1;
  }
  integrate(&MyTime, x, TEND, DELTA_T, 1, NJMP, &MyStart);
}
void CL_DisplayWindow_OpenGL::setup_joysticks()
{
	// This could need some improvments, it doesn't look for
	// /dev/input/jsX for example
	char pathname[256];
	char joydev[256];
	bool done = false;

	CL_Log::log("debug", "Setting up joystick");

	if (access("/dev/input/", R_OK | X_OK) == 0)
	{
		strcpy(joydev, "/dev/input/js%d");
	} 
	else
	{
		strcpy(joydev, "/dev/js%d");
	}

	for(int i = 0; !done; ++i)
	{
		snprintf(pathname, sizeof(pathname), joydev, i);
		
		if (access(pathname, R_OK) == 0)
		{
			try
			{
				get_ic()->add_joystick(CL_InputDevice(new CL_InputDevice_LinuxJoystick(pathname)));
			} 
			catch (CL_Error& err)
			{
				CL_Log::log("debug", "Joystick Error: %1", err.message);
				done = true;
			}
		}
		else
		{
			CL_Log::log("debug", "Joystick Error: %1: %2", pathname, strerror(errno));
			done = true;
		}
	}
}
Esempio n. 10
0
static Eina_Bool
_ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx,
                                    Ecore_IMF_Event_Type type,
                                    Ecore_IMF_Event *event)
{
   EINA_LOG_DBG("%s in", __FUNCTION__);
#ifdef ENABLE_XIM
   Ecore_IMF_Context_Data *imf_context_data;
   XIC ic;

   Ecore_X_Display *dsp;
   Ecore_X_Window win;

   int val;
   char compose_buffer[256];
   KeySym sym;
   char *compose = NULL;
   char *tmp = NULL;
   Eina_Bool result = EINA_FALSE;

   imf_context_data = ecore_imf_context_data_get(ctx);
   if (!imf_context_data) return EINA_FALSE;
   ic = imf_context_data->ic;
   if (!ic)
     ic = get_ic(ctx);

   if (type == ECORE_IMF_EVENT_KEY_DOWN)
     {
        XKeyPressedEvent xev;
        Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event;
        EINA_LOG_DBG("ECORE_IMF_EVENT_KEY_DOWN");

        dsp = ecore_x_display_get();
        win = imf_context_data->win;

        xev.type = KeyPress;
        xev.serial = 0; /* hope it doesn't matter */
        xev.send_event = 0;
        xev.display = dsp;
        xev.window = win;
        xev.root = ecore_x_window_root_get(win);
        xev.subwindow = win;
        xev.time = ev->timestamp;
        xev.x = xev.x_root = 0;
        xev.y = xev.y_root = 0;
        xev.state = 0;
        xev.state |= _ecore_x_event_reverse_modifiers(ev->modifiers);
        xev.state |= _ecore_x_event_reverse_locks(ev->locks);
        xev.keycode = _keycode_get(dsp, ev->keyname);
        xev.same_screen = True;

        if (ic)
          {
             Status mbstatus;
#ifdef X_HAVE_UTF8_STRING
             val = Xutf8LookupString(ic,
                                     &xev,
                                     compose_buffer,
                                     sizeof(compose_buffer) - 1,
                                     &sym,
                                     &mbstatus);
#else /* ifdef X_HAVE_UTF8_STRING */
             val = XmbLookupString(ic,
                                   &xev,
                                   compose_buffer,
                                   sizeof(compose_buffer) - 1,
                                   &sym,
                                   &mbstatus);
#endif /* ifdef X_HAVE_UTF8_STRING */
             if (mbstatus == XBufferOverflow)
               {
                  tmp = malloc(sizeof (char) * (val + 1));
                  if (!tmp)
                    return EINA_FALSE;

                  compose = tmp;

#ifdef X_HAVE_UTF8_STRING
                  val = Xutf8LookupString(ic,
                                          &xev,
                                          tmp,
                                          val,
                                          &sym,
                                          &mbstatus);
#else /* ifdef X_HAVE_UTF8_STRING */
                  val = XmbLookupString(ic,
                                        &xev,
                                        tmp,
                                        val,
                                        &sym,
                                        &mbstatus);
#endif /* ifdef X_HAVE_UTF8_STRING */
                  if (val > 0)
                    {
                       tmp[val] = '\0';
#ifndef X_HAVE_UTF8_STRING
                       compose = eina_str_convert(nl_langinfo(CODESET),
                                                  "UTF-8", tmp);
                       free(tmp);
                       tmp = compose;
#endif /* ifndef X_HAVE_UTF8_STRING */
                    }
                  else
                    compose = NULL;
               }
             else if (val > 0)
               {
                  compose_buffer[val] = '\0';
#ifdef X_HAVE_UTF8_STRING
                  compose = strdup(compose_buffer);
#else /* ifdef X_HAVE_UTF8_STRING */
                  compose = eina_str_convert(nl_langinfo(CODESET), "UTF-8",
                                             compose_buffer);
#endif /* ifdef X_HAVE_UTF8_STRING */
               }
          }
        else
          {
             compose = strdup(ev->compose);
          }

        if (compose)
          {
             Eina_Unicode *unicode;
             int len;
             unicode = eina_unicode_utf8_to_unicode(compose, &len);
             if (!unicode) abort();
             if (unicode[0] >= 0x20 && unicode[0] != 0x7f)
               {
                  ecore_imf_context_commit_event_add(ctx, compose);
                  ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_COMMIT, compose);
                  result = EINA_TRUE;
               }
             free(compose);
             free(unicode);
          }
     }

   return result;
#else
   (void)ctx;
   (void)type;
   (void)event;
   return EINA_FALSE;
#endif
}
Esempio n. 11
0
void Connection::xim_reset_ic(RxPacket *p)
{
    XimIC *ic = get_ic(p);
    if (ic)
	ic->reset_ic();
}
void CL_DisplayWindow_OpenGL::create_window(const CL_DisplayWindowDescription &desc)
{
	OSStatus result;

	const CL_OpenGLWindowDescription_Generic *gl_desc = 0;
	gl_desc = dynamic_cast<const CL_OpenGLWindowDescription_Generic*>(desc.impl.get());

	fullscreen_width = desc.get_size().width;
	fullscreen_height = desc.get_size().height;

	disp_ref_count++;

	GLint gl_attribs_single[] =
	{
		AGL_RGBA,
		AGL_RED_SIZE, 4,
		AGL_GREEN_SIZE, 4,
		AGL_BLUE_SIZE, 4,
		AGL_DEPTH_SIZE, 16,
		AGL_NONE
	};

	GLint gl_attribs[32];
	int i = 0;
	
	if( gl_desc )
	{
		if( gl_desc->rgba ) gl_attribs[i++] = AGL_RGBA;
		if( gl_desc->doublebuffer ) gl_attribs[i++] = AGL_DOUBLEBUFFER;
		//if( gl_desc->stereo ) gl_attribs[i++] = AGL_STEREO;
		gl_attribs[i++] = AGL_BUFFER_SIZE;
		gl_attribs[i++] = gl_desc->buffer_size;
		gl_attribs[i++] = AGL_LEVEL;
		gl_attribs[i++] = gl_desc->level;
		gl_attribs[i++] = AGL_AUX_BUFFERS;
		gl_attribs[i++] = gl_desc->aux_buffers;
		gl_attribs[i++] = AGL_RED_SIZE; 
		gl_attribs[i++] = gl_desc->red_size;
		gl_attribs[i++] = AGL_GREEN_SIZE;
		gl_attribs[i++] = gl_desc->green_size;
		gl_attribs[i++] = AGL_BLUE_SIZE;
		gl_attribs[i++] = gl_desc->blue_size;
		gl_attribs[i++] = AGL_DEPTH_SIZE;
		gl_attribs[i++] = gl_desc->depth_size;
		gl_attribs[i++] = AGL_STENCIL_SIZE;
		gl_attribs[i++] = gl_desc->stencil_size;
		gl_attribs[i++] = AGL_ACCUM_RED_SIZE;
		gl_attribs[i++] = gl_desc->accum_red_size;
		gl_attribs[i++] = AGL_ACCUM_GREEN_SIZE;
		gl_attribs[i++] = gl_desc->accum_green_size;
		gl_attribs[i++] = AGL_ACCUM_BLUE_SIZE;
		gl_attribs[i++] = gl_desc->accum_blue_size;
		gl_attribs[i++] = AGL_ACCUM_ALPHA_SIZE;
		gl_attribs[i++] = gl_desc->accum_alpha_size;
		gl_attribs[i++] = AGL_ACCUM_RED_SIZE;
		gl_attribs[i++] = gl_desc->accum_red_size;
//		gl_attribs[i++] = AGL_FULLSCREEN;
	}
	else
	{
		gl_attribs[i++] = AGL_RGBA;
		gl_attribs[i++] = AGL_NO_RECOVERY;
		gl_attribs[i++] = AGL_DOUBLEBUFFER;
		gl_attribs[i++] = AGL_DEPTH_SIZE;
		gl_attribs[i++] = 16;
	} 
/*	
	else
	{
		gl_attribs[i++] = AGL_RGBA;
		gl_attribs[i++] = AGL_DOUBLEBUFFER;
		gl_attribs[i++] = AGL_RED_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = AGL_GREEN_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = AGL_BLUE_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = AGL_DEPTH_SIZE;
		gl_attribs[i++] = 16;
//		gl_attribs[i++] = AGL_FULLSCREEN;
	}
*/

	gl_attribs[i] = AGL_NONE;

	CGDirectDisplayID display = CGMainDisplayID();
	GDHandle gdhDisplay, *pgdhDisplay;
	int numDisplay;

	pgdhDisplay = &gdhDisplay;
	
	if (noErr == DMGetGDeviceByDisplayID ((DisplayIDType)display, pgdhDisplay, false)) 
		numDisplay = 1;	
	else 
	{
		pgdhDisplay = 0;
		numDisplay = 0;
	}
		
	AGLPixelFormat pixelformat;	
	pixelformat = aglChoosePixelFormat(pgdhDisplay, numDisplay, gl_attribs);
	win_context = aglCreateContext(pixelformat, share_context);
	if (!share_context) share_context = win_context;
	aglDestroyPixelFormat(pixelformat);
	gl_attribs[i++] = AGL_FULLSCREEN;
	gl_attribs[i] = AGL_NONE;
	pixelformat = aglChoosePixelFormat(pgdhDisplay, numDisplay, gl_attribs);
	fs_context = aglCreateContext(pixelformat, win_context);
	aglDestroyPixelFormat(pixelformat);

	if (!(win_context && fs_context)) 
	{
		printf("Requested visual not supported by your OpenGL implementation. Falling back on singlebuffered Visual!\n");
		pixelformat = aglChoosePixelFormat(0, 0, gl_attribs_single);
		win_context = aglCreateContext(pixelformat, share_context);
		aglDestroyPixelFormat(pixelformat);
		fs_context = 0;
	}

	WindowAttributes style = kWindowCloseBoxAttribute | kWindowStandardHandlerAttribute;
	if (desc.get_allow_resize()) style |= kWindowResizableAttribute | kWindowFullZoomAttribute;
	Rect window_rect;
	SetRect(&window_rect, 50, 50, 50+desc.get_size().width, 50+desc.get_size().height);
	result = CreateNewWindow(kDocumentWindowClass, style, &window_rect, &window_ref);
	if (result != noErr)
		printf("Could not create window, due to error %d\n", (int)result);

	// set title of window:
	set_title(desc.get_title());

	// Set standard arrow cursor:
	InitCursor(); // do we need to do this? -- iMBN, 13. may 2004
	
	// Create input devices for window:
	keyboard = CL_InputDevice(new CL_InputDevice_MacKeyboard(this));
	mouse	= CL_InputDevice(new CL_InputDevice_MacMouse(this));

	get_ic()->clear();
	get_ic()->add_keyboard(keyboard);
	get_ic()->add_mouse(mouse);

//	buffer_front = CL_PixelBuffer(new CL_PixelBuffer_OpenGL_Frame(CL_FRONT, gc));
//	buffer_back = CL_PixelBuffer(new CL_PixelBuffer_OpenGL_Frame(CL_BACK, gc));

	if (!aglSetDrawable(win_context, GetWindowPort(window_ref)))
	{
		printf("Unable to set drawable");
	}
	
	if (desc.is_fullscreen())
		set_fullscreen(desc.get_size().width, desc.get_size().height, desc.get_bpp(), desc.get_refresh_rate());
	else {
		fullscreen = true;  // not really, but need to fool set_windowed
		set_windowed();
	}

	ShowWindow(window_ref);
}
Esempio n. 13
0
void find_bvp_com(int com) {
  int ishow = 0, iret;
  int iper = 0, ivar = 0, ipar = 0, pflag;
  double sect = 0.0;
  double oldpar;
  double ystart[MAXODE], oldtrans;
  double yend[MAXODE];
  /*  Window temp=main_win; */
  if (NMarkov > 0 || NKernel > 0) {
    err_msg("Can't do BVP with integral or markov eqns");
    return;
  }
  wipe_rep();
  data_back();
  compile_bvp();
  if (FFT || HIST || DelayFlag || BVP_FLAG == 0)
    return;
  STORFLAG = 0;
  RANGE_FLAG = 1;
  POIMAP = 0;
  oldtrans = TRANS;
  TRANS = 0.0;
  get_ic(1, ystart);
  switch (com) {
  case 0:
    do_sh_range(ystart, yend);
    return;
  case 4:
    set_up_homoclinic();
    return;
  case 3:
    if (NUPAR == 0)
      goto bye;
    pflag = set_up_periodic(&ipar, &ivar, &sect, &ishow);
    if (pflag == 0)
      goto bye;
    iper = 1;
    get_val(upar_names[ipar], &oldpar);
    break;

  case 2:
    ishow = 1;
    iper = 0;
    break;
  case 1:
  default:
    iper = 0;
    break;
  }
  if (iper)
    bvshoot(ystart, yend, BVP_TOL, BVP_EPS, BVP_MAXIT, &iret, NODE, ishow, iper,
            ipar, ivar, sect);
  else
    bvshoot(ystart, yend, BVP_TOL, BVP_EPS, BVP_MAXIT, &iret, NODE, ishow, 0, 0,
            0, 0.0);
  bad_shoot(iret);
  if (iret == GOODSHOT || iret == NOCHANGE) {
    get_ic(0, ystart);
    redraw_ics();
    if (ishow) {
      reset_graphics();
    }
    last_shot(1);
    INFLAG = 1;
    set_browser_data(storage, storind, NEQ + 1);
    auto_freeze_it();
    ping();
  } else if (iper)
    set_val(upar_names[ipar], oldpar);

bye:
  TRANS = oldtrans;
}
Esempio n. 14
0
static void
set_ic_option(int option, bool value)
{
    HangulInputContext* ic = get_ic("2");
    hangul_ic_set_option(ic, option, value);
}
void CL_DisplayWindow_OpenGL::create_window(const CL_DisplayWindowDescription &desc)
{
	const CL_OpenGLWindowDescription_Generic *gl_desc = 0;
	gl_desc = dynamic_cast<const CL_OpenGLWindowDescription_Generic*>(desc.impl.get());

	fullscreen_width  = desc.get_size().width;
	fullscreen_height = desc.get_size().height;

	XVisualInfo *vi;
	Colormap cmap;

	if (disp == 0)
	{
		disp = XOpenDisplay(0);
		if (disp == 0) throw CL_Error("Could not open X11 display!");
	}
	disp_ref_count++;

	int gl_attribs_single[] =
	{
		GLX_RGBA,
		GLX_RED_SIZE, 4,
		GLX_GREEN_SIZE, 4,
		GLX_BLUE_SIZE, 4,
		GLX_DEPTH_SIZE, 16,
		None
	};

	int gl_attribs[32];
	int i = 0;
	
	if( gl_desc )
	{
		if( gl_desc->rgba ) gl_attribs[i++] = GLX_RGBA;
		if( gl_desc->doublebuffer ) gl_attribs[i++] = GLX_DOUBLEBUFFER;
		if( gl_desc->stereo ) gl_attribs[i++] = GLX_STEREO;
		gl_attribs[i++] = GLX_BUFFER_SIZE;
		gl_attribs[i++] = gl_desc->buffer_size;
		gl_attribs[i++] = GLX_LEVEL;
		gl_attribs[i++] = gl_desc->level;
		gl_attribs[i++] = GLX_AUX_BUFFERS;
		gl_attribs[i++] = gl_desc->aux_buffers;
		gl_attribs[i++] = GLX_RED_SIZE; 
		gl_attribs[i++] = gl_desc->red_size;
		gl_attribs[i++] = GLX_GREEN_SIZE;
		gl_attribs[i++] = gl_desc->green_size;
		gl_attribs[i++] = GLX_BLUE_SIZE;
		gl_attribs[i++] = gl_desc->blue_size;
		gl_attribs[i++] = GLX_DEPTH_SIZE;
		gl_attribs[i++] = gl_desc->depth_size;
		gl_attribs[i++] = GLX_STENCIL_SIZE;
		gl_attribs[i++] = gl_desc->stencil_size;
		gl_attribs[i++] = GLX_ACCUM_RED_SIZE;
		gl_attribs[i++] = gl_desc->accum_red_size;
		gl_attribs[i++] = GLX_ACCUM_GREEN_SIZE;
		gl_attribs[i++] = gl_desc->accum_green_size;
		gl_attribs[i++] = GLX_ACCUM_BLUE_SIZE;
		gl_attribs[i++] = gl_desc->accum_blue_size;
		gl_attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
		gl_attribs[i++] = gl_desc->accum_alpha_size;
		gl_attribs[i++] = GLX_ACCUM_RED_SIZE;
		gl_attribs[i++] = gl_desc->accum_red_size;
		gl_attribs[i++] = None;
	}
	else
	{
		gl_attribs[i++] = GLX_RGBA;
		gl_attribs[i++] = GLX_DOUBLEBUFFER;
		gl_attribs[i++] = GLX_RED_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = GLX_GREEN_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = GLX_BLUE_SIZE;
		gl_attribs[i++] = 4;
		gl_attribs[i++] = GLX_DEPTH_SIZE;
		gl_attribs[i++] = 16;
		gl_attribs[i++] = None;
	}

	// get an appropriate visual
	vi = glXChooseVisual(disp, DefaultScreen(disp), gl_attribs);
	
	if (vi == NULL)
	{
		vi = glXChooseVisual(disp, window, gl_attribs_single);
		printf("Requested visual not supported by your OpenGL implementation. Falling back on singlebuffered Visual!\n");
	}

	// create a GLX context
	context = glXCreateContext(disp, vi, share_context, True);

	if( share_context == NULL )
		share_context = context;

	glXGetConfig(disp, vi, GLX_BUFFER_SIZE, &glx_bpp);

	// create a color map
	cmap = XCreateColormap( disp, RootWindow(disp, vi->screen), vi->visual, AllocNone);

	attributes.colormap = cmap;
	attributes.border_pixel = 0;
	attributes.override_redirect = False;

	// create a window in window mode
	attributes.event_mask =
		ExposureMask |
		KeyPressMask |
		KeyReleaseMask |
		ButtonPressMask |
		ButtonReleaseMask |
		StructureNotifyMask |
		PointerMotionMask |
		EnterWindowMask |
		LeaveWindowMask |
		FocusChangeMask;

	window = XCreateWindow(disp, RootWindow(disp, vi->screen),
		0, 0, desc.get_size().width, desc.get_size().height, 0, vi->depth, InputOutput, vi->visual,
		CWBorderPixel | CWColormap | CWOverrideRedirect | CWEventMask, &attributes);
	
	XSelectInput(disp, window,
		FocusChangeMask | KeyPressMask | KeyReleaseMask
		| PropertyChangeMask | StructureNotifyMask |
		KeymapStateMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask);

	// set title of window:
	set_title(desc.get_title());
	
	// setup size hints:
	XSizeHints size_hints;
	memset(&size_hints, 0, sizeof(XSizeHints));
	size_hints.width       = desc.get_size().width;
	size_hints.height      = desc.get_size().height;
	size_hints.base_width  = desc.get_size().width;
	size_hints.base_height = desc.get_size().height;
	size_hints.min_width   = size_hints.width;
	size_hints.min_height  = size_hints.height;
	size_hints.max_width   = size_hints.width;
	size_hints.max_height  = size_hints.height;
	size_hints.flags       = PSize|PBaseSize;
	if (!desc.get_allow_resize()) size_hints.flags |= PMinSize | PMaxSize;
	XSetWMNormalHints(disp, window, &size_hints);

	// handle wm_delete_events if in windowed mode:
	Atom wm_delete = XInternAtom(disp, "WM_DELETE_WINDOW", True);
	XSetWMProtocols(disp, window, &wm_delete, 1);

	// make window visible:
	XMapRaised(disp, window);

	if (!glXIsDirect(disp, context))
		printf("No hardware acceleration available. I hope you got a really fast machine..\n");

	// Create input devices for window:
	keyboard = CL_InputDevice(new CL_InputDevice_X11Keyboard(this));
	mouse    = CL_InputDevice(new CL_InputDevice_X11Mouse(this));

	get_ic()->clear();
	get_ic()->add_keyboard(keyboard);
	get_ic()->add_mouse(mouse);

	setup_joysticks();
// 	setup_usb_mice();
//	setup_xinput();
//	setup_event();

	XSync(disp, True);
	
	focus = true;
	
	system_cursor = XCreateFontCursor(disp, XC_left_ptr);
	char *data = (char*)malloc(64); // 8x8
	memset(data, 0, 64);

	XColor black_color;
	memset(&black_color, 0, sizeof(black_color));

	cursor_bitmap = XCreateBitmapFromData(disp, window, data, 8, 8);
	hidden_cursor = XCreatePixmapCursor(disp, cursor_bitmap, cursor_bitmap, &black_color, &black_color, 0,0 );
	
	if (desc.is_fullscreen())
		set_fullscreen(desc.get_size().width, desc.get_size().height, desc.get_bpp(), desc.get_refresh_rate());
}
Esempio n. 16
0
direct_field()
{
   static char *n[]={"(D)irect Field","(F)low"};
 static char key[]="df";
 char ch;
 int i,j,start,k;
 int inx=MyGraph->xv[0]-1;
 int iny=MyGraph->yv[0]-1;
 double y[MAXODE],ydot[MAXODE],xv1,xv2;
 float v1[MAXODE],v2[MAXODE];
 double amp;
 double t;
 double du,dv,u0,v0;
 double oldtrans=TRANS;
 
 Window temp=main_win;
 int grid=10;
 
 
 if(MyGraph->TimeFlag||MyGraph->xv[0]==MyGraph->yv[0]||MyGraph->ThreeDFlag)
   return;
 ch=(char)pop_up_list(&temp,"Two-D Fun",n,key,2,12,0,10,6*DCURY+8);
 if(ch==27)return;
 new_int("Grid:",&grid);
 if(grid<=1)return;
 du=(MyGraph->xhi-MyGraph->xlo)/(double)grid;
 dv=(MyGraph->yhi-MyGraph->ylo)/(double)grid;
 u0=MyGraph->xlo;
 v0=MyGraph->ylo;
 set_color(MyGraph->color[0]);
 if(ch!='f'){
   get_ic(2,y);
   for(i=0;i<=grid;i++){
     y[inx]=u0+du*i;
     for(j=0;j<=grid;j++){
       y[iny]=v0+dv*j;
       rhs(0.0,y,ydot,NODE);
       if(MyGraph->ColorFlag){
	 for(k=0;k<NODE;k++){
	   v1[k]=(float)y[k];
	   v2[k]=v1[k]+(float)ydot[k];
	 }
	 comp_color(v1,v2,NODE,1.0);
       }
    
       
       amp=hypot(ydot[inx],ydot[iny]);
       if(amp!=0.0){
	 ydot[inx]/=amp;
	 ydot[iny]/=amp;
       }
       xv1=y[inx]+ydot[inx]*du*.25;
       xv2=y[iny]+ydot[iny]*dv*.25;
       line_abs((float)y[inx],(float)y[iny],(float)xv1,(float)xv2);
     }
   }
   TRANS=oldtrans;
   return;
 }
   for(i=0;i<=grid;i++)
     for(j=0;j<=grid;j++)
       {
	 get_ic(2,y);
	 y[inx]=u0+du*i;
	 y[iny]=v0+dv*j;
	 t=0.0;
	 start=1;
	 if(integrate(&t,y,TEND,DELTA_T,1,NJMP,&start)==1){
	   TRANS=oldtrans;
	   return;
	 }
       }
 }