Skip to content

Commit

Permalink
FvwmEvent: begin groundwork for RandR
Browse files Browse the repository at this point in the history
This starts the beginnigs of getting FvwmEvent listening on different
RandR events.
  • Loading branch information
ThomasAdam committed May 30, 2020
1 parent 1ba9538 commit 0ddfcbd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 18 deletions.
24 changes: 24 additions & 0 deletions fvwm/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,29 @@ void monitor_update_ewmh(void)
UPDATE_FVWM_SCREEN(t);
}
}

void
monitor_emit_broadcast(void)
{
struct monitor *m;

TAILQ_FOREACH (m, &monitor_q, entry) {
if (m->emit & MONITOR_CHANGED) {
BroadcastName(MX_MONITOR_CHANGED, -1, -1, -1, m->si->name);
fvwm_debug(__func__, "MONITOR '%s' CHANGED",
m->si->name);
m->emit &= ~MONITOR_ALL;
m->flags &= ~MONITOR_CHANGED;
}
if (m->emit & MONITOR_ENABLED)
BroadcastName(MX_MONITOR_ENABLED, -1, -1, -1, m->si->name);
fvwm_debug(__func__, "MONITOR '%s' ENABLED",
m->si->name);
if (m->emit & MONITOR_DISABLED)
fvwm_debug(__func__, "MONITOR '%s' DISABLED",
m->si->name);
}
}
#endif

void HandleButtonPress(const evh_args_t *ea)
Expand Down Expand Up @@ -4136,6 +4159,7 @@ void dispatch_event(XEvent *e)
monitor_output_change(sce->display, sce);
XRRUpdateConfiguration(e);
monitor_update_ewmh();
monitor_emit_broadcast();
break;
}
}
Expand Down
21 changes: 10 additions & 11 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,19 @@ monitor_output_change(Display *dpy, XRRScreenChangeNotifyEvent *e)
continue;

TAILQ_FOREACH(m, &monitor_q, entry) {
if (m->si == si)
if (m->si == si) {
m->emit &= ~MONITOR_ALL;
break;
}
}

if (m == NULL)
continue;

if (oinfo->connection == RR_Connected &&
m->flags & MONITOR_ENABLED) {
if (m->flags & MONITOR_CHANGED) {
fvwm_debug(__func__, "MONITOR: %s CHANGED\n",
m->si->name);
m->flags &= ~MONITOR_CHANGED;
}
if (m->flags & MONITOR_CHANGED)
m->emit |= MONITOR_CHANGED;
continue;
}

Expand All @@ -288,14 +287,13 @@ monitor_output_change(Display *dpy, XRRScreenChangeNotifyEvent *e)
case RR_Connected:
m->flags &= ~MONITOR_DISABLED;
m->flags |= MONITOR_ENABLED;
fvwm_debug(__func__, "MONITOR: %s CONNECTED\n",
m->si->name);

m->emit |= MONITOR_ENABLED;
break;
case RR_Disconnected:
m->flags &= ~MONITOR_ENABLED;
m->flags |= MONITOR_DISABLED;
fvwm_debug(__func__, "MONITOR: %s DISCONNECTED\n",
m->si->name);
m->emit |= MONITOR_DISABLED;
break;
default:
break;
Expand Down Expand Up @@ -346,7 +344,8 @@ scan_screens(Display *dpy)
if ((strcmp(m->si->name, name) == 0) &&
(m->si->x != rrm[i].x || m->si->y != rrm[i].y ||
m->si->w != rrm[i].width || m->si->h != rrm[i].height)) {
m->flags |= MONITOR_CHANGED;
if (m->flags & MONITOR_ENABLED)
m->flags |= MONITOR_CHANGED;
}

set_coords:
Expand Down
2 changes: 2 additions & 0 deletions libs/FScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ struct screen_info *screen_info_by_name(const char *);
#define MONITOR_ENABLED 0x4
#define MONITOR_PRIMARY 0x8
#define MONITOR_CHANGED 0x10
#define MONITOR_ALL (MONITOR_DISABLED|MONITOR_ENABLED|MONITOR_CHANGED)

