Bug 516920 - Calendar Pop up disappears of the left side

The last change did not check for the left screen edge. This update
checks for the calendar pop up going over the left, right, and
bottom edges of the screen. The top should not be an issue.
This commit is contained in:
Robert Fewell 2016-12-27 11:53:49 +00:00 committed by Geert Janssens
parent 2a97675bee
commit b798a6cdbd

View File

@ -1181,6 +1181,8 @@ gnc_dense_cal_button_press(GtkWidget *widget,
GtkAllocation alloc;
gint doc;
GncDenseCal *dcal = GNC_DENSE_CAL(widget);
gint win_xpos = evt->x_root + 5;
gint win_ypos = evt->y_root + 5;
doc = wheres_this(dcal, evt->x, evt->y);
dcal->showPopup = ~(dcal->showPopup);
@ -1200,11 +1202,13 @@ gnc_dense_cal_button_press(GtkWidget *widget,
gtk_widget_queue_resize(GTK_WIDGET(dcal->transPopup));
gtk_widget_show_all(GTK_WIDGET(dcal->transPopup));
if ((evt->x_root + 5 + alloc.width > gdk_screen_get_width(screen))||
(evt->y_root + 5 + alloc.height > gdk_screen_get_height(screen)))
gtk_window_move(GTK_WINDOW(dcal->transPopup), evt->x_root - 2 - alloc.width, evt->y_root - 2 - alloc.height);
else
gtk_window_move(GTK_WINDOW(dcal->transPopup), evt->x_root + 5, evt->y_root + 5);
if (evt->x_root + 5 + alloc.width > gdk_screen_get_width(screen))
win_xpos = evt->x_root - 2 - alloc.width;
if (evt->y_root + 5 + alloc.height > gdk_screen_get_height(screen))
win_ypos = evt->y_root - 2 - alloc.height;
gtk_window_move(GTK_WINDOW(dcal->transPopup), win_xpos, win_ypos);
}
else
gtk_widget_hide(GTK_WIDGET(dcal->transPopup));
@ -1221,6 +1225,8 @@ gnc_dense_cal_motion_notify(GtkWidget *widget,
gint doc;
int unused;
GdkModifierType unused2;
gint win_xpos = event->x_root + 5;
gint win_ypos = event->y_root + 5;
dcal = GNC_DENSE_CAL(widget);
if (!dcal->showPopup)
@ -1238,13 +1244,15 @@ gnc_dense_cal_motion_notify(GtkWidget *widget,
gtk_widget_get_allocation(GTK_WIDGET(dcal->transPopup), &alloc);
gtk_widget_show_all(GTK_WIDGET(dcal->transPopup));
gtk_widget_show_all(GTK_WIDGET(dcal->transPopup));
if ((event->x_root + 5 + alloc.width > gdk_screen_get_width(screen))||
(event->y_root + 5 + alloc.height > gdk_screen_get_height(screen)))
gtk_window_move(GTK_WINDOW(dcal->transPopup), event->x_root - 2 - alloc.width, event->y_root - 2 - alloc.height);
else
gtk_window_move(GTK_WINDOW(dcal->transPopup), event->x_root + 5, event->y_root + 5);
if (event->x_root + 5 + alloc.width > gdk_screen_get_width(screen))
win_xpos = event->x_root - 2 - alloc.width;
if (event->y_root + 5 + alloc.height > gdk_screen_get_height(screen))
win_ypos = event->y_root - 2 - alloc.height;
gtk_window_move(GTK_WINDOW(dcal->transPopup), win_xpos, win_ypos);
}
else
gtk_widget_hide(GTK_WIDGET(dcal->transPopup));