diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-08-15 18:54:02 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-10-02 11:01:54 +0530 |
commit | fa02b6361f582d67efaaadc4e8664617b69340e0 (patch) | |
tree | 408f0fd5a73271b6833ffe4c15cf860db5e02889 /libreofficekit/qa/gtktiledviewer | |
parent | 81c00c9b47fd5a8ca03829386ee97342fb6aa847 (diff) |
lokdialog: Smoother mouse move on floating windows
Do away with an early hack to create the floating window with every
invalidate.
This gets rid of persistent blinking when moving the mouse over a
listbox, for example.
Change-Id: Ida9367156605edc9835529f83529363ad97beaee
Diffstat (limited to 'libreofficekit/qa/gtktiledviewer')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index b711c3bc034e..c7f5bfe39e10 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -598,34 +598,34 @@ void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY) GtvLokDialogPrivate* priv = getPrivate(dialog); // remove any existing floating windows, for now - if (priv->pFloatingWin) - gtk_widget_destroy(priv->pFloatingWin); - - priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP); - GtkWidget* pDrawingArea = gtk_drawing_area_new(); - gtk_container_add(GTK_CONTAINER(priv->pFloatingWin), pDrawingArea); - - gtk_window_set_transient_for(GTK_WINDOW(priv->pFloatingWin), GTK_WINDOW(dialog)); - gtk_window_set_destroy_with_parent(GTK_WINDOW(priv->pFloatingWin), true); - - gtk_widget_add_events(pDrawingArea, - GDK_BUTTON_PRESS_MASK - |GDK_POINTER_MOTION_MASK - |GDK_BUTTON_RELEASE_MASK - |GDK_BUTTON_MOTION_MASK); - - g_signal_connect(G_OBJECT(pDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_floating_win_draw), dialog); - g_signal_connect(G_OBJECT(pDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog); - g_signal_connect(G_OBJECT(pDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog); - g_signal_connect(G_OBJECT(pDrawingArea), "motion-notify-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_motion), dialog); - - gtk_widget_set_size_request(priv->pFloatingWin, 1, 1); - gtk_window_set_type_hint(GTK_WINDOW(priv->pFloatingWin), GDK_WINDOW_TYPE_HINT_POPUP_MENU); - gtk_window_set_screen(GTK_WINDOW(priv->pFloatingWin), gtk_window_get_screen(GTK_WINDOW(dialog))); - - gtk_widget_show_all(priv->pFloatingWin); - gtk_window_present(GTK_WINDOW(priv->pFloatingWin)); - gtk_widget_grab_focus(pDrawingArea); + if (!priv->pFloatingWin) + { + priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP); + GtkWidget* pDrawingArea = gtk_drawing_area_new(); + gtk_container_add(GTK_CONTAINER(priv->pFloatingWin), pDrawingArea); + + gtk_window_set_transient_for(GTK_WINDOW(priv->pFloatingWin), GTK_WINDOW(dialog)); + gtk_window_set_destroy_with_parent(GTK_WINDOW(priv->pFloatingWin), true); + + gtk_widget_add_events(pDrawingArea, + GDK_BUTTON_PRESS_MASK + |GDK_POINTER_MOTION_MASK + |GDK_BUTTON_RELEASE_MASK + |GDK_BUTTON_MOTION_MASK); + + g_signal_connect(G_OBJECT(pDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_floating_win_draw), dialog); + g_signal_connect(G_OBJECT(pDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog); + g_signal_connect(G_OBJECT(pDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_button), dialog); + g_signal_connect(G_OBJECT(pDrawingArea), "motion-notify-event", G_CALLBACK(gtv_lok_dialog_floating_win_signal_motion), dialog); + + gtk_widget_set_size_request(priv->pFloatingWin, 1, 1); + gtk_window_set_type_hint(GTK_WINDOW(priv->pFloatingWin), GDK_WINDOW_TYPE_HINT_POPUP_MENU); + gtk_window_set_screen(GTK_WINDOW(priv->pFloatingWin), gtk_window_get_screen(GTK_WINDOW(dialog))); + + gtk_widget_show_all(priv->pFloatingWin); + gtk_window_present(GTK_WINDOW(priv->pFloatingWin)); + gtk_widget_grab_focus(pDrawingArea); + } // Get the root coords of our new floating window GdkWindow* pGdkWin = gtk_widget_get_window(GTK_WIDGET(dialog)); @@ -633,6 +633,8 @@ void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY) int nrY = 0; gdk_window_get_root_coords(pGdkWin, nX, nY, &nrX, &nrY); gtk_window_move(GTK_WINDOW(priv->pFloatingWin), nrX, nrY); + + gtk_widget_queue_draw(priv->pFloatingWin); } void gtv_lok_dialog_child_close(GtvLokDialog* dialog) |