ソースを参照

Fixed bug where slop would ignore the environment variable DISPLAY.

Dalton Nell 10 年 前
コミット
5a98bc1b57
共有6 個のファイルを変更した21 個の追加9 個の削除を含む
  1. 1
    1
      CMakeLists.txt
  2. 2
    2
      README.md
  3. 3
    3
      src/cmdline.c
  4. 1
    1
      src/cmdline.in
  5. 14
    1
      src/main.cpp
  6. 0
    1
      src/options.ggo

+ 1
- 1
CMakeLists.txt ファイルの表示

@@ -3,7 +3,7 @@ cmake_minimum_required( VERSION 2.8 )
3 3
 project( "slop" )
4 4
 set( slop_VERSION_MAJOR 3 )
5 5
 set( slop_VERSION_MINOR 1 )
6
-set( slop_VERSION_PATCH 10 )
6
+set( slop_VERSION_PATCH 11 )
7 7
 
8 8
 set( BIN_TARGET     "${PROJECT_NAME}" )
9 9
 set( CMAKE_INSTALL_PREFIX "/usr/bin" )

+ 2
- 2
README.md ファイルの表示

@@ -82,7 +82,7 @@ Make sure to check out and install [maim](https://github.com/naelstrof/maim) too
82 82
 help
83 83
 ----
84 84
 ```text
85
-slop v3.1.10
85
+slop v3.1.11
86 86
 
87 87
 Copyright (C) 2014 Dalton Nell, Slop Contributors
88 88
 (https://github.com/naelstrof/slop/graphs/contributors)
@@ -96,7 +96,7 @@ user and prints the region to stdout.
96 96
   -V, --version                 Print version and exit
97 97
 Options
98 98
       --xdisplay=hostname:number.screen_number
99
-                                Sets the x display.  (default=`:0')
99
+                                Sets the x display.
100 100
       --nokeyboard              Disables the ability to cancel selections with
101 101
                                   the keyboard.  (default=off)
102 102
   -b, --bordersize=INT          Set the selection rectangle's thickness. Does

+ 3
- 3
src/cmdline.c ファイルの表示

@@ -37,7 +37,7 @@ const char *gengetopt_args_info_help[] = {
37 37
   "  -h, --help                    Print help and exit",
38 38
   "  -V, --version                 Print version and exit",
39 39
   "Options",
40
-  "      --xdisplay=hostname:number.screen_number\n                                Sets the x display.  (default=`:0')",
40
+  "      --xdisplay=hostname:number.screen_number\n                                Sets the x display.",
41 41
   "      --nokeyboard              Disables the ability to cancel selections with\n                                  the keyboard.  (default=off)",
42 42
   "  -b, --bordersize=INT          Set the selection rectangle's thickness. Does\n                                  nothing when --highlight is enabled.\n                                  (default=`5')",
43 43
   "  -p, --padding=INT             Set the padding size of the selection. Can be\n                                  negative.  (default=`0')",
@@ -95,7 +95,7 @@ static
95 95
 void clear_args (struct gengetopt_args_info *args_info)
96 96
 {
97 97
   FIX_UNUSED (args_info);
98
-  args_info->xdisplay_arg = gengetopt_strdup (":0");
98
+  args_info->xdisplay_arg = NULL;
99 99
   args_info->xdisplay_orig = NULL;
100 100
   args_info->nokeyboard_flag = 0;
101 101
   args_info->bordersize_arg = 5;
@@ -680,7 +680,7 @@ cmdline_parser_internal (
680 680
           
681 681
             if (update_arg( (void *)&(args_info->xdisplay_arg), 
682 682
                  &(args_info->xdisplay_orig), &(args_info->xdisplay_given),
683
-                &(local_args_info.xdisplay_given), optarg, 0, ":0", ARG_STRING,
683
+                &(local_args_info.xdisplay_given), optarg, 0, 0, ARG_STRING,
684 684
                 check_ambiguity, override, 0, 0,
685 685
                 "xdisplay", '-',
686 686
                 additional_error))

+ 1
- 1
src/cmdline.in ファイルの表示

@@ -39,7 +39,7 @@ struct gengetopt_args_info
39 39
 {
40 40
   const char *help_help; /**< @brief Print help and exit help description.  */
41 41
   const char *version_help; /**< @brief Print version and exit help description.  */
42
-  char * xdisplay_arg;	/**< @brief Sets the x display. (default=':0').  */
42
+  char * xdisplay_arg;	/**< @brief Sets the x display..  */
43 43
   char * xdisplay_orig;	/**< @brief Sets the x display. original value given at command line.  */
44 44
   const char *xdisplay_help; /**< @brief Sets the x display. help description.  */
45 45
   int nokeyboard_flag;	/**< @brief Disables the ability to cancel selections with the keyboard. (default=off).  */

+ 14
- 1
src/main.cpp ファイルの表示

@@ -191,7 +191,20 @@ int app( int argc, char** argv ) {
191 191
     slop::Rectangle* selection = NULL;
192 192
     Window window = None;
193 193
     Window windowmemory = None;
194
-    std::string xdisplay = options.xdisplay_arg;
194
+    std::string xdisplay;
195
+    if ( options.xdisplay_given ) {
196
+        xdisplay = options.xdisplay_arg;
197
+    } else {
198
+        // If we weren't specifically given a xdisplay, we try
199
+        // to parse it from environment variables
200
+        char* display = getenv( "DISPLAY" );
201
+        if ( display ) {
202
+            xdisplay = display;
203
+        } else {
204
+            fprintf( stderr, "Warning: Failed to parse environment variable: DISPLAY. Using \":0\" instead.\n" );
205
+            xdisplay = ":0";
206
+        }
207
+    }
195 208
     int padding = options.padding_arg;
196 209
     int borderSize = options.bordersize_arg;
197 210
     int tolerance = options.tolerance_arg;

+ 0
- 1
src/options.ggo ファイルの表示

@@ -9,7 +9,6 @@ text "Options"
9 9
 option "xdisplay" - "Sets the x display."
10 10
     string
11 11
     typestr="hostname:number.screen_number"
12
-    default=":0"
13 12
     optional
14 13
 
15 14
 option "nokeyboard" - "Disables the ability to cancel selections with the keyboard."