Skip to content

Commit

Permalink
pluma.c Fix: deprecated gdk_display_get_screen and gdk_screen_get_number
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0w committed Jul 10, 2017
1 parent 4c2ed0e commit 04db9ce
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pluma/pluma.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ on_message_received (const char *message,
gint viewport_x;
gint viewport_y;
gchar *display_name;
#if !GTK_CHECK_VERSION (3, 22, 0)
gint screen_number;
#endif
gint i;
PlumaApp *app;
PlumaWindow *window;
Expand All @@ -268,10 +270,16 @@ on_message_received (const char *message,
params = g_strsplit (commands[0], "\t", 6);
startup_timestamp = atoi (params[0]);
display_name = params[1];
#if GTK_CHECK_VERSION (3, 22, 0)
workspace = atoi (params[2]);
viewport_x = atoi (params[3]);
viewport_y = atoi (params[4]);
#else
screen_number = atoi (params[2]);
workspace = atoi (params[3]);
viewport_x = atoi (params[4]);
viewport_y = atoi (params[5]);
#endif

display = display_open_if_needed (display_name);
if (display == NULL)
Expand All @@ -281,7 +289,11 @@ on_message_received (const char *message,
goto out;
}

#if GTK_CHECK_VERSION (3, 22, 0)
screen = gdk_display_get_default_screen (display);
#else
screen = gdk_display_get_screen (display, screen_number);
#endif

g_strfreev (params);

Expand Down Expand Up @@ -402,12 +414,25 @@ send_bacon_message (void)
GdkScreen *screen;
GdkDisplay *display;
const gchar *display_name;
#if !GTK_CHECK_VERSION (3, 22, 0)
gint screen_number;
#endif
gint ws;
gint viewport_x;
gint viewport_y;
GString *command;

#if GTK_CHECK_VERSION (3, 22, 0)
/* the messages have the following format:
* <--- header ---> <---- body ----->
* timestamp \t display_name \t workspace \t viewport_x \t viewport_y \v OP1 \t arg \t arg \v OP2 \t arg \t arg|...
*
* when the arg is a list of uri, they are separated by a space.
* So the delimiters are \v for the commands, \t for the tokens in
* a command and ' ' for the uris: note that such delimiters cannot
* be part of an uri, this way parsing is easier.
*/
#else
/* the messages have the following format:
* <--- header ---> <---- body ----->
* timestamp \t display_name \t screen_number \t workspace \t viewport_x \t viewport_y \v OP1 \t arg \t arg \v OP2 \t arg \t arg|...
Expand All @@ -417,17 +442,22 @@ send_bacon_message (void)
* a command and ' ' for the uris: note that such delimiters cannot
* be part of an uri, this way parsing is easier.
*/
#endif

pluma_debug (DEBUG_APP);

screen = gdk_screen_get_default ();
display = gdk_screen_get_display (screen);

display_name = gdk_display_get_name (display);
#if !GTK_CHECK_VERSION (3, 22, 0)
screen_number = gdk_screen_get_number (screen);
#endif

pluma_debug_message (DEBUG_APP, "Display: %s", display_name);
#if !GTK_CHECK_VERSION (3, 22, 0)
pluma_debug_message (DEBUG_APP, "Screen: %d", screen_number);
#endif

ws = pluma_utils_get_current_workspace (screen);
pluma_utils_get_current_viewport (screen, &viewport_x, &viewport_y);
Expand All @@ -436,10 +466,16 @@ send_bacon_message (void)

/* header */
g_string_append_printf (command,
#if GTK_CHECK_VERSION (3, 22, 0)
"%" G_GUINT32_FORMAT "\t%s\t%d\t%d\t%d",
#else
"%" G_GUINT32_FORMAT "\t%s\t%d\t%d\t%d\t%d",
#endif
startup_timestamp,
display_name,
#if !GTK_CHECK_VERSION (3, 22, 0)
screen_number,
#endif
ws,
viewport_x,
viewport_y);
Expand Down

0 comments on commit 04db9ce

Please sign in to comment.