mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add unminimize.
This commit is contained in:
parent
466185fc24
commit
c70c8217de
@ -12,6 +12,8 @@ import (
|
|||||||
type Desktop struct {
|
type Desktop struct {
|
||||||
Display string
|
Display string
|
||||||
|
|
||||||
|
Unminimize bool
|
||||||
|
|
||||||
ScreenWidth int
|
ScreenWidth int
|
||||||
ScreenHeight int
|
ScreenHeight int
|
||||||
ScreenRate int16
|
ScreenRate int16
|
||||||
@ -23,6 +25,11 @@ func (Desktop) Init(cmd *cobra.Command) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.PersistentFlags().Bool("desktop.unminimize", true, "automatically unminimize window when it is minimized")
|
||||||
|
if err := viper.BindPFlag("desktop.unminimize", cmd.PersistentFlags().Lookup("desktop.unminimize")); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +37,8 @@ func (s *Desktop) Set() {
|
|||||||
// Display is provided by env variable
|
// Display is provided by env variable
|
||||||
s.Display = os.Getenv("DISPLAY")
|
s.Display = os.Getenv("DISPLAY")
|
||||||
|
|
||||||
|
s.Unminimize = viper.GetBool("desktop.unminimize")
|
||||||
|
|
||||||
s.ScreenWidth = 1280
|
s.ScreenWidth = 1280
|
||||||
s.ScreenHeight = 720
|
s.ScreenHeight = 720
|
||||||
s.ScreenRate = 30
|
s.ScreenRate = 30
|
||||||
|
@ -45,6 +45,7 @@ func (manager *DesktopManagerCtx) Start() {
|
|||||||
Str("screen_size", fmt.Sprintf("%dx%d@%d", width, height, rate)).
|
Str("screen_size", fmt.Sprintf("%dx%d@%d", width, height, rate)).
|
||||||
Msgf("setting initial screen size")
|
Msgf("setting initial screen size")
|
||||||
|
|
||||||
|
xevent.Unminimize = manager.config.Unminimize
|
||||||
go xevent.EventLoop(manager.config.Display)
|
go xevent.EventLoop(manager.config.Display)
|
||||||
|
|
||||||
// In case it was opened
|
// In case it was opened
|
||||||
|
@ -83,7 +83,7 @@ void XEventLoop(char *name) {
|
|||||||
if (event.type == ClientMessage) {
|
if (event.type == ClientMessage) {
|
||||||
Window window = event.xclient.window;
|
Window window = event.xclient.window;
|
||||||
|
|
||||||
// check for window manager state change
|
// check for net window manager state (fullscreen, maximized, etc)
|
||||||
if (event.xclient.message_type == XInternAtom(display, "_NET_WM_STATE", 0)) {
|
if (event.xclient.message_type == XInternAtom(display, "_NET_WM_STATE", 0)) {
|
||||||
// see documentation in XWindowManagerStateEvent
|
// see documentation in XWindowManagerStateEvent
|
||||||
Atom action = event.xclient.data.l[0];
|
Atom action = event.xclient.data.l[0];
|
||||||
@ -122,6 +122,15 @@ void XEventLoop(char *name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for window manager change state (minimize, maximize, etc)
|
||||||
|
if (event.xclient.message_type == XInternAtom(display, "WM_CHANGE_STATE", 0)) {
|
||||||
|
int window_state = event.xclient.data.l[0];
|
||||||
|
// NormalState - The client's top-level window is viewable.
|
||||||
|
// IconicState - The client's top-level window is iconic (whatever that means for this window manager).
|
||||||
|
// WithdrawnState - Neither the client's top-level window nor its icon is visible.
|
||||||
|
goXEventWMChangeState(display, window, window_state);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var Emmiter events.EventEmmiter
|
var Emmiter events.EventEmmiter
|
||||||
|
var Unminimize bool = false
|
||||||
var file_chooser_dialog_window uint32 = 0
|
var file_chooser_dialog_window uint32 = 0
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -68,6 +69,17 @@ func goXEventUnmapNotify(window C.Window) {
|
|||||||
Emmiter.Emit("file-chooser-dialog-closed")
|
Emmiter.Emit("file-chooser-dialog-closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export goXEventWMChangeState
|
||||||
|
func goXEventWMChangeState(display *C.Display, window C.Window, window_state C.ulong) {
|
||||||
|
// if we just realized that window is minimized and we want it to be unminimized
|
||||||
|
if window_state != C.NormalState && Unminimize {
|
||||||
|
// we want to unmap and map the window to force it to redraw
|
||||||
|
C.XUnmapWindow(display, window)
|
||||||
|
C.XMapWindow(display, window)
|
||||||
|
C.XFlush(display)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//export goXEventError
|
//export goXEventError
|
||||||
func goXEventError(event *C.XErrorEvent, message *C.char) {
|
func goXEventError(event *C.XErrorEvent, message *C.char) {
|
||||||
Emmiter.Emit("event-error", uint8(event.error_code), C.GoString(message), uint8(event.request_code), uint8(event.minor_code))
|
Emmiter.Emit("event-error", uint8(event.error_code), C.GoString(message), uint8(event.request_code), uint8(event.minor_code))
|
||||||
|
@ -12,6 +12,7 @@ extern void goXEventCursorChanged(XFixesCursorNotifyEvent event);
|
|||||||
extern void goXEventClipboardUpdated();
|
extern void goXEventClipboardUpdated();
|
||||||
extern void goXEventConfigureNotify(Display *display, Window window, char *name, char *role);
|
extern void goXEventConfigureNotify(Display *display, Window window, char *name, char *role);
|
||||||
extern void goXEventUnmapNotify(Window window);
|
extern void goXEventUnmapNotify(Window window);
|
||||||
|
extern void goXEventWMChangeState(Display *display, Window window, ulong state);
|
||||||
extern void goXEventError(XErrorEvent *event, char *message);
|
extern void goXEventError(XErrorEvent *event, char *message);
|
||||||
extern int goXEventActive();
|
extern int goXEventActive();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user