Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700330 > unrolled thread

[PATCH v2 0/2] Invert margin colors when terminal is inverted

Started byDavid Lechner <david@lechnology.com>
First post2017-07-31 21:20 +0200
Last post2017-07-31 22:50 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/2] Invert margin colors when terminal is inverted David Lechner <david@lechnology.com> - 2017-07-31 21:20 +0200
    [PATCH v2 1/2] fbcon: Invert margin colors when terminal is inverted David Lechner <david@lechnology.com> - 2017-07-31 21:20 +0200
    [PATCH v2 2/2] fbcon: add VT notifier for VT_UPDATE event David Lechner <david@lechnology.com> - 2017-07-31 21:20 +0200
    Re: [PATCH v2 0/2] Invert margin colors when terminal is inverted Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-07-31 21:40 +0200
      Re: [PATCH v2 0/2] Invert margin colors when terminal is inverted David Lechner <david@lechnology.com> - 2017-07-31 22:50 +0200

#1700330 — [PATCH v2 0/2] Invert margin colors when terminal is inverted

FromDavid Lechner <david@lechnology.com>
Date2017-07-31 21:20 +0200
Subject[PATCH v2 0/2] Invert margin colors when terminal is inverted
Message-ID<u9oop-1IS-5@gated-at.bofh.it>
This is v2 of "fbcon: Use background color for margins​"[1].

It turns out that using the text background color was not a good choice. So,
I've started over.

In this series, the margin color depends on the terminal's inversion state. If
it is not inverted, then the margins are black as they currently are. But now,
if the terminal is inverted, the margin color is also inverted, so it is white.

In order to detect when the terminal is inverted, I had to add a notifier
callback for the VT_UPDATE event. Otherwise, running `setterm -inverse on`
would not change the margins until I also ran `clear`.

[1]: https://patchwork.kernel.org/patch/9869421/

David Lechner (2):
  fbcon: Invert margin colors when terminal is inverted
  fbcon: add VT notifier for VT_UPDATE event

 drivers/video/console/bitblit.c   |  2 +-
 drivers/video/console/fbcon.c     | 28 ++++++++++++++++++++++++++++
 drivers/video/console/fbcon_ccw.c |  2 +-
 drivers/video/console/fbcon_cw.c  |  2 +-
 drivers/video/console/fbcon_ud.c  |  2 +-
 5 files changed, 32 insertions(+), 4 deletions(-)

-- 
2.7.4

[toc] | [next] | [standalone]


#1700331 — [PATCH v2 1/2] fbcon: Invert margin colors when terminal is inverted

FromDavid Lechner <david@lechnology.com>
Date2017-07-31 21:20 +0200
Subject[PATCH v2 1/2] fbcon: Invert margin colors when terminal is inverted
Message-ID<u9oop-1IS-7@gated-at.bofh.it>
In reply to#1700330
This uses white (7) for the margin color when a fbcon terminal is inverted,
e.g. with `setterm -inverse on`.

The motivation for this is screens where the black does not blend into the
screen. For example, using an LCD (not the backlit kind), white text on a
black background is hard to read, so inverting the colors is preferred.
However, if the margins are not also inverted, it leaves ugly black bars
on the right and bottom of the text area.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/video/console/bitblit.c   | 2 +-
 drivers/video/console/fbcon_ccw.c | 2 +-
 drivers/video/console/fbcon_cw.c  | 2 +-
 drivers/video/console/fbcon_ud.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
index dbfe4ee..13cad9e 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/console/bitblit.c
@@ -213,7 +213,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info,
 	unsigned int bs = info->var.yres - bh;
 	struct fb_fillrect region;
 
