WebColorPickerGtk::WebColorPickerGtk(WebPageProxy& page, const Color& initialColor, const IntRect&) : WebColorPicker(&page) , m_initialColor(initialColor) , m_webView(page.viewWidget()) , m_colorChooser(nullptr) { }
GestureController::ZoomGesture::ZoomGesture(WebPageProxy& page) : Gesture(gtk_gesture_zoom_new(page.viewWidget()), page) , m_initialScale(0) , m_scale(0) { g_signal_connect_swapped(m_gesture.get(), "begin", G_CALLBACK(begin), this); g_signal_connect_swapped(m_gesture.get(), "scale-changed", G_CALLBACK(scaleChanged), this); }
std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify) { GdkWindow* parentWindow = gtk_widget_get_parent_window(webPage.viewWidget()); ASSERT(GDK_IS_WINDOW(parentWindow)); if (!supportsXDamageAndXComposite(parentWindow)) return nullptr; return std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(webPage, initialSize, WTFMove(damageNotify))); }
GestureController::DragGesture::DragGesture(WebPageProxy& page) : Gesture(gtk_gesture_drag_new(page.viewWidget()), page) , m_inDrag(false) { gtk_gesture_single_set_touch_only(GTK_GESTURE_SINGLE(m_gesture.get()), TRUE); g_signal_connect_swapped(m_gesture.get(), "drag-begin", G_CALLBACK(begin), this); g_signal_connect_swapped(m_gesture.get(), "drag-update", G_CALLBACK(update), this); g_signal_connect_swapped(m_gesture.get(), "end", G_CALLBACK(end), this); }
RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify) : m_webPage(webPage) , m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gtk_widget_get_parent_window(webPage.viewWidget())))) , m_size(initialSize) { m_size.scale(m_webPage.deviceScaleFactor()); ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display); Screen* screen = DefaultScreenOfDisplay(m_display); GdkVisual* visual = gdk_window_get_visual(gtk_widget_get_parent_window(webPage.viewWidget())); XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone)); // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc XSetWindowAttributes windowAttributes; windowAttributes.override_redirect = True; windowAttributes.colormap = colormap.get(); // CWBorderPixel must be present when the depth doesn't match the parent's one. // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703. windowAttributes.border_pixel = 0; m_parentWindow = XCreateWindow(m_display, RootWindowOfScreen(screen), WidthOfScreen(screen) + 1, 0, 1, 1, 0, gdk_visual_get_depth(visual), InputOutput, GDK_VISUAL_XVISUAL(visual), CWOverrideRedirect | CWColormap | CWBorderPixel, &windowAttributes); XMapWindow(m_display, m_parentWindow.get()); windowAttributes.event_mask = StructureNotifyMask; windowAttributes.override_redirect = False; // Create the window of at last 1x1 since X doesn't allow to create empty windows. m_window = XCreateWindow(m_display, m_parentWindow.get(), 0, 0, std::max(1, m_size.width()), std::max(1, m_size.height()), 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &windowAttributes); XMapWindow(m_display, m_window.get()); xDamageNotifier().add(m_window.get(), WTFMove(damageNotify)); while (1) { XEvent event; XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &event); if (event.type == MapNotify && event.xmap.window == m_window.get()) break; } XSelectInput(m_display, m_window.get(), NoEventMask); XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual); if (!m_size.isEmpty()) createNewPixampAndPixampSurface(); m_damage = XDamageCreate(m_display, m_window.get(), XDamageReportNonEmpty); }