Пример #1
0
void ShellSurface::restore()
{
    if (!m_minimized) {
        return;
    }

    m_minimized = false;
    m_forceMap = true;
    committed(0, 0);
    emit restored();
}
void checkEnumeratorToEnumerator(CryptoNote::ParentBlock& pb, uint64_t ts, uint32_t nonce, bool hashingSerialization, bool headerOnly) {
  std::stringstream archive;

  CryptoNote::ParentBlockSerializer original(pb, ts, nonce, hashingSerialization, headerOnly);
  CryptoNote::BinaryOutputStreamSerializer output(archive);
  output(original, "");

  CryptoNote::ParentBlock restoredPb;
  uint64_t restoredTs;
  uint32_t restoredNonce;

  CryptoNote::ParentBlockSerializer restored(restoredPb, restoredTs, restoredNonce, hashingSerialization, headerOnly);

  CryptoNote::BinaryInputStreamSerializer input(archive);
  input(restored, "");

  EXPECT_EQ(nonce, restoredNonce);
  EXPECT_EQ(ts, restoredTs);

  ASSERT_NO_FATAL_FAILURE(compareParentBlocks(pb, restoredPb, headerOnly));
}
Пример #3
0
int dispatcher::execute( void )
{
	xcb_flush( _connection );
	_exit_code = 0;

	bool done = false;
	while ( !done )
	{
		auto event = core::wrap_cptr( xcb_wait_for_event( _connection ) );
		if ( !event )
			break;
		switch ( event->response_type & ~0x80 )
		{
			case XCB_EXPOSE:
			{
				auto *ev = reinterpret_cast<xcb_expose_event_t*>( event.get() );
				if ( ev->count == 0 )
					_windows[ev->window]->exposed();
				xcb_flush( _connection );
				break;
			}

			case XCB_CONFIGURE_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_configure_notify_event_t*>( event.get() );
				auto w = _windows[ev->window];
				if ( w->check_last_position( ev->x, ev->y ) )
					w->moved( ev->x, ev->y );
				if ( w->check_last_size( ev->width, ev->height ) )
					w->resize_canvas( ev->width, ev->height );
				break;
			}

			case XCB_DESTROY_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_destroy_notify_event_t*>( event.get() );
				auto w = _windows[ev->window];
				w->closed();
				break;
			}

			case XCB_MAP_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_map_notify_event_t*>( event.get() );
				auto w = _windows[ev->window];
				w->shown();
				w->restored();
				break;
			}

			case XCB_UNMAP_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_unmap_notify_event_t*>( event.get() );
				auto w = _windows[ev->window];
				w->hidden();
				w->minimized();
				break;
			}

			case XCB_ENTER_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_enter_notify_event_t*>( event.get() );
				auto w = _windows[ev->event];
				w->entered();
				break;
			}

			case XCB_LEAVE_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_leave_notify_event_t*>( event.get() );
				auto w = _windows[ev->event];
				w->exited();
				break;
			}

			case XCB_KEY_PRESS:
			{
				auto *ev = reinterpret_cast<xcb_key_press_event_t*>( event.get() );
				auto w = _windows[ev->event];
				platform::scancode sc = _keyboard->get_scancode( ev->detail );
				w->key_pressed( _keyboard, sc );
				break;
			}

			case XCB_KEY_RELEASE:
			{
				auto *ev = reinterpret_cast<xcb_key_press_event_t*>( event.get() );
				auto w = _windows[ev->event];
				platform::scancode sc = _keyboard->get_scancode( ev->detail );
				w->key_released( _keyboard, sc );
				break;
			}

			case XCB_MAPPING_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_mapping_notify_event_t*>( event.get() );
				if ( ev->request == XCB_MAPPING_MODIFIER || ev->request == XCB_MAPPING_KEYBOARD )
					_keyboard->update_mapping();
				break;
			}

			case XCB_BUTTON_PRESS:
			{
				auto *ev = reinterpret_cast<xcb_button_press_event_t*>( event.get() );
				auto w = _windows[ev->event];
				switch ( ev->detail )
				{
					case 1:
					case 2:
					case 3:
						w->mouse_pressed( _mouse, { double(ev->event_x), double(ev->event_y) }, ev->detail );
						break;

					case 4: // Mouse wheel up
					case 5: // Mouse wheel down
						break;
				}
				break;
			}

			case XCB_BUTTON_RELEASE:
			{
				auto *ev = reinterpret_cast<xcb_button_press_event_t*>( event.get() );
				auto w = _windows[ev->event];
				switch ( ev->detail )
				{
					case 1:
					case 2:
					case 3:
						w->mouse_released( _mouse, { double(ev->event_x), double(ev->event_y) }, ev->detail );
						break;

					case 4: // Mouse wheel up
					case 5: // Mouse wheel down
						break;
				}
				break;
			}

			case XCB_MOTION_NOTIFY:
			{
				auto *ev = reinterpret_cast<xcb_motion_notify_event_t*>( event.get() );
				auto w = _windows[ev->event];
				w->mouse_moved( _mouse, { double(ev->event_x), double(ev->event_y) } );
				break;
			}

			case XCB_VISIBILITY_NOTIFY:
			case XCB_REPARENT_NOTIFY:
				break;

			case XCB_CLIENT_MESSAGE:
			{
				auto *ev = reinterpret_cast<xcb_client_message_event_t*>( event.get() );
				if ( ev->data.data32[0] == _atom_delete_window )
				{
					auto w = _windows[ev->window];
					w->hide();
					_windows.erase( w->id() );
					done = _windows.empty();
				}
				break;
			}

			default:
				std::cout << "Unknown event: " << uint32_t( event->response_type & ~0x80 ) << ' ' << uint32_t( event->response_type ) << std::endl;
		}
	}

	return _exit_code;
}
Пример #4
0
  const SUCCESS Events::handleEvent(const SDL_Event * const Event)
  {
    switch(Event->type)
    {  //newline brackets implemented since this is a lot of nesting
    case SDL_WINDOWEVENT: ///Some sort of input or output gained or lost
      {
        const Uint8 &winID = Event->window.windowID;
        switch(Event->window.event) 
        {
        case SDL_WINDOWEVENT_ENTER:   ///Mouse message handling gained or lost
          return mouseEnter(winID);
          
        case SDL_WINDOWEVENT_LEAVE:   ///General input message handling gained or lost
          return mouseLeave(winID);

        case SDL_WINDOWEVENT_MINIMIZED:   ///Output to the screen at all gained or lost
          return minimized(winID);
          
        case SDL_WINDOWEVENT_RESTORED:
          return restored(winID);
          
        case SDL_WINDOWEVENT_MAXIMIZED:
          return maximized(winID);
          
        case SDL_WINDOWEVENT_SHOWN:
          return shown(winID);
          
        case SDL_WINDOWEVENT_HIDDEN:
          return hidden(winID);
          
        case SDL_WINDOWEVENT_EXPOSED:
          return exposed(winID);
          
        case SDL_WINDOWEVENT_FOCUS_GAINED:
          return keyboardFocusGain(winID);
          
        case SDL_WINDOWEVENT_FOCUS_LOST:
          return keyboardFocusLost(winID);
          
        case SDL_WINDOWEVENT_SIZE_CHANGED:
            return changeSize(winID);
            
        case SDL_WINDOWEVENT_RESIZED:
          return resized(winID, Dimensions<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_MOVED:
          return moved(winID, Point<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_CLOSE:
          return windowExited(winID);
          
        default:   ///For some reason there is an unknown window event
          return FAILED;
        }
        break;
      }
    case SDL_KEYDOWN:
      {
        if(Event->key.repeat)
        {
          return keyHeld(Event->key.windowID, Event->key.keysym);
        }
        else
        {
          return keyPressed(Event->key.windowID, Event->key.keysym);
        }
        break;
      }
    case SDL_KEYUP:
        return keyReleased(Event->key.windowID, Event->key.keysym);
        
    case SDL_TEXTINPUT:
        return textInput(Event->text.windowID, Event->text.text);
        
    case SDL_TEXTEDITING:
        return textEdit(Event->edit.windowID, Event->edit.text, Event->edit.start, Event->edit.length);
        
    case SDL_MOUSEMOTION:
      return mouseMove(Event->motion.windowID, Event->motion.which,
                       Delta<Point<int> >(Point<int>(Event->motion.xrel, Event->motion.yrel), 
                                          Point<int>(Event->motion.x, Event->motion.y)),
                       bitset<N_MOUSE_BUTTONS>(Event->motion.state));
                       
    case SDL_MOUSEBUTTONDOWN:
      return mouseButtonPressed(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                Point<int>(Event->button.x, Event->button.y));
      
    case SDL_MOUSEBUTTONUP:
        return mouseButtonReleased(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                  Point<int>(Event->button.x, Event->button.y));
     
    case SDL_MOUSEWHEEL:
        return mouseWheel(Event->wheel.windowID, Event->wheel.which, Point<int>(Event->wheel.x, Event->wheel.y));
        
    case SDL_JOYAXISMOTION:
      return joyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
    
    case SDL_JOYBUTTONDOWN:
      return joyButtonPressed(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYBUTTONUP:
      return joyButtonReleased(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYHATMOTION:
      return joyHatChange(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
        
    case SDL_JOYBALLMOTION:
      return joyBallMove(Event->jball.which, Event->jball.ball, Point<int>(Event->jball.xrel, Event->jball.yrel));
      
    case SDL_DROPFILE:
    {
      const SUCCESS ret = droppedFile(Event->drop.file);
      SDL_free(Event->drop.file);
      return ret;
    }
      
    case SDL_SYSWMEVENT:
      return unhandledSystemEvent(Event->syswm.msg);
     
    case SDL_QUIT:
      return appExited();
        
    case SDL_USEREVENT:
    default:
      {
        return userEvent(Event->user.windowID, Event->user.code, Event->user.data1, Event->user.data2);
      }
    }

    return FAILED;
  }
Пример #5
0
void perturbEnum(LifeList *seed, LifeList *perturbs, int nperturbs, int depth,
           int maxDepth, int mingen, int maxgencurr, int maxgenall, int maxvanish) {
int i, naligns;
int iperturb, thisgen;


   for (iperturb=0; iperturb<nperturbs; iperturb++) {

     if(depth == 0 && maxDepth > 1)
        fprintf(stderr, "Working with perturber #%d\n", iperturb+1);

     copyLifeList(seed, reaction+depth);
     setValues(reaction[depth].cellList, reaction[depth].ncells, 1);

     naligns=placeNewPerturbor(reaction+depth, perturbs,
                               perturbPlace, depth, iperturb,
                               mingen, maxgencurr, aligns);

     setupPerturbors(perturbs, perturbPlace, depth,
                     &justPerturbs, reaction+depth);


     for (thisgen=0; thisgen<mingen; thisgen++) generate(reaction+depth);

     for (; thisgen<maxgencurr; thisgen++) {
       for (i=0; i<naligns; i++) {
         int j;
         int tvanish = maxvanish;

         int oldcount;
         assert((aligns-alignstore)+i < 100000);
         if (aligns[i].value==thisgen &&
             (depth<=0 || ptbPrecedes(perturbGen[depth-1],
                          perturbPlace[depth-1].value,
                          perturbPlace[depth-1].position,
                          thisgen, iperturb, aligns[i].position))
             ) {
           copyLifeList(reaction+depth, &tmp);

           justPerturbs.ncells=0;
           for (j=0; j<depth; j++) {
               mergeLifeLists(&justPerturbs, perturbs+perturbPlace[j].value,
                                             perturbPlace[j].position);
           }

           mergeLifeLists(&tmp, perturbs+iperturb, aligns[i].position);

           oldcount=justPerturbs.ncells;
           mergeLifeLists(&justPerturbs, perturbs+iperturb,
                                              aligns[i].position);

           // if (iperturb==8) printf("chose a block %d %d\n", perturbs[iperturb].ncells, countGreaterThan(perturbs[iperturb].cellList, perturbs[iperturb].ncells, 1)  );

           if ( countGreaterThan(perturbs[iperturb].cellList,
                                perturbs[iperturb].ncells, 1) ==
                                perturbs[iperturb].ncells) tvanish--;

           if (tvanish>=0 &&
             oldcount+perturbs[iperturb].ncells == justPerturbs.ncells &&
               survives(&tmp, &justPerturbs, 0, 15)) {

             if (depth >= maxDepth) {
               if (restored(&tmp, &justPerturbs, 0, 50)) {
               copyLifeList(seed, &tmp);
               mergeLifeLists(&tmp, &justPerturbs, 0);
               makeString(tmp.cellList, tmp.ncells, out);
//               outTr(perturbPlace[0].position);
//               outTr(perturbPlace[1].position);
//               outTr(aligns[i].position);
               printf("%s %d\n", out, thisgen);
/*
               printf("%d %d %d ", perturbPlace[0].position,
                                  perturbPlace[0].value,
                                  perturbGen[0]);
               printf("%d %d %d\n", aligns[i].position,
                                  iperturb,
                                  aligns[i].value);
*/
               fflush(stdout);
               }
             } else {
               perturbPlace[depth].position= aligns[i].position;
               perturbPlace[depth].value= iperturb;
               perturbGen[depth]= thisgen;
               aligns+=naligns;
               perturbEnum(seed, perturbs, nperturbs, depth+1, maxDepth,
                           thisgen, maxgenall, maxgenall, tvanish);
               aligns-=naligns;
             }
           }
         }
       }
       generate(reaction+depth);
     }
   }
}
Пример #6
0
bool VarEqConstraint::post() {
    restored(nullptr);
    return propagate();
}
Пример #7
0
bool VarSameTermConstraint::post() {
    domcheck(b_->remove(RDF_ERROR));
    restored(nullptr);
    return propagate();
}