struct monitor {
struct screen_info *si;
int flags;
int emit;
int dx, dy;

/* info for some desktops; the first entries should be generic info
Expand Down
7 changes: 4 additions & 3 deletions libs/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ typedef struct
#define MX_LEAVE_WINDOW ((1<<2) | M_EXTENDED_MSG)
#define MX_PROPERTY_CHANGE ((1<<3) | M_EXTENDED_MSG)
#define MX_REPLY ((1<<4) | M_EXTENDED_MSG)
#define MX_MONITOR_CHANGE ((1<<5) | M_EXTENDED_MSG)
#define MX_MONITOR_LIST ((1<<6) | M_EXTENDED_MSG)
#define MAX_EXTENDED_MESSAGES 7
#define MX_MONITOR_ENABLED ((1<<5) | M_EXTENDED_MSG)
#define MX_MONITOR_DISABLED ((1<<6) | M_EXTENDED_MSG)
#define MX_MONITOR_CHANGED ((1<<7) | M_EXTENDED_MSG)
#define MAX_EXTENDED_MESSAGES 8
#define DEFAULT_XMSG_MASK 0x00000000
#define MAX_XMSG_MASK 0x0000001f

Expand Down
18 changes: 14 additions & 4 deletions modules/FvwmEvent/FvwmEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ static event_entry extended_message_event_table[] =
EVENT_ENTRY( "enter_window", 0 ),
EVENT_ENTRY( "leave_window", 0 ),
EVENT_ENTRY( "property_change", 0),
EVENT_ENTRY( "monitor_enabled", -1),
EVENT_ENTRY( "monitor_disabled", -1),
EVENT_ENTRY( "monitor_changed", -1),
EVENT_ENTRY( "reply", 0), /* FvwmEvent will never receive MX_REPLY */
EVENT_ENTRY(NULL,0)
};
Expand Down Expand Up @@ -265,7 +268,7 @@ int main(int argc, char **argv)
/* Now MyName is defined */
if ((argc != 6)&&(argc != 7))
{
fvwm_debug(__func__, "%s Version "VERSION" should only be "
fprintf(stderr, "%s Version "VERSION" should only be "
"executed by fvwm!\n", MyName+1);
exit(1);
}
Expand Down Expand Up @@ -472,6 +475,9 @@ void execute_event(event_entry *event_table, short event, unsigned long *body)
int action_arg = event_table[event].action_arg;
int fw = 0;

fprintf(stderr, "MONITOR: CL: %s, ACTION: %s\n",
cmd_line, action);

if (action_arg != -1 && !(action_arg & ARG_NO_WINID))
{
fw = body[action_arg];
Expand All @@ -496,6 +502,7 @@ void execute_event(event_entry *event_table, short event, unsigned long *body)
sprintf(buf,"%s %s", cmd_line, action);
}
/* let fvwm execute the function */
fprintf(stderr, "MONITOR SENDING: %s\n", buf);
SendText(fd, buf, fw);
last_time = now;
}
Expand Down Expand Up @@ -532,6 +539,7 @@ void handle_config_line(char *buf, char **phost)
"Cmd",
"Delay",
"Dir",
"PassMonitor",
"PassID",
"PlayCmd",
"RplayHost",
Expand Down Expand Up @@ -682,8 +690,7 @@ void handle_config_line(char *buf, char **phost)
{
free(action);
}
fvwm_debug(__func__,
"%s: incomplete event definition %s\n",
fprintf(stderr, "%s: incomplete event definition %s\n",
MyName + 1, buf);
return;
}
Expand All @@ -699,12 +706,14 @@ void handle_config_line(char *buf, char **phost)
{
if (MatchToken(event, loop_event->name))
{
fprintf(stderr, "event: %s, lne: %s\n", event, loop_event->name);
if (loop_event->action.action != NULL)
{
free(loop_event->action.action);
}
loop_event->action.action = action;
found = 1;
fprintf(stderr, "MONITOR USING ACTION: %s\n", action);
if (*event_table == message_event_table)
{
m_selected |= (1 << i);
Expand All @@ -713,6 +722,7 @@ void handle_config_line(char *buf, char **phost)
*event_table ==
extended_message_event_table)
{
fprintf(stderr, "ET MONITOR %d\n", i);
mx_selected |= (1 << i);
}
}
Expand All @@ -721,7 +731,7 @@ void handle_config_line(char *buf, char **phost)
}
if (!found)
{
fvwm_debug(__func__, "%s: unknown event type: %s\n",
fprintf(stderr, "%s: unknown event type: %s\n",
MyName+1, event);
if (action)
{
Expand Down

0 comments on commit 0ddfcbd

Please sign in to comment.