Exemplo n.º 1
0
void xfocus_update_events(struct _xfocus *p, int mode)
{
	// Mouse pointer motion masking and focus event masking every time for all windows
	const int mask = POINTER_MOTION_MASK;
	
	// Grabbing ONLY after masking!!!
	if (mode == LISTEN_DONTGRAB_INPUT)
	{
		// Event unmasking
		set_mask_to_window(p->parent_window, mask);
		set_event_mask(p->owner_window, mask | FOCUS_CHANGE_MASK);

		// Ungrabbing special key (Enter, Tab and other)
		grab_spec_keys(p->owner_window, FALSE);
	}
	else
	{
		// Event masking
		set_mask_to_window(p->parent_window, mask | EVENT_PRESS_MASK);
		set_event_mask(p->owner_window, mask | INPUT_HANDLE_MASK | FOCUS_CHANGE_MASK | EVENT_PRESS_MASK);

		// Grabbing special key (Enter, Tab and other)
		grab_spec_keys(p->owner_window, TRUE);
	}

	p->last_parent_window = p->parent_window;
}
Exemplo n.º 2
0
/**
 * main - entry point for SPU-side context restore.
 *
 * This code deviates from the documented sequence in the
 * following aspects:
 *
 *	1. The EA for LSCSA is passed from PPE in the
 *	   signal notification channels.
 *	2. The register spill area is pulled by SPU
 *	   into LS, rather than pushed by PPE.
 *	3. All 128 registers are restored by exit().
 *	4. The exit() function is modified at run
 *	   time in order to properly restore the
 *	   SPU_Status register.
 */
int main()
{
	addr64 lscsa_ea;

	lscsa_ea.ui[0] = spu_readch(SPU_RdSigNotify1);
	lscsa_ea.ui[1] = spu_readch(SPU_RdSigNotify2);
	fetch_regs_from_mem(lscsa_ea);

	set_event_mask();		/* Step 1.  */
	set_tag_mask();			/* Step 2.  */
	build_dma_list(lscsa_ea);	/* Step 3.  */
	restore_upper_240kb(lscsa_ea);	/* Step 4.  */
					/* Step 5: done by 'exit'. */
	enqueue_putllc(lscsa_ea);	/* Step 7. */
	set_tag_update();		/* Step 8. */
	read_tag_status();		/* Step 9. */
	restore_decr();			/* moved Step 6. */
	read_llar_status();		/* Step 10. */
	write_ppu_mb();			/* Step 11. */
	write_ppuint_mb();		/* Step 12. */
	restore_fpcr();			/* Step 13. */
	restore_srr0();			/* Step 14. */
	restore_event_mask();		/* Step 15. */
	restore_tag_mask();		/* Step 16. */
					/* Step 17. done by 'exit'. */
	restore_complete();		/* Step 18. */

	return 0;
}
Exemplo n.º 3
0
/**
 * main - entry point for SPU-side context save.
 *
 * This code deviates from the documented sequence as follows:
 *
 *      1. The EA for LSCSA is passed from PPE in the
 *         signal notification channels.
 *      2. All 128 registers are saved by crt0.o.
 */
