void decor_frame_refresh (decor_frame_t *frame) { decor_shadow_options_t active_o, inactive_o; decor_shadow_info_t *info; const gchar *titlebar_font = NULL; gwd_decor_frame_ref (frame); update_style (frame->style_window_rgba); update_style (frame->style_window_rgb); g_object_get (settings, "titlebar-font", &titlebar_font, NULL); set_frame_scale (frame, titlebar_font); titlebar_font = NULL; frame_update_titlebar_font (frame); if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0) (*theme_update_border_extents) (frame); (*theme_get_shadow) (frame, &active_o, TRUE); (*theme_get_shadow) (frame, &inactive_o, FALSE); info = malloc (sizeof (decor_shadow_info_t)); if (!info) return; info->frame = frame; info->state = 0; frame_update_shadow (frame, info, &active_o, &inactive_o); gwd_decor_frame_unref (frame); free (info); info = NULL; }
void Application::scroll_event(float offset_x, float offset_y) { update_style(); switch(mode) { case EDIT_MODE: case VISUALIZE_MODE: camera.move_forward(-offset_y * scroll_rate); break; case RENDER_MODE: break; } }
static void on_config_style_scheme_changed(GSettings *settings, const char *key) { I7App *theapp = i7_app_get(); char *newvalue = g_settings_get_string(settings, key); /* TODO: validate new value? */ /* update application to reflect new value */ select_style_scheme(theapp->prefs->schemes_view, newvalue); update_style(GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(theapp->prefs->source_example)))); i7_app_foreach_document(theapp, (I7DocumentForeachFunc)i7_document_update_fonts, NULL); i7_app_foreach_document(theapp, (I7DocumentForeachFunc)i7_document_update_font_styles, NULL); g_free(newvalue); }
static void style_updated (GtkWidget *widget, void *user_data) { GdkDisplay *gdkdisplay; GdkScreen *gdkscreen; WnckScreen *screen; PangoContext *context = (PangoContext *) user_data; gdkdisplay = gdk_display_get_default (); gdkscreen = gdk_display_get_default_screen (gdkdisplay); screen = wnck_screen_get_default (); update_style (widget); pango_cairo_context_set_resolution (context, gdk_screen_get_resolution (gdkscreen)); decorations_changed (screen); }
/** * \brief Initialize w32_common framework. * * The first function that should be called from the w32_common framework. * It handles window creation on the screen with proper title and attributes. * It also initializes the framework's internal variables. The function should * be called after your own preinit initialization and you shouldn't do any * window management on your own. * * Global libvo variables changed: * vo_w32_window * vo_screenwidth * vo_screenheight * * \return 1 = Success, 0 = Failure */ int vo_w32_init(struct vo *vo) { struct vo_w32_state *w32 = vo->w32; if (w32 && w32->window) return 1; if (!w32) w32 = vo->w32 = talloc_zero(vo, struct vo_w32_state); HINSTANCE hInstance = GetModuleHandleW(NULL); HICON mplayerIcon = LoadIconW(hInstance, L"IDI_ICON1"); WNDCLASSEXW wcex = { .cbSize = sizeof wcex, .style = CS_OWNDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, .lpfnWndProc = WndProc, .hInstance = hInstance, .hIcon = mplayerIcon, .hCursor = LoadCursor(0, IDC_ARROW), .lpszClassName = classname, .hIconSm = mplayerIcon, }; if (!RegisterClassExW(&wcex)) { mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to register window class!\n"); return 0; } if (vo->opts->WinID >= 0) { RECT r; GetClientRect(WIN_ID_TO_HWND(vo->opts->WinID), &r); vo->dwidth = r.right; vo->dheight = r.bottom; w32->window = CreateWindowExW(WS_EX_NOPARENTNOTIFY, classname, classname, WS_CHILD | WS_VISIBLE, 0, 0, vo->dwidth, vo->dheight, WIN_ID_TO_HWND(vo->opts->WinID), 0, hInstance, vo); } else { w32->window = CreateWindowExW(0, classname, classname, update_style(vo, 0), CW_USEDEFAULT, 0, 100, 100, 0, 0, hInstance, vo); } if (!w32->window) { mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to create window!\n"); return 0; } if (vo->opts->WinID >= 0) EnableWindow(w32->window, 0); // we don't have proper event handling vo->wakeup_period = 0.02; updateScreenProperties(vo); mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d\n", vo->opts->screenwidth, vo->opts->screenheight); return 1; } /** * \brief Toogle fullscreen / windowed mode. * * Should be called on VOCTRL_FULLSCREEN event. The window is * always resized during this call, so the rendering context * should be reinitialized with the new dimensions. * It is unspecified if vo_check_events will create a resize * event in addition or not. */ void vo_w32_fullscreen(struct vo *vo) { vo->opts->fs = !vo->opts->fs; reinit_window_state(vo); }
// Update the window title, position, size, and border style from vo_* values. static int reinit_window_state(struct vo *vo) { struct vo_w32_state *w32 = vo->w32; HWND layer = HWND_NOTOPMOST; RECT r; if (vo->opts->WinID >= 0) return 1; wchar_t *title = mp_from_utf8(NULL, vo_get_window_title(vo)); SetWindowTextW(w32->window, title); talloc_free(title); bool toggle_fs = w32->current_fs != vo->opts->fs; w32->current_fs = vo->opts->fs; DWORD style = update_style(vo, GetWindowLong(w32->window, GWL_STYLE)); if (vo->opts->fs || vo->opts->ontop) layer = HWND_TOPMOST; // xxx not sure if this can trigger any unwanted messages (WM_MOVE/WM_SIZE) if (vo->opts->fs) { while (ShowCursor(0) >= 0) /**/ ; } else { while (ShowCursor(1) < 0) /**/ ; } updateScreenProperties(vo); if (vo->opts->fs) { // Save window position and size when switching to fullscreen. if (toggle_fs) { w32->prev_width = vo->dwidth; w32->prev_height = vo->dheight; w32->prev_x = w32->window_x; w32->prev_y = w32->window_y; mp_msg(MSGT_VO, MSGL_V, "[vo] save window bounds: %d:%d:%d:%d\n", w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height); } vo->dwidth = vo->opts->screenwidth; vo->dheight = vo->opts->screenheight; w32->window_x = vo->xinerama_x; w32->window_y = vo->xinerama_y; } else { if (toggle_fs) { // Restore window position and size when switching from fullscreen. mp_msg(MSGT_VO, MSGL_V, "[vo] restore window bounds: %d:%d:%d:%d\n", w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height); vo->dwidth = w32->prev_width; vo->dheight = w32->prev_height; w32->window_x = w32->prev_x; w32->window_y = w32->prev_y; } } r.left = w32->window_x; r.right = r.left + vo->dwidth; r.top = w32->window_y; r.bottom = r.top + vo->dheight; SetWindowLong(w32->window, GWL_STYLE, style); add_window_borders(w32->window, &r); mp_msg(MSGT_VO, MSGL_V, "[vo] reset window bounds: %d:%d:%d:%d\n", (int) r.left, (int) r.top, (int)(r.right - r.left), (int)(r.bottom - r.top)); SetWindowPos(w32->window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); // For some reason, moving SWP_SHOWWINDOW to a second call works better // with wine: returning from fullscreen doesn't cause a bogus resize to // screen size. // It's not needed on Windows XP or wine with a virtual desktop. // It doesn't seem to have any negative effects. SetWindowPos(w32->window, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); return 1; }
/** * \brief Initialize w32_common framework. * * The first function that should be called from the w32_common framework. * It handles window creation on the screen with proper title and attributes. * It also initializes the framework's internal variables. The function should * be called after your own preinit initialization and you shouldn't do any * window management on your own. * * Global libvo variables changed: * vo_w32_window * vo_screenwidth * vo_screenheight * * \return 1 = Success, 0 = Failure */ int vo_w32_init(struct vo *vo) { assert(!vo->w32); struct vo_w32_state *w32 = talloc_zero(vo, struct vo_w32_state); vo->w32 = w32; HINSTANCE hInstance = GetModuleHandleW(NULL); HICON mplayerIcon = LoadIconW(hInstance, L"IDI_ICON1"); WNDCLASSEXW wcex = { .cbSize = sizeof wcex, .style = CS_OWNDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, .lpfnWndProc = WndProc, .hInstance = hInstance, .hIcon = mplayerIcon, .hCursor = LoadCursor(NULL, IDC_ARROW), .lpszClassName = classname, .hIconSm = mplayerIcon, }; if (!RegisterClassExW(&wcex)) { MP_ERR(vo, "win32: unable to register window class!\n"); return 0; } if (vo->opts->WinID >= 0) { RECT r; GetClientRect(WIN_ID_TO_HWND(vo->opts->WinID), &r); vo->dwidth = r.right; vo->dheight = r.bottom; w32->window = CreateWindowExW(WS_EX_NOPARENTNOTIFY, classname, classname, WS_CHILD | WS_VISIBLE, 0, 0, vo->dwidth, vo->dheight, WIN_ID_TO_HWND(vo->opts->WinID), 0, hInstance, vo); } else { w32->window = CreateWindowExW(0, classname, classname, update_style(vo, 0), CW_USEDEFAULT, 0, 100, 100, 0, 0, hInstance, vo); } if (!w32->window) { MP_ERR(vo, "win32: unable to create window!\n"); return 0; } w32->tracking = FALSE; w32->trackEvent = (TRACKMOUSEEVENT){ .cbSize = sizeof(TRACKMOUSEEVENT), .dwFlags = TME_LEAVE, .hwndTrack = w32->window, }; if (vo->opts->WinID >= 0) EnableWindow(w32->window, 0); w32->cursor_visible = true; // we don't have proper event handling vo->wakeup_period = 0.02; updateScreenProperties(vo); MP_VERBOSE(vo, "win32: running at %dx%d\n", vo->opts->screenwidth, vo->opts->screenheight); return 1; } /** * \brief Toogle fullscreen / windowed mode. * * Should be called on VOCTRL_FULLSCREEN event. The window is * always resized during this call, so the rendering context * should be reinitialized with the new dimensions. * It is unspecified if vo_check_events will create a resize * event in addition or not. */ static void vo_w32_fullscreen(struct vo *vo) { if (vo->opts->fullscreen != vo->w32->current_fs) reinit_window_state(vo); } /** * \brief Toogle window border attribute. * * Should be called on VOCTRL_BORDER event. */ static void vo_w32_border(struct vo *vo) { vo->opts->border = !vo->opts->border; reinit_window_state(vo); } /** * \brief Toogle window ontop attribute. * * Should be called on VOCTRL_ONTOP event. */ static void vo_w32_ontop(struct vo *vo) { vo->opts->ontop = !vo->opts->ontop; reinit_window_state(vo); }