:: [devuan-dev] bug#761: slim: label p…
Etusivu
Poista viesti
Vastaa
Lähettäjä: tom314
Päiväys:  
Vastaanottaja: submit
Aihe: [devuan-dev] bug#761: slim: label position in slimlock vs. slim (fix included)
package: slim
version: 1.4.0-0devuan2

slimlock shows two text-labels (welcome_ and password_). Placement is
relative background, but should be relativepanel-image, like slim.
This is invisible when using a current Devuan theme(s): The panel-image
is placed at 0,0, which equalises the origins in slim and slimlock.
Fix: small patch included, mostly comments in the source as patch-notes.
Maintainers may use it as they see fit.
Patch file:
"slim__slimlock_label_positions__welcome_and_password__bugfix.patch"

System: daedalus
Kernel: 6.3.6-1-liquorix-amd64
((chimaera's 1.3.6: Patch applies with comments rejected. Seems to work
for welcome_ and username_ (not hidden), but not for password_)).


Part II:
Dear maintainer,
beside the bug fix, there is a small piece of code to handle in-line
comments in config files, which is attached too.

Proposed feature: Handle in-line comments in config files (slim.theme).
Reason: Before realising the error, I used in-line comments during
theme'ing.
Patch file: "slim__in-line_comments_in_config_files__addon.patch"
This may or may not be considered useful.


Both are tested, but I'm not really a software developer.
Feel free to contact me for any issues.

Thanks for devuan, slim and all the effort!
Regards,
Thomas
diff -ru -x build slim-1.4.0/panel.cpp slim-1.4.1/panel.cpp
--- slim-1.4.0/panel.cpp    2023-01-22 10:51:28.000000000 +0100
+++ slim-1.4.1/panel.cpp    2023-06-08 19:43:11.624315311 +0200
@@ -181,6 +181,10 @@
         // Thus we apply a hack to offset the input positions. It's a shame
         // we don't do the job properly, as this hack isn't applied to any
         // of the static text
+        /* 2023-06-08: Applied as suggested, in function 'ShowText()' to the
+         * concerning label's positions 'welcome_x,y' and 'password_x,y'.
+         * 'username_x,y' would apply, but is not shown in slimlock.
+         * Details: see blow (grep the date) */
         input_name_x += X;
         input_name_y += Y;
         input_pass_x += X;
@@ -757,6 +761,37 @@


     /// @bug this draw context is assumed relative to the panel but in lock
     ///         mode it's actually relative to the background
+    /* 2023-06-08: 
+     * Fix: Sync remaining label positions in 'slimlock' with 'slim'. 
+     *   In case of slimlock 'if (mode == Mode_Lock)', a coordinate-offset
+     *   is applied to 'welcome_x,y' and 'password_x,y'.
+     * How: The offsets (X, Y) form function 'Panel()' are used here equally.
+     *
+     * *** The following notes can be found (+/-) on slims web-site too
+     * ***  https://slim-fork.sourceforge.io/themes.html 
+     *
+     * Notes about text-label positions:
+     * slimlock: All positions are relative background.
+     * slim: Positions are either relative background or relative 'panel.png'.
+     * Var-names and coordinates gathered in 'cfg.cpp' from 'slim.theme'. 
+     *    Coordinates of 'panel.png' are in:  input_panel_[x,y] 
+     *    Positions relative to 'panel.png' are in: 
+     *       username_x, password_x, input_name_x, input_pass_x, welcome_x
+     *    Absolute positions relative background are in: 
+     *       msg_x , session_x, passwd_feedback_x, input_panel_x
+     * 
+     * Notes on theme'ing:
+     * slim:
+     *  * Labels written at absolute positions are only visible BESIDE 'panel.png'.
+     *  * Labels written at relative positions are only visible ON 'panel.png' itself.
+     * slimlock:
+     *   Shows the relative labels 'welcome_x,y' and 'password_x,y' above background.
+     *   This reveals their positions, even if invisible in slim.
+     * 
+     * layer:
+     *  slim    : bg-color -> bg-image -> bg-labels -> pannel-img -> pannel-labels
+     *  slimlock: composit-backgound -> pannel-labels  
+     */
     XftDraw *draw = XftDrawCreate(Dpy, Win,
           DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
     /* welcome message */
@@ -770,6 +805,10 @@
     welcome_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
     welcome_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
     if (welcome_x >= 0 && welcome_y >= 0) {
+        if (mode == Mode_Lock) {
+            welcome_x += X; 
+            welcome_y += Y;
+        }
         SlimDrawString8 (draw, &welcomecolor, welcomefont,
                          welcome_x, welcome_y,
                          welcome_message,
@@ -789,6 +828,10 @@
         password_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
         password_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
         if (password_x >= 0 && password_y >= 0){
+            if (mode == Mode_Lock) {
+                password_x += X; 
+                password_y += Y;
+            } 
             SlimDrawString8 (draw, &entercolor, enterfont, password_x, password_y,
                              msg, &entershadowcolor, shadowXOffset, shadowYOffset);
         }
@@ -805,6 +848,7 @@
         username_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
         username_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
         if (username_x >= 0 && username_y >= 0){
+            /* if (mode == Mode_Lock) {username_x += X; username_y += Y;} */ /* not shown, just to mark */
             SlimDrawString8 (draw, &entercolor, enterfont, username_x, username_y,
                              msg, &entershadowcolor, shadowXOffset, shadowYOffset);
         }

diff -ru -x build slim-1.4.0/cfg.cpp slim-1.4.1/cfg.cpp
--- slim-1.4.0/cfg.cpp    2023-01-22 10:51:28.000000000 +0100
+++ slim-1.4.1/cfg.cpp    2023-06-08 19:38:52.539127875 +0200
@@ -213,6 +213,13 @@
     }
     name = line.substr ( 0, pos );
     value = Trim ( line.substr ( pos ) );
+    // In case of in-line comments:  value = 'strings # comment'.  
+    // Find '#' past the 1st character (colour), then cut and trim again.
+    pos = value.find_first_of ( '#', 1 );      
+    if ( pos > 0 && pos < string::npos )
+    { 
+        value = Trim ( value.substr( 0, pos ) );  
+    }
     if ( value.empty() )
     {
         error = "Badly formed line: " + line;