Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osdd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
osdd
Commits
7f62214e
Commit
7f62214e
authored
4 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Add support for multiple outputs (v2)
parent
1e8f3e84
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
display.c
+32
-4
32 additions, 4 deletions
display.c
display.h
+9
-1
9 additions, 1 deletion
display.h
osdd.c
+22
-20
22 additions, 20 deletions
osdd.c
with
63 additions
and
25 deletions
display.c
+
32
−
4
View file @
7f62214e
...
...
@@ -26,6 +26,7 @@
struct
osd_state
{
// Basic characteristics of current display and screen
Display
*
dpy
;
int
screen
;
Visual
*
visual
;
...
...
@@ -34,6 +35,8 @@ struct osd_state {
int
depth
;
int
screen_width
;
int
screen_height
;
int
screen_x
;
int
screen_y
;
// Our window
Window
win
;
...
...
@@ -115,7 +118,30 @@ stay_on_top(struct osd_state *osd)
DBG
(
"stay_on_top: WM does not support any known protocol
\n
"
);
}
struct
osd_state
*
osd_new
(
Display
*
dpy
)
struct
osd_set
osd_set_new
(
Display
*
dpy
)
{
struct
osd_set
set
;
set
.
len
=
0
;
FILE
*
f
=
popen
(
"xrandr | grep
\\
connected"
,
"r"
);
char
line
[
1000
];
while
(
fscanf
(
f
,
" %1000[^
\n
]"
,
line
)
==
1
)
{
int
width
,
height
,
x
,
y
;
char
*
l
=
line
;
while
(
*
l
&&
!
(
*
l
==
' '
))
l
++
;
while
(
*
l
&&
!
(
'0'
<=*
l
&&*
l
<=
'9'
))
l
++
;
if
(
sscanf
(
l
,
"%dx%d+%d+%d"
,
&
width
,
&
height
,
&
x
,
&
y
)
==
4
)
if
(
set
.
len
<
OSD_MAX_SET_LEN
)
{
DBG
(
"ADD screen %dx%d on %d,%d
\n
"
,
width
,
height
,
x
,
y
);
set
.
state
[
set
.
len
++
]
=
osd_state_new
(
dpy
,
width
,
height
,
x
,
y
);
}
}
return
set
;
}
struct
osd_state
*
osd_state_new
(
Display
*
dpy
,
int
width
,
int
height
,
int
x
,
int
y
)
{
struct
osd_state
*
osd
=
xmalloc
(
sizeof
(
*
osd
));
memset
(
osd
,
0
,
sizeof
(
*
osd
));
...
...
@@ -128,8 +154,10 @@ struct osd_state *osd_new(Display *dpy)
// FIXME: These can change. And what about Xinerama?
osd
->
depth
=
XDefaultDepth
(
osd
->
dpy
,
osd
->
screen
);
osd
->
screen_width
=
XDisplayWidth
(
osd
->
dpy
,
osd
->
screen
);
osd
->
screen_height
=
XDisplayHeight
(
osd
->
dpy
,
osd
->
screen
);
osd
->
screen_width
=
width
;
osd
->
screen_height
=
height
;
osd
->
screen_x
=
x
;
osd
->
screen_y
=
y
;
DBG
(
"Screen: %dx%d depth %d
\n
"
,
osd
->
screen_width
,
osd
->
screen_height
,
osd
->
depth
);
int
event_basep
,
error_basep
;
...
...
@@ -469,7 +497,7 @@ void osd_show(struct osd_state *osd)
};
osd
->
win
=
XCreateWindow
(
osd
->
dpy
,
osd
->
root
,
(
osd
->
screen_width
-
osd
->
win_width
)
/
2
,
(
osd
->
screen_height
-
osd
->
win_height
)
/
2
,
(
osd
->
screen_width
-
osd
->
win_width
)
/
2
+
osd
->
screen_x
,
(
osd
->
screen_height
-
osd
->
win_height
)
/
2
+
osd
->
screen_y
,
osd
->
win_width
,
osd
->
win_height
,
0
,
osd
->
depth
,
...
...
This diff is collapsed.
Click to expand it.
display.h
+
9
−
1
View file @
7f62214e
...
...
@@ -38,7 +38,15 @@ struct osd_line {
int
log
;
};
struct
osd_state
*
osd_new
(
Display
*
dpy
);
#define ALL_OSD_SET(set) for(int ALL_OSD_SET_i=0;ALL_OSD_SET_i<set.len;ALL_OSD_SET_i++) set->state[ALL_OSD_SET_i]
#define OSD_MAX_SET_LEN 10
struct
osd_set
{
struct
osd_state
*
state
[
OSD_MAX_SET_LEN
];
int
len
;
};
struct
osd_state
*
osd_state_new
(
Display
*
dpy
,
int
width
,
int
height
,
int
x
,
int
y
);
struct
osd_set
osd_set_new
(
Display
*
dpy
);
void
osd_free
(
struct
osd_state
*
osd
);
void
osd_set_font
(
struct
osd_state
*
osd
,
char
*
font_name
,
double
line_spacing
);
struct
osd_line
*
osd_add_line
(
struct
osd_state
*
osd
,
enum
osd_line_type
type
);
...
...
This diff is collapsed.
Click to expand it.
osdd.c
+
22
−
20
View file @
7f62214e
...
...
@@ -18,7 +18,8 @@
#include
"util.h"
#include
"display.h"
static
struct
osd_state
*
osd
;
static
struct
osd_set
osd
;
#define FOREACHOSD for(int i=0;i<osd.len;i++)
static
timestamp_t
now
;
...
...
@@ -160,21 +161,22 @@ display_msg(struct msg *msg)
}
DBG
(
"
\t
%s:%s
\n
"
,
key
,
val
);
struct
osd_line
*
l
=
NULL
;
struct
osd_line
*
l
[
OSD_MAX_SET_LEN
];
FOREACHOSD
l
[
i
]
=
0
;
if
(
!
key
[
0
])
{
l
=
osd_add_line
(
osd
,
OSD_TYPE_TEXT
);
sprintf
(
l
->
u
.
text
,
"%.*s"
,
OSD_MAX_LINE_LEN
,
val
);
FOREACHOSD
l
[
i
]
=
osd_add_line
(
osd
.
state
[
i
]
,
OSD_TYPE_TEXT
);
FOREACHOSD
sprintf
(
l
[
i
]
->
u
.
text
,
"%.*s"
,
OSD_MAX_LINE_LEN
,
val
);
}
else
if
(
!
strcmp
(
key
,
"percentage"
)
||
!
strcmp
(
key
,
"percent"
))
{
l
=
osd_add_line
(
osd
,
OSD_TYPE_PERCENTAGE
);
l
->
u
.
percent
=
atoi
(
val
);
FOREACHOSD
l
[
i
]
=
osd_add_line
(
osd
.
state
[
i
]
,
OSD_TYPE_PERCENTAGE
);
FOREACHOSD
l
[
i
]
->
u
.
percent
=
atoi
(
val
);
}
else
if
(
!
strcmp
(
key
,
"slider"
))
{
l
=
osd_add_line
(
osd
,
OSD_TYPE_SLIDER
);
l
->
u
.
percent
=
atoi
(
val
);
FOREACHOSD
l
[
i
]
=
osd_add_line
(
osd
.
state
[
i
]
,
OSD_TYPE_SLIDER
);
FOREACHOSD
l
[
i
]
->
u
.
percent
=
atoi
(
val
);
}
else
if
(
!
strcmp
(
key
,
"duration"
))
msg
->
max_light
=
now
+
atoi
(
val
);
...
...
@@ -188,21 +190,21 @@ display_msg(struct msg *msg)
outline_color
=
val
;
else
if
(
!
strcmp
(
key
,
"outline-width"
))
outline_width
=
atoi
(
val
);
if
(
l
)
FOREACHOSD
if
(
l
[
i
]
)
{
num_l
++
;
l
->
fg_color
=
fg_color
;
l
->
outline_color
=
outline_color
;
l
->
outline_width
=
outline_width
;
l
->
log
=
log
;
l
[
i
]
->
fg_color
=
fg_color
;
l
[
i
]
->
outline_color
=
outline_color
;
l
[
i
]
->
outline_width
=
outline_width
;
l
[
i
]
->
log
=
i
?
0
:
log
;
}
line
=
nl
;
}
if
(
!
num_l
)
if
(
!
num_l
)
FOREACHOSD
{
struct
osd_line
*
l
=
osd_add_line
(
osd
,
OSD_TYPE_TEXT
);
struct
osd_line
*
l
=
osd_add_line
(
osd
.
state
[
i
]
,
OSD_TYPE_TEXT
);
l
->
u
.
text
[
0
]
=
0
;
l
->
fg_color
=
fg_color
;
l
->
outline_color
=
outline_color
;
...
...
@@ -213,7 +215,7 @@ display_msg(struct msg *msg)
if
(
msg
->
min_light
>
msg
->
max_light
)
msg
->
min_light
=
msg
->
max_light
;
osd_show
(
osd
);
FOREACHOSD
osd_show
(
osd
.
state
[
i
]
);
}
static
void
...
...
@@ -258,7 +260,7 @@ static void
hide_msg
(
struct
msg
*
msg
)
{
DBG
(
"## Hiding message
\n
"
);
osd_clear
(
osd
);
FOREACHOSD
osd_clear
(
osd
.
state
[
i
]
);
free
(
msg
);
}
...
...
@@ -397,8 +399,8 @@ main(int argc, char **argv)
XFlush
(
dpy
);
}
osd
=
osd_new
(
dpy
);
osd_set_font
(
osd
,
font_name
,
line_spacing
);
osd
=
osd_
set_
new
(
dpy
);
FOREACHOSD
osd_set_font
(
osd
.
state
[
i
]
,
font_name
,
line_spacing
);
struct
pollfd
pfd
=
{
.
fd
=
ConnectionNumber
(
dpy
),
...
...
@@ -440,7 +442,7 @@ main(int argc, char **argv)
{
XEvent
ev
;
XNextEvent
(
dpy
,
&
ev
);
if
(
osd_handle_event
(
osd
,
&
ev
))
FOREACHOSD
if
(
osd_handle_event
(
osd
.
state
[
i
]
,
&
ev
))
continue
;
if
(
ev
.
type
!=
PropertyNotify
)
continue
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment