Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1orwzB-0003Im-7S for mharc-grub-devel@gnu.org; Mon, 07 Nov 2022 02:56:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orwzA-0003Ie-8a for grub-devel@gnu.org; Mon, 07 Nov 2022 02:56:00 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orwz8-0000md-1y for grub-devel@gnu.org; Mon, 07 Nov 2022 02:56:00 -0500 Received: by mail-pf1-x435.google.com with SMTP id i3so9844210pfc.11 for ; Sun, 06 Nov 2022 23:55:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1api2AHdID/cwaNcBG0p2ZUUZnxLtEEKkQ8SooXDMFw=; b=IStKCZby/+NfS9plHbIOUh3ctltXdcSo1IYPG2amv6PbxREQH5h+c6trGfe1CoqOcT ySVhtDt10OKrVaUP8qE8sqXNZyGBsnWFC1Oe90eKGCybWmO56ast+GA1JE/DH3ogJu7T Q8ngrsn4j5LVrd5u4x+Q6Q+VmZ2w+GAkd2+f0de00bpZtKMagDQ3C6eTns4aEjXHtKAO Pf6nawV1WkH6Y+ddV7oMugD9//WpnDM5qEMfgms/AaIEMxm7bHcWF1zS4UfJmtykSfkl Tjcw4biC11tWzci6cX5fo8XIngT87uuphz6HKPEN9moGH9GqzabsD5Ovs8fR1k5uf6zZ aVlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1api2AHdID/cwaNcBG0p2ZUUZnxLtEEKkQ8SooXDMFw=; b=pUrxanJkVArv+S7q61oOHQEKCDbOSj5XNt2MlGq1BuuG278ZiTRfylH5NzYbLPM4G+ abHMxu4nrN/ytgF4wE7cne1Yemj1/rH5Q5qseO8ltTVt/OCXqqo2qDIpovOc6cGP0onF Ym2Jedfze+crl0pff8emL8OIF/N0U+YeyGfb3t4XqT0UTRMX7oCAxTI6NYu56q8trV7W QemQv/FgRzx2m4CwflQOYotoz8IwGkTCApT6UOIh6PXrBEWTTBARlyBQztI2BU1cWKK0 yTK+c2JuiFdljp8L4B+7aUrRbwOZNUu8HgW6anblTsrS928Bbgu1djMeyJYbsmlW6H8p 5HGw== X-Gm-Message-State: ACrzQf139sefQ+OTmdYcVeSVU397fz5RDN0yBJjUlUWETXBzcRxyt8k1 GsPRyd7uKW6vSqS9ECN/4vU= X-Google-Smtp-Source: AMsMyM73PUjDfTQVP9lCoRKsUGZAkJQML2yl8RZSij0+iiJVOduuVVG7SK39+3kcXbBdCrtzpeMxTQ== X-Received: by 2002:a05:6a00:3699:b0:56c:80f6:bee with SMTP id dw25-20020a056a00369900b0056c80f60beemr49911731pfb.13.1667807752819; Sun, 06 Nov 2022 23:55:52 -0800 (PST) Received: from [0.0.0.0] (ec2-13-113-80-70.ap-northeast-1.compute.amazonaws.com. [13.113.80.70]) by smtp.gmail.com with ESMTPSA id e4-20020a17090a684400b00212daa6f41dsm3621810pjm.28.2022.11.06.23.55.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Nov 2022 23:55:52 -0800 (PST) Message-ID: <45d8f1f2-9df5-fda8-d003-d61aef4f83e1@gmail.com> Date: Mon, 7 Nov 2022 15:55:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: AW: Adding --set to videoinfo to retrieve current video resolution Content-Language: en-US To: Markus Scholz , grub-devel@gnu.org Cc: phcoder@gmail.com, pmenzel@molgen.mpg.de, 'Daniel Kiper' References: <032301d8de3f$990fe010$cb2fa030$@novelsense.com> <20221020173602.ls3hbhtnwhis4mrl@tomti.i.net-space.pl> <00f501d8e79b$1073c7c0$315b5740$@novelsense.com> From: Zhang Boyang In-Reply-To: <00f501d8e79b$1073c7c0$315b5740$@novelsense.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=zhangboyang.id@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2022 07:56:00 -0000 Hi, Sorry for late reply... I think my patch is almost independent of Markus's, and it would be good to have both. However, I think there are some point we can share opinions. I'd like to ask your opinions of the mechanism of choosing font size automatically. In my patch (preliminary), it scales Unifont(16x16) M times on a N x 1080p screen, with M = pow(2,ceil(log2(N))), e.g. 2x when (1080p, 2160p], 4x when (2160p, 4320p], 8x when (4320p, 8640p]. This approach seems not good enough, and it might not suitable for custom themes. What's your opinion on this from your perspective? I will probably go back to work on my HiDPI patch after few weeks. By the way, if I understand correctly, you patch seems reversed, and your mail client seems corrupted your patch. You might find "git format-patch" and "git send-email" useful :) Best Regards, Zhang Boyang On 2022/10/24 19:23, Markus Scholz wrote: > Hi all, > > * I checked the links by Daniel (thanks for providing). > * As I understand it Zhangs patches aim to add a high dpi scaling feature > for the fonts > * In contrast, the patch I submitted (albeit having a similar use-case) adds > the possibility > for grub "scripts" / config files to access & act upon the currently used > display resolution > * for me both things would have their merit and independent use-cases > > What is your opinion on having both features? > > Besides, I am willing to help progress both features - if someone can guide > me /give a hint > how to proceed best? > > Thank you > Markus > > > -----Ursprüngliche Nachricht----- > Von: Daniel Kiper > Gesendet: Donnerstag, 20. Oktober 2022 19:36 > An: Markus Scholz > Cc: grub-devel@gnu.org; phcoder@gmail.com; pmenzel@molgen.mpg.de; > zhangboyang.id@gmail.com > Betreff: Re: Adding --set to videoinfo to retrieve current video resolution > > Adding Paul, Vladimir, and Zhang... > > On Wed, Oct 12, 2022 at 03:36:13PM +0200, Markus Scholz wrote: >> Dear Grub Developers, >> >> recently we faced the problem the author in this old thread faced: >> - https://lists.gnu.org/archive/html/grub-devel/2012-10/msg00009.html >> >> Ie. our theme wouldn't display properly due to different screen > resolutions. >> Hence, I wanted to change specifically the font size of our theme >> given the current resolution. >> While the videoinfo module provides info about the current resolution >> I wasn't able to discover any way to get the info from the booted >> grub. >> >> Following the aforementioned thread, I therefore patched the videoinfo >> mod to add the ability of a -set switch just like commands like >> "smbinfo" or "search" have. >> >> Ie. the documentation of the videoinfo call could change as follows: >> >> Command: videoinfo [--set var | [WxH]xD] >> >> Retrieve available video modes. If --set is given, assign the >> currently active resolution to var. >> If --set is not provided the available video modes are listed. >> If resolution is given, show only matching modes. >> >> Attached is my patch proposal for the module; I probably made a lot >> mistakes wrt. >> coding style and guidelines - please bear with me. >> >> I would be grateful regarding feedback what I could do / how I could >> improve the patch to make it part of grub? If it possible at all with this > approach? > > I think fix for similar problem has been proposed here [1] and I commented > it here [2]. Sadly it ended in limbo. Could you work with Zhang on this > issue? > > Daniel > > [1] https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00143.html > [2] https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00027.html > >> Thank you for your reply & best, >> Markus >> >> --- >> >> --- grub-mod/grub-core/commands/videoinfo.c 2022-10-12 >> 13:30:54.992451000 +0000 >> +++ grub/grub-core/commands/videoinfo.c 2022-10-12 > 13:31:37.715512000 +0000 >> @@ -30,7 +30,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct hook_ctx { >> unsigned height, width, depth; >> - unsigned char set_variable; >> struct grub_video_mode_info *current_mode; }; >> >> @@ -39,9 +38,6 @@ hook (const struct grub_video_mode_info { >> struct hook_ctx *ctx = hook_arg; >> >> - if (ctx->set_variable) /* if variable should be set don't print all >> modes */ >> - return 0; >> - >> if (ctx->height && ctx->width && (info->width != ctx->width || >> info->height != ctx->height)) >> return 0; >> >> @@ -136,40 +132,31 @@ grub_cmd_videoinfo (grub_command_t cmd _ >> grub_video_adapter_t adapter; >> grub_video_driver_id_t id; >> struct hook_ctx ctx; >> - >> - ctx.height = ctx.width = ctx.depth = ctx.set_variable = 0; >> - >> + >> + ctx.height = ctx.width = ctx.depth = 0; >> if (argc) >> { >> - if (argc == 2 && grub_memcmp(args[0], "--set", sizeof ("--set") - > 1) >> == 0 ) >> - ctx.set_variable = 1; >> - else >> - { >> const char *ptr; >> ptr = args[0]; >> ctx.width = grub_strtoul (ptr, &ptr, 0); >> if (grub_errno) >> - return grub_errno; >> + return grub_errno; >> if (*ptr != 'x') >> - return grub_error (GRUB_ERR_BAD_ARGUMENT, >> - N_("invalid video mode specification `%s'"), >> - args[0]); >> + return grub_error (GRUB_ERR_BAD_ARGUMENT, >> + N_("invalid video mode specification `%s'"), >> + args[0]); >> ptr++; >> ctx.height = grub_strtoul (ptr, &ptr, 0); >> if (grub_errno) >> - return grub_errno; >> + return grub_errno; >> if (*ptr == 'x') >> - { >> - ptr++; >> - ctx.depth = grub_strtoul (ptr, &ptr, 0); >> - if (grub_errno) >> - return grub_errno; >> - } >> - } >> - >> + { >> + ptr++; >> + ctx.depth = grub_strtoul (ptr, &ptr, 0); >> + if (grub_errno) >> + return grub_errno; >> + } >> } >> - >> - >> >> #ifdef GRUB_MACHINE_PCBIOS >> if (grub_strcmp (cmd->name, "vbeinfo") == 0) @@ -177,23 +164,20 @@ >> grub_cmd_videoinfo (grub_command_t cmd _ #endif >> >> id = grub_video_get_driver_id (); >> - if (!ctx.set_variable) >> - { >> -grub_puts_ (N_("List of supported video modes:")); -grub_puts_ >> (N_("Legend: mask/position=red/green/blue/reserved")); >> - } >> - >> + >> + grub_puts_ (N_("List of supported video modes:")); grub_puts_ >> + (N_("Legend: mask/position=red/green/blue/reserved")); >> + >> FOR_VIDEO_ADAPTERS (adapter) >> { >> struct grub_video_mode_info info; >> struct grub_video_edid_info edid_info; >> - if (!ctx.set_variable) >> - grub_printf_ (N_("Adapter `%s':\n"), adapter->name); >> + >> + grub_printf_ (N_("Adapter `%s':\n"), adapter->name); >> >> if (!adapter->iterate) >> { >> - if (!ctx.set_variable) >> - grub_puts_ (N_(" No info available")); >> + grub_puts_ (N_(" No info available")); >> continue; >> } >> >> @@ -202,18 +186,7 @@ grub_puts_ (N_("Legend: mask/position=re >> if (adapter->id == id) >> { >> if (grub_video_get_info (&info) == GRUB_ERR_NONE) >> - { >> - ctx.current_mode = &info; >> - if (ctx.set_variable) >> - { >> - /* set grub env var to current mode */ >> - char screen_wxh[20]; >> - unsigned int width = info.width; >> - unsigned int height = info.height; >> - grub_snprintf (screen_wxh, 20, "%ux%u", width, height); >> - grub_env_set (args[1], screen_wxh); >> - } >> - } >> + ctx.current_mode = &info; >> else >> /* Don't worry about errors. */ >> grub_errno = GRUB_ERR_NONE; >> @@ -263,26 +236,19 @@ GRUB_MOD_INIT(videoinfo) >> /* TRANSLATORS: "x" has to be entered in, >> like an identifier, so please don't >> use better Unicode codepoints. */ >> - N_("[--set var | [WxH]xD]"), >> - N_("Retrieve available video modes. " >> - "--set is given, assign the currently" >> - "active resolution to var. If --set " >> - "is not provided the available video " >> - "modes are listed. If resolution is " >> - "given, show only matching modes.")); >> - >> + N_("[WxH[xD]]"), >> + N_("List available video modes. If " >> + "resolution is given show only modes" >> + " matching it.")); >> #ifdef GRUB_MACHINE_PCBIOS >> cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, >> /* TRANSLATORS: "x" has to be entered in, >> like an identifier, so please don't >> use better Unicode codepoints. */ >> - N_("[--set var | [WxH]xD]"), >> - N_("Retrieve available video modes. " >> - "--set is given, assign the currently" >> - "active resolution to var. If --set " >> - "is not provided the available video " >> - "modes are listed. If resolution is " >> - "given, show only matching modes.")); >> + N_("[WxH[xD]]"), >> + N_("List available video modes. If " >> + "resolution is given show only modes" >> + " matching it.")); >> #endif >> } >