fixup! Add display server.
This commit is contained in:
parent
b2585414a0
commit
63260a916e
|
@ -17,11 +17,14 @@
|
||||||
* Interactive utility functions.
|
* Interactive utility functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/display.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/termmode.h>
|
#include <sys/termmode.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -262,6 +265,36 @@ bool missing_program(const char* program)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_video_mode(struct dispmsg_crtc_mode* mode)
|
||||||
|
{
|
||||||
|
struct tiocgdisplay display;
|
||||||
|
struct tiocgdisplays gdisplays;
|
||||||
|
memset(&gdisplays, 0, sizeof(gdisplays));
|
||||||
|
gdisplays.count = 1;
|
||||||
|
gdisplays.displays = &display;
|
||||||
|
struct dispmsg_get_driver_name dgdn = { 0 };
|
||||||
|
if ( ioctl(1, TIOCGDISPLAYS, &gdisplays) < 0 || gdisplays.count == 0 )
|
||||||
|
return false;
|
||||||
|
dgdn.device = display.device;
|
||||||
|
dgdn.msgid = DISPMSG_GET_DRIVER_NAME;
|
||||||
|
dgdn.device = display.device;
|
||||||
|
dgdn.driver_index = 0;
|
||||||
|
dgdn.name.byte_size = 0;
|
||||||
|
dgdn.name.str = NULL;
|
||||||
|
if ( dispmsg_issue(&dgdn, sizeof(dgdn)) < 0 && errno == ENODEV )
|
||||||
|
return false;
|
||||||
|
struct dispmsg_get_crtc_mode get_mode;
|
||||||
|
memset(&get_mode, 0, sizeof(get_mode));
|
||||||
|
get_mode.msgid = DISPMSG_GET_CRTC_MODE;
|
||||||
|
get_mode.device = display.device;
|
||||||
|
get_mode.connector = display.connector;
|
||||||
|
// TODO: Still allow setting the video mode if none was already set.
|
||||||
|
if ( dispmsg_issue(&get_mode, sizeof(get_mode)) < 0 )
|
||||||
|
return false;
|
||||||
|
*mode = get_mode.mode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void gui_shutdown(int code)
|
void gui_shutdown(int code)
|
||||||
{
|
{
|
||||||
if ( getenv("DISPLAY_SOCKET") )
|
if ( getenv("DISPLAY_SOCKET") )
|
||||||
|
|
|
@ -42,6 +42,7 @@ void password(char* buffer,
|
||||||
size_t buffer_size,
|
size_t buffer_size,
|
||||||
const char* question);
|
const char* question);
|
||||||
bool missing_program(const char* program);
|
bool missing_program(const char* program);
|
||||||
|
bool get_video_mode(struct dispmsg_crtc_mode* mode);
|
||||||
void gui_shutdown(int code);
|
void gui_shutdown(int code);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -623,38 +623,16 @@ int main(void)
|
||||||
text("\n");
|
text("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tiocgdisplay display;
|
struct dispmsg_crtc_mode mode;
|
||||||
struct tiocgdisplays gdisplays;
|
if ( get_video_mode(&mode) )
|
||||||
memset(&gdisplays, 0, sizeof(gdisplays));
|
|
||||||
gdisplays.count = 1;
|
|
||||||
gdisplays.displays = &display;
|
|
||||||
struct dispmsg_get_driver_name dgdn = { 0 };
|
|
||||||
dgdn.msgid = DISPMSG_GET_DRIVER_NAME;
|
|
||||||
dgdn.device = 0;
|
|
||||||
dgdn.driver_index = 0;
|
|
||||||
dgdn.name.byte_size = 0;
|
|
||||||
dgdn.name.str = NULL;
|
|
||||||
if ( ioctl(1, TIOCGDISPLAYS, &gdisplays) == 0 &&
|
|
||||||
0 < gdisplays.count &&
|
|
||||||
(dgdn.device = display.device, true) &&
|
|
||||||
(dispmsg_issue(&dgdn, sizeof(dgdn)) == 0 || errno != ENODEV) )
|
|
||||||
{
|
{
|
||||||
struct dispmsg_get_crtc_mode get_mode;
|
bool good = (mode.control & DISPMSG_CONTROL_VALID) &&
|
||||||
memset(&get_mode, 0, sizeof(get_mode));
|
(mode.control & DISPMSG_CONTROL_GOOD_DEFAULT);
|
||||||
get_mode.msgid = DISPMSG_GET_CRTC_MODE;
|
if ( mode.control & DISPMSG_CONTROL_VM_AUTO_SCALE )
|
||||||
get_mode.device = 0;
|
|
||||||
get_mode.connector = 0;
|
|
||||||
bool good = false;
|
|
||||||
if ( dispmsg_issue(&get_mode, sizeof(get_mode)) == 0 )
|
|
||||||
{
|
{
|
||||||
good = (get_mode.mode.control & DISPMSG_CONTROL_VALID) &&
|
text("The display resolution will automatically change to "
|
||||||
(get_mode.mode.control & DISPMSG_CONTROL_GOOD_DEFAULT);
|
"match the size of the virtual machine window.\n\n");
|
||||||
if ( get_mode.mode.control & DISPMSG_CONTROL_VM_AUTO_SCALE )
|
good = true;
|
||||||
{
|
|
||||||
text("The display resolution will automatically change to "
|
|
||||||
"match the size of the virtual machine window.\n\n");
|
|
||||||
good = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const char* def = non_interactive || good ? "no" : "yes";
|
const char* def = non_interactive || good ? "no" : "yes";
|
||||||
while ( true )
|
while ( true )
|
||||||
|
@ -673,14 +651,12 @@ int main(void)
|
||||||
if ( execute((const char*[]) { "chvideomode", r, NULL }, "f") != 0 )
|
if ( execute((const char*[]) { "chvideomode", r, NULL }, "f") != 0 )
|
||||||
continue;
|
continue;
|
||||||
input[0] = '\0';
|
input[0] = '\0';
|
||||||
if ( dispmsg_issue(&get_mode, sizeof(get_mode)) < 0 ||
|
if ( !get_video_mode(&mode) ||
|
||||||
!(get_mode.mode.control & DISPMSG_CONTROL_VALID) ||
|
!(mode.control & DISPMSG_CONTROL_VALID) ||
|
||||||
get_mode.mode.control & DISPMSG_CONTROL_VGA )
|
mode.control & DISPMSG_CONTROL_VGA )
|
||||||
break;
|
continue;
|
||||||
snprintf(input, sizeof(input), "%ux%ux%u",
|
snprintf(input, sizeof(input), "%ux%ux%u",
|
||||||
get_mode.mode.view_xres,
|
mode.view_xres, mode.view_yres, mode.fb_format);
|
||||||
get_mode.mode.view_yres,
|
|
||||||
get_mode.mode.fb_format);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -509,38 +509,16 @@ int main(void)
|
||||||
if ( kblayout_setable )
|
if ( kblayout_setable )
|
||||||
text("\n");
|
text("\n");
|
||||||
|
|
||||||
struct tiocgdisplay display;
|
struct dispmsg_crtc_mode mode;
|
||||||
struct tiocgdisplays gdisplays;
|
if ( get_video_mode(&mode) )
|
||||||
memset(&gdisplays, 0, sizeof(gdisplays));
|
|
||||||
gdisplays.count = 1;
|
|
||||||
gdisplays.displays = &display;
|
|
||||||
struct dispmsg_get_driver_name dgdn = { 0 };
|
|
||||||
dgdn.msgid = DISPMSG_GET_DRIVER_NAME;
|
|
||||||
dgdn.device = 0;
|
|
||||||
dgdn.driver_index = 0;
|
|
||||||
dgdn.name.byte_size = 0;
|
|
||||||
dgdn.name.str = NULL;
|
|
||||||
if ( ioctl(1, TIOCGDISPLAYS, &gdisplays) == 0 &&
|
|
||||||
0 < gdisplays.count &&
|
|
||||||
(dgdn.device = display.device, true) &&
|
|
||||||
(dispmsg_issue(&dgdn, sizeof(dgdn)) == 0 || errno != ENODEV) )
|
|
||||||
{
|
{
|
||||||
struct dispmsg_get_crtc_mode get_mode;
|
bool good = (mode.control & DISPMSG_CONTROL_VALID) &&
|
||||||
memset(&get_mode, 0, sizeof(get_mode));
|
(mode.control & DISPMSG_CONTROL_GOOD_DEFAULT);
|
||||||
get_mode.msgid = DISPMSG_GET_CRTC_MODE;
|
if ( mode.control & DISPMSG_CONTROL_VM_AUTO_SCALE )
|
||||||
get_mode.device = 0;
|
|
||||||
get_mode.connector = 0;
|
|
||||||
bool good = false;
|
|
||||||
if ( dispmsg_issue(&get_mode, sizeof(get_mode)) == 0 )
|
|
||||||
{
|
{
|
||||||
good = (get_mode.mode.control & DISPMSG_CONTROL_VALID) &&
|
text("The display resolution will automatically change to "
|
||||||
(get_mode.mode.control & DISPMSG_CONTROL_GOOD_DEFAULT);
|
"match the size of the virtual machine window.\n\n");
|
||||||
if ( get_mode.mode.control & DISPMSG_CONTROL_VM_AUTO_SCALE )
|
good = true;
|
||||||
{
|
|
||||||
text("The display resolution will automatically change to "
|
|
||||||
"match the size of the virtual machine window.\n\n");
|
|
||||||
good = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const char* def = non_interactive || good ? "no" : "yes";
|
const char* def = non_interactive || good ? "no" : "yes";
|
||||||
while ( true )
|
while ( true )
|
||||||
|
|
Loading…
Reference in New Issue