* Patch from PulkoMandy: Add resolution listing to "screenmode"
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29449 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
static struct option const kLongOptions[] = {
|
static struct option const kLongOptions[] = {
|
||||||
{"fall-back", no_argument, 0, 'f'},
|
{"fall-back", no_argument, 0, 'f'},
|
||||||
{"short", no_argument, 0, 's'},
|
{"short", no_argument, 0, 's'},
|
||||||
|
{"list", no_argument, 0, 'l'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
@@ -57,7 +58,8 @@ usage(int status)
|
|||||||
" --fall-back\tchanges to the standard fallback mode, and displays a\n"
|
" --fall-back\tchanges to the standard fallback mode, and displays a\n"
|
||||||
"\t\t\tnotification requester.\n"
|
"\t\t\tnotification requester.\n"
|
||||||
" -s --short\t\twhen no mode is given the current screen mode is\n"
|
" -s --short\t\twhen no mode is given the current screen mode is\n"
|
||||||
"\t\t\tprinted in short form.\n",
|
"\t\t\tprinted in short form.\n"
|
||||||
|
" -l --list\t\tdisplay a list of the available modes\n",
|
||||||
kProgramName);
|
kProgramName);
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
@@ -70,6 +72,7 @@ main(int argc, char** argv)
|
|||||||
bool fallbackMode = false;
|
bool fallbackMode = false;
|
||||||
bool setMode = false;
|
bool setMode = false;
|
||||||
bool shortOutput = false;
|
bool shortOutput = false;
|
||||||
|
bool listModes = false;
|
||||||
int width = -1;
|
int width = -1;
|
||||||
int height = -1;
|
int height = -1;
|
||||||
int depth = -1;
|
int depth = -1;
|
||||||
@@ -79,7 +82,7 @@ main(int argc, char** argv)
|
|||||||
// the display resolution!
|
// the display resolution!
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "sh", kLongOptions, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "shlf", kLongOptions, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@@ -90,6 +93,9 @@ main(int argc, char** argv)
|
|||||||
case 's':
|
case 's':
|
||||||
shortOutput = true;
|
shortOutput = true;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
listModes = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(0);
|
usage(0);
|
||||||
break;
|
break;
|
||||||
@@ -129,7 +135,7 @@ main(int argc, char** argv)
|
|||||||
screen_mode currentMode;
|
screen_mode currentMode;
|
||||||
screenMode.Get(currentMode);
|
screenMode.Get(currentMode);
|
||||||
|
|
||||||
if (!setMode) {
|
if ((!setMode) && (!listModes)) {
|
||||||
const char* format = shortOutput
|
const char* format = shortOutput
|
||||||
? "%ld %ld %ld %g\n" : "Resolution: %ld %ld, %ld bits, %g Hz\n";
|
? "%ld %ld %ld %g\n" : "Resolution: %ld %ld, %ld bits, %g Hz\n";
|
||||||
printf(format, currentMode.width, currentMode.height,
|
printf(format, currentMode.width, currentMode.height,
|
||||||
@@ -139,7 +145,19 @@ main(int argc, char** argv)
|
|||||||
|
|
||||||
screen_mode newMode = currentMode;
|
screen_mode newMode = currentMode;
|
||||||
|
|
||||||
if (fallbackMode) {
|
if (listModes) {
|
||||||
|
const int modeCount = screenMode.CountModes();
|
||||||
|
printf("Available screen modes :\n");
|
||||||
|
|
||||||
|
for (int modeNumber = 0; modeNumber < modeCount; modeNumber++) {
|
||||||
|
currentMode = screenMode.ModeAt(modeNumber);
|
||||||
|
const char* format = shortOutput
|
||||||
|
? "%ld %ld %ld %g\n" : "%ld %ld, %ld bits, %g Hz\n";
|
||||||
|
printf(format, currentMode.width, currentMode.height,
|
||||||
|
currentMode.BitsPerPixel(), currentMode.refresh);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if (fallbackMode) {
|
||||||
if (currentMode.width == 800 && currentMode.height == 600) {
|
if (currentMode.width == 800 && currentMode.height == 600) {
|
||||||
newMode.width = 640;
|
newMode.width = 640;
|
||||||
newMode.height = 480;
|
newMode.height = 480;
|
||||||
|
|||||||
Reference in New Issue
Block a user