+
Skip to content

Improve RandR Detection #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 34 additions & 37 deletions fvwm/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
/* ---------------------------- included header files ---------------------- */

#include "config.h"
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/randr.h>

#if HAVE_SYS_BSDTYPES_H
#include <sys/bsdtypes.h>
Expand Down Expand Up @@ -1776,7 +1778,6 @@ void monitor_update_ewmh(void)
FvwmWindow *t;
struct monitor *m, *mref, *mo, *mo1;

fvwm_debug(__func__, "monitor debug...\n");
if (Scr.bo.do_debug_randr)
{
monitor_dump_state(NULL);
Expand All @@ -1786,8 +1787,8 @@ void monitor_update_ewmh(void)

RB_FOREACH(m, monitors, &monitor_q) {
if (m->flags & MONITOR_CHANGED) {
if (changed_monitor_count() == 1)
goto out;
fvwm_debug(__func__, "Applying EWMH changes to "
"existing %s", m->si->name);
TAILQ_FOREACH(mo, &monitorsold_q, oentry) {
if (strcmp(m->si->name, mo->si->name) != 0)
continue;
Expand All @@ -1799,41 +1800,39 @@ void monitor_update_ewmh(void)
update_fvwm_monitor(t);
}
}
m->emit |= MONITOR_CHANGED;
}
m->flags &= ~MONITOR_CHANGED;
continue;
}
if (m->flags & MONITOR_NEW) {
fvwm_debug(__func__, "Applying EWMH changes to new %s",
m->si->name);
int ewbs[4] = {0, 0, 0, 0};
if (m->Desktops == NULL) {
int ewbs[4] = {0, 0, 0, 0};

m->Desktops = fxcalloc(1, sizeof *m->Desktops);
m->Desktops->name = NULL;
m->Desktops->next = NULL;
m->Desktops->desk = 0;
apply_desktops_monitor(m);

if (m->Desktops->next == mref->Desktops->next)
continue;
}

calculate_page_sizes(m, mref->dx, mref->dy);
apply_desktops_monitor(m);
calculate_page_sizes(m, mref->dx, mref->dy);

fvwm_debug(__func__,
"new_monitor: %s (%p) compared to (%p)\n",
m->si->name,
m->Desktops->next,
mref->Desktops->next);
fvwm_debug(__func__,
"new_monitor: %s (%p) compared to (%p)\n",
m->si->name,
m->Desktops->next,
mref->Desktops->next);

m->virtual_scr.Vx = 0;
m->virtual_scr.Vy = 0;
m->virtual_scr.Vx = 0;
m->virtual_scr.Vy = 0;

set_ewmhc_strut_values(m, ewbs);
}
m->flags &= ~MONITOR_NEW;
set_ewmhc_strut_values(m, ewbs);
}
EWMH_Init(m);
}

out:
TAILQ_FOREACH_SAFE(mo, &monitorsold_q, oentry, mo1) {
TAILQ_REMOVE(&monitorsold_q, mo, oentry);
fvwm_debug(__func__, "Removed mo '%s' from processing",
Expand All @@ -1855,25 +1854,27 @@ monitor_emit_broadcast(void)
char *randrfunc = "RandRFunc";

RB_FOREACH (m, monitors, &monitor_q) {
if (m->emit & MONITOR_CHANGED) {
if (m->emit > 0)
fvwm_debug(__func__, "%s: emit: %d\n", m->si->name, m->emit);
if (m->emit &= ~MONITOR_CHANGED) {
BroadcastName(
MX_MONITOR_CHANGED, -1, -1, -1, m->si->name);
m->emit &= ~MONITOR_ALL;
m->flags &= ~MONITOR_CHANGED;
m->emit &= ~MONITOR_CHANGED;

/* Run the RandRFunc in case a user has set it. */
execute_function_override_window(
NULL, NULL, randrfunc, NULL, 0, NULL);
}
if (m->emit & MONITOR_ENABLED) {
if (m->emit &= ~MONITOR_ENABLED) {
BroadcastName(
MX_MONITOR_ENABLED, -1, -1, -1, m->si->name);

/* Run the RandRFunc in case a user has set it. */
execute_function_override_window(
NULL, NULL, randrfunc, NULL, 0, NULL);
}
if (m->emit & MONITOR_DISABLED) {
if (m->emit &= ~MONITOR_DISABLED) {
fvwm_debug(__func__, "MONITOR DISABLED: %s", m->si->name);
BroadcastName(
MX_MONITOR_DISABLED, -1, -1, -1, m->si->name);

Expand Down Expand Up @@ -4210,18 +4211,14 @@ void dispatch_event(XEvent *e)

XFlush(dpy);

XRRScreenChangeNotifyEvent *sce;

switch (e->type - randr_event) {
case RRScreenChangeNotify: {
sce = (XRRScreenChangeNotifyEvent *)e;
XRRUpdateConfiguration(e);
monitor_output_change(sce->display, sce);
monitor_update_ewmh();
monitor_emit_broadcast();
initPanFrames(NULL);
break;
}
case RRScreenChangeNotify:
XRRUpdateConfiguration(e);
monitor_output_change(e->xany.display, NULL);
monitor_update_ewmh();
monitor_emit_broadcast();
initPanFrames(NULL);
break;
}

if (w == Scr.Root)
Expand Down
14 changes: 13 additions & 1 deletion fvwm/ewmh.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "ewmh.h"
#include "ewmh_intern.h"
#include "geometry.h"
#include "virtual.h"
#include "window_flags.h"

#define EWMH_DEBUG 0
Expand Down Expand Up @@ -1944,6 +1945,17 @@ void EWMH_Init(struct monitor *m)

clean_up();

if (m->Desktops == NULL) {
m->Desktops = fxcalloc(1, sizeof *m->Desktops);
m->Desktops->name = NULL;
m->Desktops->next = NULL;
m->Desktops->desk = 0;

/* XXX: mempcy virtual_scr??? */

apply_desktops_monitor(m);
}

EWMH_SetDesktopNames(m);
EWMH_SetCurrentDesktop(m);
EWMH_SetNumberOfDesktops(m);
Expand All @@ -1952,7 +1964,7 @@ void EWMH_Init(struct monitor *m)
EWMH_SetClientList(m);
EWMH_SetClientListStacking(m);

return;
m->flags &= ~MONITOR_NEW;
}

/*
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载