int main()
{
	addr64 lscsa_ea;

	lscsa_ea.ui[0] = spu_readch(SPU_RdSigNotify1);
	lscsa_ea.ui[1] = spu_readch(SPU_RdSigNotify2);

	/* Step 1: done by exit(). */
	save_event_mask();	/* Step 2.  */
	save_tag_mask();	/* Step 3.  */
	set_event_mask();	/* Step 4.  */
	set_tag_mask();		/* Step 5.  */
	build_dma_list(lscsa_ea);	/* Step 6.  */
	save_upper_240kb(lscsa_ea);	/* Step 7.  */
	/* Step 8: done by exit(). */
	save_fpcr();		/* Step 9.  */
	save_decr();		/* Step 10. */
	save_srr0();		/* Step 11. */
	enqueue_putllc(lscsa_ea);	/* Step 12. */
	spill_regs_to_mem(lscsa_ea);	/* Step 13. */
	enqueue_sync(lscsa_ea);	/* Step 14. */
	set_tag_update();	/* Step 15. */
	read_tag_status();	/* Step 16. */
	read_llar_status();	/* Step 17. */
	save_complete();	/* Step 18. */

	return 0;
}
Exemplo n.º 4
0
int xwindow_create(struct _xwindow *p)
{
	XSetErrorHandler(error_handler);

	Display *display = XOpenDisplay(NULL);
	if (!display)
	{
		log_message(ERROR, "Can't connect to XServer");
		return FALSE;
	}

	Window window = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, 1, 1, 0, 0, 0);
	if (!window)
	{
		log_message(ERROR, "Can't create program window");
		return FALSE;
	}

	p->display	= display;
	p->window	= window;

	set_event_mask(window, MAIN_WINDOW_MASK);

	XSynchronize(display, TRUE);
	XFlush(display);

	return TRUE;
}
Exemplo n.º 5
0
static void set_mask_to_window(Window current_window, int mask)
{
	if (current_window == None)
		return;
	
	set_event_mask(current_window, mask);
	
	if (mask == None)
		grab_button(current_window, FALSE);
	else
		grab_button(current_window, TRUE);
	
	unsigned int children_count;
	Window root_window, parent_window;
	Window *children_return;
	
	int is_same_screen = XQueryTree(main_window->display, current_window, &root_window, &parent_window, &children_return, &children_count);
	if (!is_same_screen)
		return;
	
	for (int i = 0; i < children_count; i++)
		set_mask_to_window(children_return[i], mask);
	
	XFree(children_return);
}
Exemplo n.º 6
0
static void focus_update_grab_events(struct _focus *p, int mode)
{
	char *owner_window_name = get_wm_class_name(p->owner_window);
	if (mode == LISTEN_DONTGRAB_INPUT)
	{
		log_message (DEBUG, _("Interception of events in the window (ID %d) with name '%s' OFF"), p->owner_window, owner_window_name);
		
		// Event unmasking
		grab_button(FALSE);
		
		// Ungrabbing special key (Enter, Tab and other)
		grab_spec_keys(p->owner_window, FALSE);

		set_mask_to_window(p->owner_window, FOCUS_CHANGE_MASK);
		//set_event_mask(p->owner_window, None);
	}
	else
	{
		log_message (DEBUG, _("Interception of events in the window (ID %d) with name '%s' ON"), p->owner_window, owner_window_name);
		
		// Event masking
		
		// Grabbing special key (Enter, Tab and other)
		if (p->last_focus != FOCUS_EXCLUDED)
		{
			if (xconfig->tracking_mouse)
			  grab_button(TRUE);
			grab_spec_keys(p->owner_window, TRUE);
			set_event_mask(p->owner_window, INPUT_HANDLE_MASK | FOCUS_CHANGE_MASK | EVENT_KEY_MASK);
		}
		else
		{
			grab_button(FALSE);
			grab_spec_keys(p->owner_window, FALSE);
			set_event_mask(p->owner_window, FOCUS_CHANGE_MASK);
		}
	}

	p->last_parent_window = p->parent_window;
	
	if (owner_window_name != NULL)
		free(owner_window_name);
}
Exemplo n.º 7
0
int
main(int argc, char *argv[])
{
  int s, s2;
  char *node = "ubt0hci";
  int has_bdaddr = 0;
  int peer_addr_type = 0;
  bdaddr_t bd;
  int ch;

  while((ch = getopt(argc, argv, "a:n:pr")) != -1){
    switch(ch){
    case 'a':
      has_bdaddr = bt_aton(optarg, &bd);
      break;
    case 'n':
      node = strdup(optarg);
      break;
    case 'p':
      peer_addr_type = 0;
      break;
    case 'r':
      peer_addr_type = 1;
      break;
    case '?':
    default:
      usage();
    }
  }
  s = open_socket(node);

  /* Vol.6 Part D 2.1 INITIAL SETUP */
  le_read_local_supported_features(s);
  set_event_mask(s,0x20001fffffffffff);
  le_set_event_mask(s, 0x1f);
  le_read_buffer_size(s);
  le_read_supported_status(s);
  read_bd_addr(s, NULL);

  /* Vol.6 Part D 4.1 PASSIVE SCANNING */
  le_set_scan_param(s, 0, 0x12, 0x12, peer_addr_type, 0);

  le_set_scan_enable(s,1);
  le_scan_result(s);
  le_set_scan_enable(s,0);

  if(has_bdaddr){
    s2 = le_l2connect(&bd, peer_addr_type);
    /* some code here*/
    close(s2);
  }
  close(s);
  return 0;
}
Exemplo n.º 8
0
static void focus_update_events(struct _focus *p, int mode)
{
	
	if (mode == LISTEN_DONTGRAB_INPUT)
	{
		set_event_mask(p->owner_window, None);
	}
	else
	{
		if (p->last_focus != FOCUS_EXCLUDED)
		{
			set_event_mask(p->owner_window, INPUT_HANDLE_MASK | FOCUS_CHANGE_MASK | EVENT_KEY_MASK);
		}
		else
		{
			set_event_mask(p->owner_window, FOCUS_CHANGE_MASK);
		}
	}

	p->last_parent_window = p->parent_window;
}
Exemplo n.º 9
0
TWstring * TStatusPanel_STD::create(Obj_Config * conf, Status_Pack * sp)
{
	vector<TWstring> name;
	vector<TWstring> value;
	int w, h;

	TWstring val1, val2;
	TWstring * err;

	if ((err = conf->get_val(L"FONT_NAME", val1)) != NULL)
		return err;
	fontset = new TFontSet;
	if ((err = fontset->create(&val1)) != NULL)
		return err;

	if ((err = conf->get_val(L"FG_COLOR", val1)) != NULL)
		return err;
	if ((err = conf->get_val(L"BG_COLOR", val2)) != NULL)
		return err;
		
	TWin::create(0, 0, 1, 1, &val1, &val2, NULL);

	gc = new TGC(id(), &val1, &val2);

	if ((err = conf->get_val(L"STATUS_COLOR", val1)) != NULL)
		return err;
	stat_gc = new TGC(id(), &val1, &val1);

	w = fontset->width() * 2 + 4;
	h = fontset->height() +  4;
	if (TConf::load_config(CONFIG_FILE_NAME, name, value)){
		win_x = value[0].toint();
		win_y = value[1].toint();
		}else{
			win_x = TWinMan::get_display_w() - 3 * w - 1;
			win_y = TWinMan::get_display_h() - h - 1;
			}

	XSetWindowAttributes wa;
	wa.override_redirect = True;
	set_winattr(CWOverrideRedirect, &wa);

	set_event_mask(ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|VisibilityChangeMask);

	im_desc.copy(sp->im_desc.data());
	resize(w, h);
	move(win_x, win_y);
	show();

	return NULL;
}
Exemplo n.º 10
0
void set_mask_to_window(Window window, int event_mask)
{
    if (window == None)
        return;

    set_event_mask(window, event_mask);

    unsigned int children_count;
    Window root, parent;
    Window *children;

    int is_same_screen = XQueryTree(main_window->display, window, &root, &parent, &children, &children_count);
    if (!is_same_screen)
        return;

    unsigned int i;
    for (i = 0; i < children_count; i++)
        set_mask_to_window(children[i], event_mask);

    XFree(children);
}
Exemplo n.º 11
0
int
main( int argc, char *argv[] )
{
   Display *dpy;
   XVisualInfo *visinfo;

   parse_opts(argc, argv);

   dpy = XOpenDisplay(NULL);

   visinfo = choose_visual(dpy);

   Context = glXCreateContext( dpy, visinfo, NULL, True );
   if (!Context) {
      printf("Error: glXCreateContext failed\n");
      exit(1);
   }

   if (MyID == 0) {
      WindowID = make_gl_window(dpy, visinfo, Width, Height);
      set_window_title(dpy, WindowID, "corender");
      XMapWindow(dpy, WindowID);
      /*printf("WindowID 0x%x\n", (int) WindowID);*/
   }

   /* do ipc hand-shake here */
   setup_ipc();
   assert(Sock);
   assert(WindowID);

   if (MyID == 1) {
      set_event_mask(dpy, WindowID);
   }

   resize(dpy, Width, Height);

   event_loop(dpy);

   return 0;
}
Exemplo n.º 12
0
void handle_control_session(int fd, int code, void *data) {
  int ret;
  control_state *sess = (control_state *)data;

  switch(sess->state) {
    case READ_FD:
      switch(sess->operation) {
        case READ_COMMAND:
	  ret = read(fd, &sess->operation, 1);
	  if(ret == 0) goto close_clean;
	  if(ret < 0) {
	    if(errno == EAGAIN || errno == EWOULDBLOCK)
	      return;
	    goto error;
	  }
	  if(new_command(sess)) goto error;
	  if(set_event_mask(fd, sess)) goto error;
	  break;
	default:
	  goto error;
      }
      break;
    case WRITE_FD:
      switch(sess->operation) {
	case GET_WACK_STATE:
	  ret = write(fd, sess->data.writing.buffer+sess->data.writing.written,
		    sess->data.writing.size-sess->data.writing.written);
	  if(ret == 0) goto error;
	  if(ret<0) {
	    if(errno == EAGAIN || errno == EWOULDBLOCK)
              return;
            goto error;
	  }
	  sess->data.writing.written += ret;
	  if(sess->data.writing.written == sess->data.writing.size) {
	    free(sess->data.writing.buffer);
	    sess->operation = READ_COMMAND;
	    sess->state = READ_FD;
	    if(set_event_mask(fd, sess)) goto error;
	  }
	  break;
	case WACK_SERVICE_FAILURE:
	case WACK_SERVICE_SUCCESS:
	  ret = write(fd, &sess->data.retint, sizeof(int));
	  if(ret == 0) goto error;
	  if(ret<0) {
	    if(errno == EAGAIN || errno == EWOULDBLOCK)
              return;
            goto error;
          }
          if(ret != sizeof(int)) goto error;
	  sess->operation = READ_COMMAND;
	  sess->state = READ_FD;
	  if(set_event_mask(fd, sess)) goto error;
	  break;
	default:
	  goto error;
      }
      break;
    default:
      goto error;
  }
  return;
error:
  wack_alarm(PRINT, "control session error: [fd=%d] %s\n\tState=%d, Operation=%d",
	fd, strerror(errno), sess->state, sess->operation);
close_clean:
  E_detach_fd(fd, READ_FD);
  E_detach_fd(fd, WRITE_FD);
  free(sess);
  close(fd);
}
Exemplo n.º 13
0
int main(int argc, char *argv[])
{

	ng_hci_le_set_event_mask_cp lemc;
	char buf[NG_HCI_ADVERTISING_DATA_SIZE];
	char hname[NG_HCI_ADVERTISING_DATA_SIZE-10];
	int s;
	int ch;
	char *node="ubt0hci";
	int len,addr_valid = 0;
	bdaddr_t bd;
	int sflag = 0;
	int res = -1,handle = -1;
	while((ch = getopt(argc, argv, "s") )!= -1){
		switch(ch){
		case 's':
			sflag = 1;
			break;
		default:
			fprintf(stderr, "Usage: %s [-s] bdaddr\n", argv[0]);
			exit(-1);
			break;
		}
	}
	argc -= optind;
	argv += optind;
	if(argc>0){
	  addr_valid = bt_aton(argv[0],&bd);
	}
	s = open_socket("ubt0hci");
	
	set_event_mask(s,0x20001fffffffffff);
	set_le_event_mask(s, 0x1f);
	read_le_buffer_size(s);
	le_read_local_supported_features(s);
	le_set_scan_param(s, 0, 0x12, 0x12, 0, 0);
	buf[0] = 2;
	buf[1] = 1;
	buf[2] = 0;
	buf[3] = 8;
	
	gethostname(hname, sizeof(hname));
	len = strlen(hname);
#if 1
	memcpy(&buf[5], hname, len);
	buf[4] = len - 1;
	le_set_scan_response(s, sizeof(buf), buf);
	le_read_supported_status(s);
	le_set_scan_enable(s,1);
	le_scan_result(s);
	le_set_scan_enable(s,0);
#endif
	if(addr_valid){
#if 0
	  res = 1;
	  res = le_connect(s, &bd);
	  if(res == 0){
		  handle = le_connect_result(s);
	  }else{
		  printf("CONNECT FAILED\n");
		  return -1;
	  }
	  printf("Handle %x\n", handle);
#endif
	  le_l2connect(&bd, s, sflag);
	  //le_smpconnect(&bd, s);
	  
	}
	
	return 0;
}