-	region.color = 0;
+	region.color = vc->vc_decscnm ? 7 : 0;
 	region.rop = ROP_COPY;
 
 	if (rw && !bottom_only) {
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c
index 5a3cbf6..371f0155 100644
--- a/drivers/video/console/fbcon_ccw.c
+++ b/drivers/video/console/fbcon_ccw.c
@@ -198,7 +198,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info,
 	unsigned int bs = vc->vc_rows*ch;
 	struct fb_fillrect region;
 
-	region.color = 0;
+	region.color = vc->vc_decscnm ? 7 : 0;
 	region.rop = ROP_COPY;
 
 	if (rw && !bottom_only) {
diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c
index e7ee44d..541e66c 100644
--- a/drivers/video/console/fbcon_cw.c
+++ b/drivers/video/console/fbcon_cw.c
@@ -181,7 +181,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info,
 	unsigned int rs = info->var.yres - rw;
 	struct fb_fillrect region;
 
-	region.color = 0;
+	region.color = vc->vc_decscnm ? 7 : 0;
 	region.rop = ROP_COPY;
 
 	if (rw && !bottom_only) {
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c
index 19e3714..61fe137 100644
--- a/drivers/video/console/fbcon_ud.c
+++ b/drivers/video/console/fbcon_ud.c
@@ -228,7 +228,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info,
 	unsigned int bh = info->var.yres - (vc->vc_rows*ch);
 	struct fb_fillrect region;
 
-	region.color = 0;
+	region.color = vc->vc_decscnm ? 7 : 0;
 	region.rop = ROP_COPY;
 
 	if (rw && !bottom_only) {
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1700332 — [PATCH v2 2/2] fbcon: add VT notifier for VT_UPDATE event

FromDavid Lechner <david@lechnology.com>
Date2017-07-31 21:20 +0200
Subject[PATCH v2 2/2] fbcon: add VT notifier for VT_UPDATE event
Message-ID<u9oop-1IS-9@gated-at.bofh.it>
In reply to#1700330
This adds notifier callback for VT events. We are currently interested
in the VT_UPDATE event, which indicates there was some major change to
the VT. This is used to redraw the margins. For example when the console
is inverted we receive the VT_UPDATE event. The color of the margins depend
on the inverted state, so it is necessary redraw the margins at this time.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/video/console/fbcon.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 12ded23..8e7ac2f 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -3329,6 +3329,28 @@ static int fbcon_event_notify(struct notifier_block *self,
 	return ret;
 }
 
+static int vt_notifier_call(struct notifier_block *blk,
+			    unsigned long code, void *_param)
+{
+	struct vt_notifier_param *param = _param;
+	struct vc_data *vc = param->vc;
+
+	switch (code) {
+	case VT_UPDATE:
+		/*
+		 * This event could indicate that the terminal has been
+		 * inverted (or there was some other major change), in which
+		 * case we need to re-draw the margins.
+		 */
+		if (con_is_visible(vc) && vc->vc_mode == KD_TEXT)
+			fbcon_clear_margins(vc, 0);
+		break;
+	default:
+		break;
+	}
+	return NOTIFY_OK;
+}
+
 /*
  *  The console `switch' structure for the frame buffer based console
  */
@@ -3364,6 +3386,10 @@ static struct notifier_block fbcon_event_notifier = {
 	.notifier_call	= fbcon_event_notify,
 };
 
+static struct notifier_block vt_notifier_block = {
+	.notifier_call = vt_notifier_call,
+};
+
 static ssize_t store_rotate(struct device *device,
 			    struct device_attribute *attr, const char *buf,
 			    size_t count)
@@ -3612,6 +3638,7 @@ static int __init fb_console_init(void)
 
 	console_lock();
 	fb_register_client(&fbcon_event_notifier);
+	register_vt_notifier(&vt_notifier_block);
 	fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
 				     "fbcon");
 
@@ -3650,6 +3677,7 @@ static void __exit fbcon_deinit_device(void)
 static void __exit fb_console_exit(void)
 {
 	console_lock();
+	unregister_vt_notifier(&vt_notifier_block);
 	fb_unregister_client(&fbcon_event_notifier);
 	fbcon_deinit_device();
 	device_destroy(fb_class, MKDEV(0, 0));
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1700354

FromAlan Cox <gnomes@lxorguk.ukuu.org.uk>
Date2017-07-31 21:40 +0200
Message-ID<u9oHM-1Rm-33@gated-at.bofh.it>
In reply to#1700330
On Mon, 31 Jul 2017 14:09:43 -0500
David Lechner <david@lechnology.com> wrote:

> This is v2 of "fbcon: Use background color for margins​"[1].
> 
> It turns out that using the text background color was not a good choice. So,
> I've started over.

Can you explain why making the margins simply match the border colour
(when possible) isn't a better option ? They are after all simply
software extensions to the border.

Alan

[toc] | [prev] | [next] | [standalone]


#1700383

FromDavid Lechner <david@lechnology.com>
Date2017-07-31 22:50 +0200
Message-ID<u9pNv-2t7-13@gated-at.bofh.it>
In reply to#1700354
On 07/31/2017 02:30 PM, Alan Cox wrote:
> On Mon, 31 Jul 2017 14:09:43 -0500
> David Lechner <david@lechnology.com> wrote:
> 
>> This is v2 of "fbcon: Use background color for margins​"[1].
>>
>> It turns out that using the text background color was not a good choice. So,
>> I've started over.
> 
> Can you explain why making the margins simply match the border colour
> (when possible) isn't a better option ? They are after all simply
> software extensions to the border.
> 

So, basically, you are proposing that it would be better to add a module 
parameter to select the margin color? That does sound like a better 
option to me.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web