void MyScrollArea::wheelEvent(QWheelEvent *event) { if(event->modifiers() == Qt::ControlModifier) { int percent; if(event->delta() > 0) { percent = mw->pvbtab[mw->currentTab].interpreter.percentZoomMask + 5; if(percent > 250) percent = 250; } else { percent = mw->pvbtab[mw->currentTab].interpreter.percentZoomMask - 5; if(percent < 10) percent = 10; } mw->pvbtab[mw->currentTab].interpreter.zoomMask(percent); int width = (mw->pvbtab[mw->currentTab].w * percent) / 100; // start int height = (mw->pvbtab[mw->currentTab].h * percent) / 100; // if(mw->pvbtab[mw->currentTab].rootWidget != NULL) // adjust scrollbars to new size mw->pvbtab[mw->currentTab].rootWidget->resize(width, height); // adjust scrollbars to new size QEvent resize_event(QEvent::Resize); // QApplication::sendEvent(mw, &resize_event); // end event->accept(); } else { QScrollArea::wheelEvent(event);; } }
int RecordMonitorGUI::redraw() { lock_window("RecordMonitorGUI::redraw"); int w = mwindow->session->rmonitor_w; int h = mwindow->session->rmonitor_h; int result = resize_event(w, h); unlock_window(); return result; }
void VWindowGUI::update_meters() { if(mwindow->edl->session->vwindow_meter != meters->visible) { meters->set_meters(meters->meter_count, mwindow->edl->session->vwindow_meter); mwindow->theme->get_vwindow_sizes(this); resize_event(get_w(), get_h()); } }
void x_window_rep::set_full_screen (bool flag) { if (full_screen_flag == flag) return; string old_name= get_name (); if (old_name == "") old_name= as_string (name); if (flag) { save_win= win; name= NULL; save_x= win_x; save_y= win_y; save_w= win_w; save_h= win_h; initialize (); XMoveResizeWindow (dpy, win, 0, 0, gui->screen_width, gui->screen_height); move_event (0, 0); resize_event (gui->screen_width, gui->screen_height); set_visibility (true); XSetInputFocus (dpy, win, PointerRoot, CurrentTime); } else { set_visibility (false); Window_to_window->reset (win); nr_windows--; XDestroyWindow (dpy, win); win= save_win; set_visibility (false); Window_to_window->reset (win); nr_windows--; XDestroyWindow (dpy, win); //FIXME: is this 'as_charp' a possible memory leak? name= as_charp (old_name); win_x= save_x; win_y= save_y; win_w= save_w; win_h= save_h; initialize (); set_visibility (true); XMoveResizeWindow (dpy, win, save_x, save_y, save_w, save_h); resize_event (save_w, save_h); move_event (save_x, save_y); } set_name (old_name); full_screen_flag= flag; }
bool MyScrollArea::event(QEvent *event) { #if QT_VERSION >= 0x040600 //for some reason the panning gesture is handled in qscrollarea //we add pinch gesture: static int ignore_gesture = 0; if(event->type() == QEvent::Gesture && ignore_gesture == 0 && mw->pvbtab[mw->currentTab].s != -1) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); if(QGesture *ge_pinch = ge->gesture(Qt::PinchGesture)) { static int mod = 0; // only respond to every 5'th pinch gesture QPinchGesture *pinch=static_cast<QPinchGesture *>(ge_pinch); int percent = mw->pvbtab[mw->currentTab].interpreter.percentZoomMask; int old_percent = percent; if (pinch->scaleFactor() < 0.99f) percent -= 5; else if(pinch->scaleFactor() > 1.01f) percent += 5; if(percent<10) percent=10; else if(percent>250) percent=250; //char buf[1024]; //sprintf(buf,"percent=%d old_percent=%d scaleFactor=%f", percent, old_percent, pinch->scaleFactor()); //mw->statusBar()->showMessage(buf); mod++; if(percent != old_percent && (mod % 5) == 0 && ignore_gesture == 0) { ignore_gesture = 1; mod = 0; mw->pvbtab[mw->currentTab].interpreter.zoomMask(percent); // will set ...interpreter.percentZoomMask int width = (mw->pvbtab[mw->currentTab].w * percent) / 100; // these lines int height = (mw->pvbtab[mw->currentTab].h * percent) / 100; // should if(mw->pvbtab[mw->currentTab].rootWidget != NULL) // mw->pvbtab[mw->currentTab].rootWidget->resize(width, height); // resize QEvent resize_event(QEvent::Resize); // scrollbars QApplication::sendEvent(mw, &resize_event); // correctly qApp->processEvents(); ignore_gesture = 0; } ge->accept(); return true; } else if(ignore_gesture == 1) { ge->accept(); return true; } } #endif return QScrollArea::event(event); }
/** * @brief Renderer::render render a single frame, then return * @return true if the user wants to quit the application */ bool Renderer::render(){ process_keys(SDL_GetKeyboardState(NULL)); SDL_Event e; while(SDL_PollEvent(&e)){ if(e.type == SDL_QUIT){ printf("received SDL_QUIT\n"); quit_flag = true; } else if(e.type == SDL_MOUSEMOTION){ mousemove_event(e.motion.xrel, e.motion.yrel); } else if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED){ resize_event(e.window.data1, e.window.data2); std::cout << "window resized" << std::endl; } } glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); world_to_camera_matrix = look_matrix(camera_vertical, camera_horizontal, camera_position); camera_to_clip_matrix = glm::mat4( glm::vec4(frustum_scale/(width/(float)height), 0.0, 0.0, 0.0), glm::vec4(0.0, frustum_scale, 0.0, 0.0), glm::vec4(0.0, 0.0, (z_far + z_near)/(z_near - z_far), (2*z_far*z_near)/(z_near - z_far)), glm::vec4(0.0, 0.0, -1.0, 0.0)); // update uniforms for all shaders now (no UBOs in 2.x, unfortunately...) axes_shader->set_camera_to_clip(camera_to_clip_matrix); axes_shader->set_world_to_camera(world_to_camera_matrix); render_axes(); trails_shader->set_camera_to_clip(camera_to_clip_matrix); trails_shader->set_world_to_camera(world_to_camera_matrix); render_trails(); pointsprites_shader->set_camera_to_clip(camera_to_clip_matrix); pointsprites_shader->set_world_to_camera(world_to_camera_matrix); pointsprites_shader->set_uniform("camera_position", camera_position); render_pointsprites(); render_center_of_mass(); SDL_GL_SwapWindow(win); //SDL_Delay(1000/60.0); // limit to 60FPS return quit_flag; }
int w32_console_read_socket (struct terminal *terminal, struct input_event *hold_quit) { int nev, add; int isdead; block_input (); for (;;) { int nfnotify = handle_file_notifications (hold_quit); nev = fill_queue (0); if (nev <= 0) { /* If nev == -1, there was some kind of error If nev == 0 then no events were available so return. */ if (nfnotify) nev = 0; break; } while (nev > 0) { struct input_event inev; EVENT_INIT (inev); inev.kind = NO_EVENT; inev.arg = Qnil; switch (queue_ptr->EventType) { case KEY_EVENT: add = key_event (&queue_ptr->Event.KeyEvent, &inev, &isdead); if (add == -1) /* 95.7.25 by himi */ { queue_ptr--; add = 1; } if (add) kbd_buffer_store_event_hold (&inev, hold_quit); break; case MOUSE_EVENT: add = do_mouse_event (&queue_ptr->Event.MouseEvent, &inev); if (add) kbd_buffer_store_event_hold (&inev, hold_quit); break; case WINDOW_BUFFER_SIZE_EVENT: if (w32_use_full_screen_buffer) resize_event (&queue_ptr->Event.WindowBufferSizeEvent); break; case MENU_EVENT: case FOCUS_EVENT: /* Internal event types, ignored. */ break; } queue_ptr++; nev--; } } /* We don't get told about changes in the window size (only the buffer size, which we no longer care about), so we have to check it periodically. */ if (!w32_use_full_screen_buffer) maybe_generate_resize_event (); unblock_input (); return nev; }
int w32_console_read_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) { BOOL no_events = TRUE; int nev, ret = 0, add; int isdead; if (interrupt_input_blocked) { interrupt_input_pending = 1; return -1; } interrupt_input_pending = 0; BLOCK_INPUT; for (;;) { nev = fill_queue (0); if (nev <= 0) { /* If nev == -1, there was some kind of error If nev == 0 then waitp must be zero and no events were available so return. */ UNBLOCK_INPUT; return nev; } while (nev > 0) { struct input_event inev; EVENT_INIT (inev); inev.kind = NO_EVENT; inev.arg = Qnil; switch (queue_ptr->EventType) { case KEY_EVENT: add = key_event (&queue_ptr->Event.KeyEvent, &inev, &isdead); if (add == -1) /* 95.7.25 by himi */ { queue_ptr--; add = 1; } if (add) kbd_buffer_store_event_hold (&inev, hold_quit); break; case MOUSE_EVENT: add = do_mouse_event (&queue_ptr->Event.MouseEvent, &inev); if (add) kbd_buffer_store_event_hold (&inev, hold_quit); break; case WINDOW_BUFFER_SIZE_EVENT: if (w32_use_full_screen_buffer) resize_event (&queue_ptr->Event.WindowBufferSizeEvent); break; case MENU_EVENT: case FOCUS_EVENT: /* Internal event types, ignored. */ break; } queue_ptr++; nev--; } if (ret > 0 || expected == 0) break; } /* We don't get told about changes in the window size (only the buffer size, which we no longer care about), so we have to check it periodically. */ if (!w32_use_full_screen_buffer) maybe_generate_resize_event (); UNBLOCK_INPUT; return ret; }