mirror of
				https://gitlab.com/sortix/sortix.git
				synced 2023-02-13 20:55:38 -05:00 
			
		
		
		
	Detect whether the terminal has a display and a keyboard layout.
A new ioctl TIOCGDISPLAYS allow detecting which displays the terminal has associated. The ability to set a keyboard layout can be detected with tcgetblob kblayout. Improve the user-space multi-monitor support while here. The kernel now sets TERM rather than init(8). This is a compatible ABI change riding on the previous commit's bump.
This commit is contained in:
		
							parent
							
								
									db7182ddc3
								
							
						
					
					
						commit
						6ef5a5cee3
					
				
					 12 changed files with 179 additions and 46 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2012 Jonas 'Sortie' Termansen.
 | 
			
		||||
 * Copyright (c) 2012, 2016 Jonas 'Sortie' Termansen.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
 * purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ struct dispd_framebuffer
 | 
			
		|||
	int bpp;
 | 
			
		||||
	int width;
 | 
			
		||||
	int height;
 | 
			
		||||
	uint64_t fb_location;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2012 Jonas 'Sortie' Termansen.
 | 
			
		||||
 * Copyright (c) 2012, 2013, 2014, 2016 Jonas 'Sortie' Termansen.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
 * purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
| 
						 | 
				
			
			@ -17,9 +17,10 @@
 | 
			
		|||
 * Handles session management.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/ioctl.h>
 | 
			
		||||
#include <sys/display.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#include <error.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -34,9 +35,6 @@
 | 
			
		|||
 | 
			
		||||
#include "session.h"
 | 
			
		||||
 | 
			
		||||
static const uint64_t ONE_AND_ONLY_DEVICE = 0;
 | 
			
		||||
static const uint64_t ONE_AND_ONLY_CONNECTOR = 0;
 | 
			
		||||
 | 
			
		||||
struct dispd_session* global_session = NULL;
 | 
			
		||||
 | 
			
		||||
bool dispd__session_initialize(int* argc, char*** argv)
 | 
			
		||||
| 
						 | 
				
			
			@ -48,8 +46,21 @@ bool dispd__session_initialize(int* argc, char*** argv)
 | 
			
		|||
	if ( !global_session )
 | 
			
		||||
		return false;
 | 
			
		||||
	memset(global_session, 0, sizeof(*global_session));
 | 
			
		||||
	global_session->device = ONE_AND_ONLY_DEVICE;
 | 
			
		||||
	global_session->connector = ONE_AND_ONLY_CONNECTOR;
 | 
			
		||||
	int tty_fd = open("/dev/tty", O_RDWR);
 | 
			
		||||
	if ( tty_fd < 0 )
 | 
			
		||||
		return free(global_session), false;
 | 
			
		||||
	struct tiocgdisplay display;
 | 
			
		||||
	struct tiocgdisplays gdisplays;
 | 
			
		||||
	memset(&gdisplays, 0, sizeof(gdisplays));
 | 
			
		||||
	gdisplays.count = 1;
 | 
			
		||||
	gdisplays.displays = &display;
 | 
			
		||||
	bool fail = ioctl(tty_fd, TIOCGDISPLAYS, &gdisplays) < 0 ||
 | 
			
		||||
	            gdisplays.count == 0;
 | 
			
		||||
	close(tty_fd);
 | 
			
		||||
	if ( fail )
 | 
			
		||||
		return free(global_session), false;
 | 
			
		||||
	global_session->device = display.device;
 | 
			
		||||
	global_session->connector = display.connector;
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2012 Jonas 'Sortie' Termansen.
 | 
			
		||||
 * Copyright (c) 2012, 2013, 2014, 2016 Jonas 'Sortie' Termansen.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
 * purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
| 
						 | 
				
			
			@ -17,8 +17,8 @@
 | 
			
		|||
 * Handles windows.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/display.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <ioleast.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -102,6 +102,7 @@ struct dispd_framebuffer* dispd_begin_render(struct dispd_window* window)
 | 
			
		|||
	fb->pitch = fb->width * fb->bpp / 8;
 | 
			
		||||
	fb->datasize = fb->pitch * fb->height;
 | 
			
		||||
	fb->data = (uint8_t*) request_buffer(window, fb->datasize);
 | 
			
		||||
	fb->fb_location = msg.mode.fb_location;
 | 
			
		||||
	if ( !fb->data ) { free(fb); return NULL; }
 | 
			
		||||
	return fb;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +114,7 @@ bool dispd_finish_render(struct dispd_framebuffer* fb)
 | 
			
		|||
	struct dispmsg_write_memory msg;
 | 
			
		||||
	msg.msgid = DISPMSG_WRITE_MEMORY;
 | 
			
		||||
	msg.device = window->session->device;
 | 
			
		||||
	msg.offset = 0;
 | 
			
		||||
	msg.offset = fb->fb_location;
 | 
			
		||||
	msg.size = fb->datasize;
 | 
			
		||||
	msg.src = fb->data;
 | 
			
		||||
	if ( dispmsg_issue(&msg, sizeof(msg)) == 0 )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue