int ServerProxy::handleCheckDrop() { T_list channelList = activeChannels_.copyList(); for (T_list::iterator j = channelList.begin(); j != channelList.end(); j++) { int channelId = *j; if (channels_[channelId] != NULL && (channels_[channelId] -> getDrop() == 1 || channels_[channelId] -> getClosing() == 1)) { #ifdef TEST *logofs << "ServerProxy: Dropping the descriptor FD#" << getFd(channelId) << " channel ID#" << channelId << ".\n" << logofs_flush; #endif handleDrop(channelId); } } return 1; }
bool UINode::onMouseButtonRelease (int32_t x, int32_t y, unsigned char button) { if (!_enabled) return false; for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) { UINode* nodePtr = *i; if (!nodePtr->hasFocus()) continue; if (nodePtr->onMouseButtonRelease(x - getRenderX(), y - getRenderY(), button)) { return true; } } switch (button) { case SDL_BUTTON_LEFT: handleDrop(x, y); return onMouseLeftRelease(x, y); case SDL_BUTTON_RIGHT: return onMouseRightRelease(x, y); case SDL_BUTTON_MIDDLE: return onMouseMiddleRelease(x, y); } return false; }
void QXcbDrag::drop(const QMouseEvent *event) { QBasicDrag::drop(event); if (!current_target) return; xcb_client_message_event_t drop; drop.response_type = XCB_CLIENT_MESSAGE; drop.window = current_target; drop.format = 32; drop.type = atom(QXcbAtom::XdndDrop); drop.data.data32[0] = connection()->clipboard()->owner(); drop.data.data32[1] = 0; // flags drop.data.data32[2] = connection()->time(); drop.data.data32[3] = 0; drop.data.data32[4] = currentDrag()->supportedActions(); QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) w = 0; Transaction t = { connection()->time(), current_target, current_proxy_target, (w ? w->window() : 0), // current_embeddig_widget, currentDrag(), QTime::currentTime() }; transactions.append(t); // timer is needed only for drops that came from other processes. if (!t.targetWindow && cleanup_timer == -1) { cleanup_timer = startTimer(XdndDropTransactionTimeout); } if (w) { handleDrop(w->window(), &drop); } else { xcb_send_event(xcb_connection(), false, current_proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&drop); } current_target = 0; current_proxy_target = 0; source_time = 0; // current_embedding_widget = 0; }
bool UINode::onFingerRelease (int64_t finger, uint16_t x, uint16_t y) { handleDrop(x, y); execute(); for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) { UINode* nodePtr = *i; if (!nodePtr->hasFocus()) continue; if (nodePtr->onFingerRelease(finger, x - getRenderX(), y - getRenderY())) { return true; } } return false; }
void DeckViewCardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { setCursor(Qt::OpenHandCursor); DeckViewScene *sc = static_cast<DeckViewScene *>(scene()); sc->removeItem(this); if (currentZone) { handleDrop(currentZone); for (int i = 0; i < childDrags.size(); i++) { DeckViewCardDragItem *c = static_cast<DeckViewCardDragItem *>(childDrags[i]); c->handleDrop(currentZone); sc->removeItem(c); } sc->updateContents(); } event->accept(); }
void handleChars(GLFWwindow * w, unsigned int code) { if(verboseOutput) debug << "A character has been pressed! Specifically, character #" << code << std::endl; if(code == ' ') isPaused = !isPaused; else if(code == '+') { graphZoom *= 1.5; if(graphZoom > maxZoom) graphZoom = maxZoom; } else if(code == '-') { graphZoom /= 1.5; if(graphZoom < 1) graphZoom = 1; } else if(code == '>' || code == '.') { shiftPressed ? turnNumber += 5 : turnNumber++; isPaused = true; } else if(code == '<' || code == ',') { shiftPressed ? turnNumber -= 5 : turnNumber--; isPaused = true; } else if(code == 'Z' || code == 'z') { turnNumber = 0; } else if(code == 'X' || code == 'x') { turnNumber = numTurns - 1; } else if(code == 'R' || code == 'r') { if(filename != "") { const char * fn = filename.c_str(); handleDrop(window, 1, &fn); } } #ifndef __APPLE__ else if(code == 'F' || code == 'f') { isWindowed ? setFullscreen() : setWindowed(); } #endif else if(code == 'O' || code == 'o') { xOffset = 0; yOffset = -1; } }
void GameHandler::processMessage(NetComputer *computer, MessageIn &message) { GameClient &client = *static_cast<GameClient *>(computer); if (client.status == CLIENT_LOGIN) { if (message.getId() != PGMSG_CONNECT) return; std::string magic_token = message.readString(MAGIC_TOKEN_LENGTH); client.status = CLIENT_QUEUED; // Before the addPendingClient mTokenCollector.addPendingClient(magic_token, &client); return; } else if (client.status != CLIENT_CONNECTED) { return; } switch (message.getId()) { case PGMSG_SAY: handleSay(client, message); break; case PGMSG_NPC_TALK: case PGMSG_NPC_TALK_NEXT: case PGMSG_NPC_SELECT: case PGMSG_NPC_NUMBER: case PGMSG_NPC_STRING: handleNpc(client, message); break; case PGMSG_PICKUP: handlePickup(client, message); break; case PGMSG_USE_ITEM: handleUseItem(client, message); break; case PGMSG_DROP: handleDrop(client, message); break; case PGMSG_WALK: handleWalk(client, message); break; case PGMSG_EQUIP: handleEquip(client, message); break; case PGMSG_UNEQUIP: handleUnequip(client, message); break; case PGMSG_MOVE_ITEM: handleMoveItem(client, message); break; case PGMSG_ATTACK: handleAttack(client, message); break; case PGMSG_USE_SPECIAL_ON_BEING: handleUseSpecialOnBeing(client, message); break; case PGMSG_USE_SPECIAL_ON_POINT: handleUseSpecialOnPoint(client, message); break; case PGMSG_ACTION_CHANGE: handleActionChange(client, message); break; case PGMSG_DIRECTION_CHANGE: handleDirectionChange(client, message); break; case PGMSG_DISCONNECT: handleDisconnect(client, message); break; case PGMSG_TRADE_REQUEST: handleTradeRequest(client, message); break; case PGMSG_TRADE_CANCEL: case PGMSG_TRADE_AGREED: case PGMSG_TRADE_CONFIRM: case PGMSG_TRADE_ADD_ITEM: case PGMSG_TRADE_SET_MONEY: handleTrade(client, message); break; case PGMSG_NPC_BUYSELL: handleNpcBuySell(client, message); break; case PGMSG_RAISE_ATTRIBUTE: handleRaiseAttribute(client, message); break; case PGMSG_LOWER_ATTRIBUTE: handleLowerAttribute(client, message); break; case PGMSG_RESPAWN: // plausibility check is done by character class client.character->respawn(); break; case PGMSG_NPC_POST_SEND: handleNpcPostSend(client, message); break; case PGMSG_PARTY_INVITE: handlePartyInvite(client, message); break; case PGMSG_BEING_EMOTE: handleTriggerEmoticon(client, message); break; default: LOG_WARN("Invalid message type"); client.send(MessageOut(XXMSG_INVALID)); break; } }
bool QgsPGConnectionItem::handleDrop( const QMimeData *data, Qt::DropAction ) { return handleDrop( data, QString() ); }
INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstnace, PSTR lpCmdLine, INT nCmdShow) { #else int main(int argc, const char ** argv) { #endif std::string loc(argv[0]); std::replace(loc.begin(), loc.end(), '\\', '/'); loc = loc.substr(0, loc.find_last_of('/')); #ifdef _WIN32 _chdir(loc.c_str()); #else if(chdir(loc.c_str())) return EXIT_FAILURE; #endif //Open debug: debug.open("logs/debug.log", std::ios_base::out | std::ios_base::binary); if(!debug.is_open()) debug.open("debug.log", std::ios_base::out); debug.flush(); //start GL context and O/S window using the GLFW helper library if(!glfwInit()) { debug << "Could not start GLFW3\n"; return EXIT_FAILURE; } util::initShaderHandler(&debug); window = NULL; GLFWmonitor* primary = glfwGetPrimaryMonitor(); const GLFWvidmode * mode = glfwGetVideoMode(primary); glfwWindowHint(GLFW_REFRESH_RATE, 60); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwSwapInterval(0); windowedWidth = mode->width * 3 / 4; windowedHeight = mode->height * 2 / 3; setWindowed(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0, 0, 0, 1); if(argc > 1) { if(strcmp(argv[1], "-v") == 0) { verboseOutput = true; if(argc == 3) { debug << "About to handle the drop of the provided (arg 3) file!" << std::endl; handleDrop(window, 1, (const char **)(argv + 2)); } else { while(isLaunch && !glfwWindowShouldClose(window)) { debug << "About to enter renderLaunch!" << std::endl; renderLaunch(); } } } else if(argc == 2) handleDrop(window, 1, (const char **)(argv + 1)); } else { while(isLaunch && !glfwWindowShouldClose(window)) { renderLaunch(); } } if(verboseOutput) { const char * glVersion = (const char * )glGetString(GL_VERSION); debug << glVersion; debug.flush(); } glfwSwapInterval(1); clock_t c = clock(); if(verboseOutput) debug << "Entering main render loop!" << std::endl; while(!glfwWindowShouldClose(window)) { if(hPressed) { float delta = float(clock() - c) / CLOCKS_PER_SEC; if(verboseOutput) debug << "[In help render loop] Frame time of " << delta << ".\n"; c = clock(); if(verboseOutput) debug << "About to clear color & depth buffer bits in render help loop" << std::endl; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(verboseOutput) debug << "Getting window height from glfw in render help loop" << std::endl; int height; glfwGetWindowSize(window, NULL, &height); if(verboseOutput) debug << "Rendering text in render help loop" << std::endl; util::renderText(-.85, 0.65, height / 6, { 1, 1, 1 }, "Halite Visualizer Help!"); renderHelp(height); if(verboseOutput) debug << "Swapping buffers in render help loop" << std::endl; glfwSwapBuffers(window); if(verboseOutput) debug << "Polling events in render help loop" << std::endl; glfwPollEvents(); } else { //Limit render rate: float delta = float(clock() - c) / CLOCKS_PER_SEC; if(verboseOutput) debug << "[In game render loop] Frame time of " << delta << ".\n"; c = clock(); short turnNumberS = turnNumber; if(verboseOutput) debug << "About to render at turn #" << turnNumberS << std::endl; my_game->render(window, turnNumberS, graphZoom, mouseX, mouseY, tabPressed, mousePressed, xOffset, yOffset); if(verboseOutput) debug << "Just rendered turn #" << turnNumberS << std::endl; if(abs(turnNumber - float(turnNumberS) >= 1)) turnNumber = turnNumberS; //Means it's gone past the right edge //Poll events glfwPollEvents(); if(verboseOutput) debug << "Polled events in render game loop!" << std::endl; if(upPressed && maxFps <= 120) maxFps += maxFps * delta; else if(downPressed && maxFps != 4) maxFps -= maxFps * delta; if(leftPressed) { if(shiftPressed) turnNumber -= 5 * maxFps * delta; else turnNumber -= maxFps * delta; } else if(rightPressed) { if(shiftPressed) turnNumber += 5 * maxFps * delta; else turnNumber += maxFps * delta; } else if(!isPaused && !tabPressed) turnNumber += maxFps * delta; if(turnNumber < 0) turnNumber = 0; if(wPressed) yOffset -= SHIFT; if(aPressed) xOffset += SHIFT; if(sPressed) yOffset += SHIFT; if(dPressed) xOffset -= SHIFT; if(verboseOutput) debug << "Finished iteration of render game loop!!" << std::endl; } } return EXIT_SUCCESS; }
void TreeView::itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y) { handleDrop (StringArray(), sourceDescription, sourceComponent, x, y); }
void TreeView::filesDropped (const StringArray& files, int x, int y) { handleDrop (files, String::empty, 0, x, y); }
void ReadWidget::dropEvent(QDropEvent * event) { handleDrop(event); }
void SceneView::onGUI() { PROFILE_FUNCTION(); m_is_opened = false; ImVec2 view_pos; const char* title = "Scene View###Scene View"; if (m_log_ui && m_log_ui->getUnreadErrorCount() > 0) { title = "Scene View | errors in log###Scene View"; } if (ImGui::BeginDock(title, nullptr, ImGuiWindowFlags_NoScrollWithMouse)) { m_is_opened = true; onToolbar(); auto size = ImGui::GetContentRegionAvail(); auto* fb = m_pipeline->getFramebuffer("default"); if (size.x > 0 && size.y > 0 && fb) { auto pos = ImGui::GetWindowPos(); m_pipeline->setViewport(0, 0, int(size.x), int(size.y)); m_texture_handle = fb->getRenderbufferHandle(0); auto cursor_pos = ImGui::GetCursorScreenPos(); m_screen_x = int(cursor_pos.x); m_screen_y = int(cursor_pos.y); m_width = int(size.x); m_height = int(size.y); auto content_min = ImGui::GetCursorScreenPos(); ImVec2 content_max(content_min.x + size.x, content_min.y + size.y); if (m_is_opengl) { ImGui::Image(&m_texture_handle, size, ImVec2(0, 1), ImVec2(1, 0)); } else { ImGui::Image(&m_texture_handle, size); } if (ImGui::IsItemHoveredRect()) { if (ImGui::IsMouseReleased(0) && m_app.getDragData().type == StudioApp::DragData::PATH) { float x = (ImGui::GetMousePos().x - content_min.x) / size.x; float y = (ImGui::GetMousePos().y - content_min.y) / size.y; handleDrop(x, y); } } view_pos = content_min; auto rel_mp = ImGui::GetMousePos(); rel_mp.x -= m_screen_x; rel_mp.y -= m_screen_y; if (ImGui::IsItemHovered()) { m_editor->getGizmo().enableStep(m_toggle_gizmo_step_action->isActive()); for (int i = 0; i < 3; ++i) { if (ImGui::IsMouseClicked(i)) { ImGui::ResetActiveID(); if(i == 1) captureMouse(true); m_editor->onMouseDown((int)rel_mp.x, (int)rel_mp.y, (Lumix::MouseButton::Value)i); break; } } } if (m_is_mouse_captured || ImGui::IsItemHovered()) { auto& input = m_editor->getEngine().getInputSystem(); auto delta = Lumix::Vec2(input.getMouseXMove(), input.getMouseYMove()); if (delta.x != 0 || delta.y != 0) { m_editor->onMouseMove((int)rel_mp.x, (int)rel_mp.y, (int)delta.x, (int)delta.y); } } for (int i = 0; i < 3; ++i) { auto rel_mp = ImGui::GetMousePos(); rel_mp.x -= m_screen_x; rel_mp.y -= m_screen_y; if (ImGui::IsMouseReleased(i)) { if (i == 1) captureMouse(false); m_editor->onMouseUp((int)rel_mp.x, (int)rel_mp.y, (Lumix::MouseButton::Value)i); } } m_pipeline->render(); } } ImGui::EndDock(); if(m_show_stats) { float toolbar_height = 24 + ImGui::GetStyle().FramePadding.y * 2; view_pos.x += ImGui::GetStyle().FramePadding.x; view_pos.y += ImGui::GetStyle().FramePadding.y + toolbar_height; ImGui::SetNextWindowPos(view_pos); auto col = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; col.w = 0.3f; ImGui::PushStyleColor(ImGuiCol_WindowBg, col); if (ImGui::Begin("###stats_overlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ShowBorders)) { const auto& stats = m_pipeline->getStats(); ImGui::LabelText("Draw calls", "%d", stats.draw_call_count); ImGui::LabelText("Instances", "%d", stats.instance_count); char buf[30]; Lumix::toCStringPretty(stats.triangle_count, buf, Lumix::lengthOf(buf)); ImGui::LabelText("Triangles", "%s", buf); ImGui::LabelText("Resolution", "%dx%d", m_pipeline->getWidth(), m_pipeline->getHeight()); ImGui::LabelText("FPS", "%.2f", m_editor->getEngine().getFPS()); ImGui::LabelText("CPU time", "%.2f", m_pipeline->getCPUTime() * 1000.0f); ImGui::LabelText("GPU time", "%.2f", m_pipeline->getGPUTime() * 1000.0f); ImGui::LabelText("Waiting for submit", "%.2f", m_pipeline->getWaitSubmitTime() * 1000.0f); ImGui::LabelText("Waiting for render thread", "%.2f", m_pipeline->getGPUTime() * 1000.0f); } ImGui::End(); ImGui::PopStyleColor(); } }