pidgin/pidgin

Merged in default (pull request #677)

2020-04-01, Gary Kramlich
4a61873ffc51
Merged in default (pull request #677)

Replace deprecated gdk functions

Approved-by: Elliott Sales de Andrade
--- a/pidgin/gtkconv.c Thu Mar 26 20:23:10 2020 -0500
+++ b/pidgin/gtkconv.c Wed Apr 01 18:07:49 2020 +0000
@@ -7811,34 +7811,46 @@
}
static gboolean gtk_conv_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) {
- int x, y;
-
- if (gtk_widget_get_visible(w))
- gtk_window_get_position(GTK_WINDOW(w), &x, &y);
- else
+ GdkMonitor *monitor = NULL;
+ GdkRectangle geo, window_geo, intersect_geo;
+
+ if(!gtk_widget_get_visible(w)) {
return FALSE; /* carry on normally */
+ }
+
+ gtk_window_get_position(GTK_WINDOW(w), &window_geo.x, &window_geo.y);
+ window_geo.width = event->width;
+ window_geo.height = event->height;
/* Workaround for GTK+ bug # 169811 - "configure_event" is fired
* when the window is being maximized */
if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED)
return FALSE;
- /* don't save off-screen positioning */
- if (x + event->width < 0 ||
- y + event->height < 0 ||
- x > gdk_screen_width() ||
- y > gdk_screen_height())
+ monitor = gdk_display_get_monitor_at_window(gdk_display_get_default(),
+ event->window);
+ gdk_monitor_get_geometry(monitor, &geo);
+
+ /* now make sure that the window is entirely within the monitor. We do
+ * this by finding the intersection of the window on the monitor, if that
+ * is equal to the window's geometry, then the window is fully contained on
+ * the given monitor.
+ */
+ gdk_rectangle_intersect(&geo, &window_geo, &intersect_geo);
+ if(!gdk_rectangle_equal(&window_geo, &intersect_geo)) {
return FALSE; /* carry on normally */
+ }
/* store the position */
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/x", x);
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/y", y);
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width);
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height);
+ purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/x", window_geo.x);
+ purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/y", window_geo.y);
+ purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width",
+ window_geo.width);
+ purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height",
+ window_geo.height);
/* continue to handle event normally */
return FALSE;
-
}
static void
@@ -8574,6 +8586,8 @@
conv_placement_last_created_win_type_configured_cb(GtkWidget *w,
GdkEventConfigure *event, PidginConversation *conv)
{
+ GdkMonitor *monitor = NULL;
+ GdkRectangle geo;
int x, y;
GList *all;
@@ -8587,12 +8601,17 @@
if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED)
return FALSE;
+ monitor = gdk_display_get_monitor_at_window(gdk_display_get_default(),
+ event->window);
+ gdk_monitor_get_geometry(monitor, &geo);
+
/* don't save off-screen positioning */
- if (x + event->width < 0 ||
- y + event->height < 0 ||
- x > gdk_screen_width() ||
- y > gdk_screen_height())
+ if (x + event->width < geo.x ||
+ y + event->height < geo.y ||
+ x > geo.width ||
+ y > geo.height) {
return FALSE; /* carry on normally */
+ }
for (all = conv->convs; all != NULL; all = all->next) {
if (PURPLE_IS_IM_CONVERSATION(conv->active_conv) != PURPLE_IS_IM_CONVERSATION(all->data)) {
--- a/pidgin/gtksound.c Thu Mar 26 20:23:10 2020 -0500
+++ b/pidgin/gtksound.c Wed Apr 01 18:07:49 2020 +0000
@@ -452,7 +452,7 @@
if (purple_strequal(method, "none")) {
return;
} else if (purple_strequal(method, "beep")) {
- gdk_beep();
+ gdk_display_beep(gdk_display_get_default());
return;
}
#ifdef _WIN32
@@ -578,7 +578,7 @@
#else /* #ifdef USE_GSTREAMER */
#ifndef _WIN32
- gdk_beep();
+ gdk_display_beep(gdk_display_get_default());
#else /* _WIN32 */
pidgin_sound_play_file_win32(filename);
#endif /* _WIN32 */
--- a/pidgin/gtkstatusbox.c Thu Mar 26 20:23:10 2020 -0500
+++ b/pidgin/gtkstatusbox.c Wed Apr 01 18:07:49 2020 +0000
@@ -1168,8 +1168,8 @@
static void
pidgin_status_box_list_position (PidginStatusBox *status_box, int *x, int *y, int *width, int *height)
{
- GdkScreen *screen;
gint monitor_num;
+ GdkMonitor *m = NULL;
GdkRectangle monitor;
GtkRequisition popup_req;
GtkPolicyType hpolicy, vpolicy;
@@ -1201,10 +1201,9 @@
*height = popup_req.height;
- screen = gtk_widget_get_screen(GTK_WIDGET(status_box));
- monitor_num = gdk_screen_get_monitor_at_window(screen,
+ m = gdk_display_get_monitor_at_window(gdk_display_get_default(),
gtk_widget_get_window(GTK_WIDGET(status_box)));
- gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor);
+ gdk_monitor_get_geometry(m, &monitor);
if (*x < monitor.x)
*x = monitor.x;
--- a/pidgin/gtkutils.c Thu Mar 26 20:23:10 2020 -0500
+++ b/pidgin/gtkutils.c Wed Apr 01 18:07:49 2020 +0000
@@ -803,16 +803,14 @@
{
GtkWidget *widget;
GtkRequisition requisition;
- GdkScreen *screen;
- GdkRectangle monitor;
- gint monitor_num;
+ GdkMonitor *monitor = NULL;
+ GdkRectangle geo;
gint space_left, space_right, space_above, space_below;
gboolean rtl;
g_return_if_fail(GTK_IS_MENU(menu));
widget = GTK_WIDGET(menu);
- screen = gtk_widget_get_screen(widget);
rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
/*
@@ -823,7 +821,7 @@
*/
gtk_widget_get_preferred_size(widget, NULL, &requisition);
- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+ monitor = gdk_display_get_monitor_at_point(gdk_display_get_default(), *x, *y);
*push_in = FALSE;
@@ -846,12 +844,12 @@
* Positioning in the vertical direction is similar: first try below
* mouse cursor, then above.
*/
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- space_left = *x - monitor.x;
- space_right = monitor.x + monitor.width - *x - 1;
- space_above = *y - monitor.y;
- space_below = monitor.y + monitor.height - *y - 1;
+ gdk_monitor_get_geometry(monitor, &geo);
+
+ space_left = *x - geo.x;
+ space_right = geo.x + geo.width - *x - 1;
+ space_above = *y - geo.y;
+ space_below = geo.y + geo.height - *y - 1;
/* position horizontally */
@@ -867,7 +865,7 @@
/* x is clamped on-screen further down */
}
- else if (requisition.width <= monitor.width)
+ else if (requisition.width <= geo.width)
{
/* the menu is too big to fit on either side of the mouse
* cursor, but smaller than the monitor. Position it on
@@ -876,12 +874,12 @@
if (space_left > space_right)
{
/* left justify */
- *x = monitor.x;
+ *x = geo.x;
}
else
{
/* right justify */
- *x = monitor.x + monitor.width - requisition.width;
+ *x = geo.x + geo.width - requisition.width;
}
}
else /* menu is simply too big for the monitor */
@@ -889,12 +887,12 @@
if (rtl)
{
/* right justify */
- *x = monitor.x + monitor.width - requisition.width;
+ *x = geo.x + geo.width - requisition.width;
}
else
{
/* left justify */
- *x = monitor.x;
+ *x = geo.x;
}
}
@@ -909,13 +907,13 @@
*y = *y - requisition.height + 1;
}
- *y = CLAMP (*y, monitor.y,
- monitor.y + monitor.height - requisition.height);
+ *y = CLAMP (*y, geo.y,
+ geo.y + geo.height - requisition.height);
} else {
if (space_below >= space_above)
- *y = monitor.y + monitor.height - requisition.height;
+ *y = geo.y + geo.height - requisition.height;
else
- *y = monitor.y;
+ *y = geo.y;
}
}
--- a/pidgin/pidgintooltip.c Thu Mar 26 20:23:10 2020 -0500
+++ b/pidgin/pidgintooltip.c Wed Apr 01 18:07:49 2020 +0000
@@ -130,20 +130,20 @@
{
int scr_w, scr_h, x, y, dy;
int preserved_x, preserved_y;
- int mon_num;
- GdkScreen *screen = NULL;
+ GdkDisplay *display = NULL;
+ GdkSeat *seat = NULL;
+ GdkMonitor *monitor = NULL;
+ GdkDevice *dev = NULL;
GdkRectangle mon_size;
GtkWidget *tipwindow = pidgin_tooltip.tipwindow;
- GdkSeat *seat;
- GdkDevice *dev;
-
- seat = gdk_display_get_default_seat(gdk_display_get_default());
+ display = gdk_display_get_default();
+ seat = gdk_display_get_default_seat(display);
dev = gdk_seat_get_pointer(seat);
- gdk_device_get_position(dev, &screen, &x, &y);
+ gdk_device_get_position(dev, NULL, &x, &y);
- mon_num = gdk_screen_get_monitor_at_point(screen, x, y);
- gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size);
+ monitor = gdk_display_get_monitor_at_point(display, x, y);
+ gdk_monitor_get_geometry(monitor, &mon_size);
scr_w = mon_size.width + mon_size.x;
scr_h = mon_size.height + mon_size.y;