Skip to content
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

[Newbie] Strange behavior on events #39

Open
nlamirault opened this issue Jun 16, 2017 · 0 comments
Open

[Newbie] Strange behavior on events #39

nlamirault opened this issue Jun 16, 2017 · 0 comments

Comments

@nlamirault
Copy link

i've got this code :

x, err := xgbutil.NewConnDisplay(os.Getenv(displayEnv))
	if err != nil {
		return nil, err
	}

	wm := &WindowManager{
		X:                x,
		WorkspaceManager: newWorkspaceManager(len(conf.Workspaces)),
	}
	wm.WorkspaceManager.Add(x, conf)
	wm.WorkspaceManager.Activate(0)

	panel, err := newPanel(x, wm)
	if err != nil {
		return nil, err
	}
	panel.Run()

	root := xwindow.New(x, x.RootWin())
	evMasks := xproto.EventMaskPropertyChange |
		xproto.EventMaskFocusChange |
		xproto.EventMaskButtonPress |
		xproto.EventMaskButtonRelease |
		xproto.EventMaskStructureNotify |
		xproto.EventMaskSubstructureRedirect |
		xproto.EventMaskSubstructureRedirect

	if err := root.Listen(evMasks); err != nil {
		return nil, err
	}

	keybind.Initialize(x)

	xevent.MapRequestFun(wm.handleMapRequest).Connect(x, x.RootWin())
	xevent.ConfigureRequestFun(wm.handleConfigureRequest).Connect(x, x.RootWin())
	xevent.ConfigureNotifyFun(wm.handleConfigureNotify).Connect(x, x.RootWin())
	if err := keybind.KeyPressFun(wm.handleActivateNextWorkspace).Connect(x, x.RootWin(), conf.Keybindings.NextWorkspace, true); err != nil {
		return nil, err
	}
	if err := keybind.KeyPressFun(wm.handleActivatePreviousWorkspace).Connect(x, x.RootWin(), conf.Keybindings.PreviousWorkspace, true); err != nil {
		return nil, err
	}


	return wm, nil
}

func (wm *WindowManager) handleMapRequest(x *xgbutil.XUtil, ev xevent.MapRequestEvent) {
	glog.V(2).Infof("Event: map request: %s", ev)
	x.Grab()
	defer x.Ungrab()

	w, err := newWindow(x, wm.activeWorkspace().WindowId(), ev.Window)
	if err != nil {
		glog.Errorf("Can't create windows: %s", err)
		return
	}
	w.Draw()
}

func (wm *WindowManager) handleConfigureRequest(x *xgbutil.XUtil, ev xevent.ConfigureRequestEvent) {
	glog.V(2).Infof("Event: configure request: %s", ev)
	xwindow.New(x, ev.Window).Configure(int(ev.ValueMask), int(ev.X), int(ev.Y), int(ev.Width)*2, int(ev.Height)*2, ev.Sibling, ev.StackMode)
}

func (wm *WindowManager) handleConfigureNotify(x *xgbutil.XUtil, ev xevent.ConfigureNotifyEvent) {
	glog.V(2).Infof("Event: configure notify: %s", ev)
}

When i add a termite application, i've got this log :

I0616 16:57:28.694279   28127 wm.go:137] Event: configure notify: ConfigureNotify {Sequence: 106, Event: 621, Window: 621, AboveSibling: 0, X: 0, Y: 0, Width: 1024, Height: 748, BorderWidth: 0, OverrideRedirect: false}
I0616 16:57:28.815842   28127 wm.go:132] Event: configure request: ConfigureRequest {Sequence: 106, StackMode: 0, Parent: 621, Window: 4194307, Sibling: 0, X: 0, Y: 0, Width: 722, Height: 434, BorderWidth: 0, ValueMask: 64}
I0616 16:57:28.815913   28127 wm.go:119] Event: map request: MapRequest {Sequence: 106, Parent: 621, Window: 4194307}

Do you know why i've got different width and height on configureNotify and configureRequest events ?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant