示例#1
0
void FocusedAXObserverCallback(AXObserverRef Observer, AXUIElementRef Element, CFStringRef Notification, void *ContextData)
{
    pthread_mutex_lock(&KWMThread.Lock);

    window_info *Window = KWMFocus.Window;
    if(Window && CFEqual(Notification, kAXTitleChangedNotification))
        Window->Name = AXLibGetWindowTitle(Element);
    else if(CFEqual(Notification, kAXFocusedWindowChangedNotification))
    {
        if(!Window || Window->WID != AXLibGetWindowID(Element))
        {
            window_info *OSXWindow = GetWindowByID(AXLibGetWindowID(Element));
            screen_info *OSXScreen = GetDisplayOfWindow(OSXWindow);
            if(OSXWindow && OSXScreen)
            {
                screen_info *ScreenOfWindow = GetDisplayOfWindow(Window);
                bool SameScreen = ScreenOfWindow == OSXScreen;
                if(ScreenOfWindow && !SameScreen)
                    UpdateActiveWindowList(ScreenOfWindow);

                if(ScreenOfWindow && Window &&
                   GetWindowByID(Window->WID) == NULL &&
                   !SameScreen)
                {
                    space_info *SpaceOfWindow = GetActiveSpaceOfScreen(ScreenOfWindow);
                    if(SpaceOfWindow->Settings.Mode == SpaceModeBSP)
                        RemoveWindowFromBSPTree(ScreenOfWindow, Window->WID, false, false);
                    else if(SpaceOfWindow->Settings.Mode == SpaceModeMonocle)
                        RemoveWindowFromMonocleTree(ScreenOfWindow, Window->WID, false, false);

                    SpaceOfWindow->FocusedWindowID = -1;
                }

                if(!SameScreen)
                    GiveFocusToScreen(OSXScreen->ID, NULL, false, false);

                SetKwmFocus(Element);
                if(SameScreen && !IsFocusedWindowFloating())
                    KWMFocus.InsertionPoint = KWMFocus.Cache;
            }
        }
    }
    else if(Window &&
           (CFEqual(Notification, kAXWindowResizedNotification) ||
            CFEqual(Notification, kAXWindowMovedNotification)))
    {
        if(KWMTiling.LockToContainer)
            LockWindowToContainerSize(Window);

        UpdateBorder("focused");
    }
    else if(CFEqual(Notification, kAXUIElementDestroyedNotification) ||
            CFEqual(Notification, kAXWindowMiniaturizedNotification))
    {
        UpdateBorder("focused");
    }

    pthread_mutex_unlock(&KWMThread.Lock);
}
示例#2
0
void FocusedAXObserverCallback(AXObserverRef Observer, AXUIElementRef Element, CFStringRef Notification, void *ContextData)
{
    Assert(Element, "AXOBserverCallback() Element was null")

    window_info *Window = KWMFocus.Window;
    if(!Window)
        return;

    if(CFEqual(Notification, kAXTitleChangedNotification))
        Window->Name = GetWindowTitle(Element);

    if(IsWindowFloating(Window->WID, NULL) ||
       IsApplicationFloating(Window))
        UpdateBorder("focused");

    if(!IsWindowFloating(Window->WID, NULL) &&
        KWMToggles.EnableDragAndDrop &&
        KWMToggles.DragInProgress &&
        CFEqual(Notification, kAXWindowMovedNotification))
    {
        KWMToggles.DragInProgress = false;
        KWMTiling.FloatingWindowLst.push_back(Window->WID);
        RemoveWindowFromBSPTree(KWMScreen.Current, Window->WID, false, false);

        if(KWMMode.Focus != FocusModeDisabled &&
           KWMMode.Focus != FocusModeAutofocus &&
           KWMToggles.StandbyOnFloat)
        {
            KWMMode.Focus = FocusModeStandby;
        }
    }
}
示例#3
0
文件: keys.cpp 项目: chrishoage/kwm
bool KwmMainHotkeyTrigger(CGEventRef *Event)
{
    modifiers Mod = {};
    CGEventFlags Flags = CGEventGetFlags(*Event);
    Mod.CmdKey = (Flags & kCGEventFlagMaskCommand) == kCGEventFlagMaskCommand;
    Mod.AltKey = (Flags & kCGEventFlagMaskAlternate) == kCGEventFlagMaskAlternate;
    Mod.CtrlKey = (Flags & kCGEventFlagMaskControl) == kCGEventFlagMaskControl;
    Mod.ShiftKey = (Flags & kCGEventFlagMaskShift) == kCGEventFlagMaskShift;
    CGKeyCode Keycode = (CGKeyCode)CGEventGetIntegerValueField(*Event, kCGKeyboardEventKeycode);

    if(KWMHotkeys.Prefix.Enabled && KwmIsPrefixKey(&KWMHotkeys.Prefix.Key, &Mod, Keycode))
    {
        KWMHotkeys.Prefix.Active = true;
        KWMHotkeys.Prefix.Time = std::chrono::steady_clock::now();
        if(PrefixBorder.Enabled)
        {
            ClearBorder(&FocusedBorder);
            UpdateBorder("focused");
        }

        return true;
    }

    return KwmExecuteHotkey(Mod, Keycode);
}
示例#4
0
void MutIconShapeClass<T>::GotFocus() {
#ifdef DEBUG
	DEBUGLOG (other, _T("Current focus is at"));
	wxWindow * focuswin =wxWindow::FindFocus();
	if (focuswin) {
		DEBUGLOGTYPE (other,
			      (*(focuswin)),
			      _T(" focus has objet %p"),
			      (void*)wxWindow::FindFocus());
	} else
		DEBUGLOG(other,_T("NULL pointer"));
#endif
/*
	parenttype::SetFocus();
#ifdef DEBUG
	DEBUGLOG (other, _T("Current focus is at"));
	focuswin =wxWindow::FindFocus();
	if (focuswin) {
		DEBUGLOGTYPE (other,
			      (*(focuswin)),
			      _T(" focus has objet %p"),
			      wxWindow::FindFocus());
	} else
		DEBUGLOG(other,_T("NULL pointer"));
#endif
*/
	UpdateBorder(wxBORDER_SUNKEN);
}
示例#5
0
void MarkedAXObserverCallback(AXObserverRef Observer, AXUIElementRef Element, CFStringRef Notification, void *ContextData)
{
    pthread_mutex_lock(&KWMThread.Lock);

    window_info *Window = &KWMScreen.MarkedWindow;
    if(Window->WID != 0 && Window->WID != -1)
    {
        if(CFEqual(Notification, kAXWindowResizedNotification) ||
           CFEqual(Notification, kAXWindowMovedNotification))
            UpdateBorder("marked");
        else if(CFEqual(Notification, kAXUIElementDestroyedNotification) ||
                CFEqual(Notification, kAXWindowMiniaturizedNotification))
            UpdateBorder("marked");
    }

    pthread_mutex_unlock(&KWMThread.Lock);
}
示例#6
0
文件: keys.cpp 项目: JakimLi/kwm
void KwmActivateBindingMode(std::string Mode)
{
    mode *BindingMode = GetBindingMode(Mode);
    if(!DoesBindingModeExist(Mode))
        BindingMode = GetBindingMode("default");

    KWMHotkeys.ActiveMode = BindingMode;
    UpdateBorder("focused");
    if(BindingMode->Prefix)
        BindingMode->Time = std::chrono::steady_clock::now();
}
示例#7
0
void FocusedAXObserverCallback(AXObserverRef Observer, AXUIElementRef Element, CFStringRef Notification, void *ContextData)
{
    pthread_mutex_lock(&KWMThread.Lock);

    window_info *Window = KWMFocus.Window;
    if(Window && CFEqual(Notification, kAXTitleChangedNotification))
        Window->Name = GetWindowTitle(Element);
    else if(CFEqual(Notification, kAXWindowResizedNotification) ||
            CFEqual(Notification, kAXWindowMovedNotification))
        UpdateBorder("focused");

    pthread_mutex_unlock(&KWMThread.Lock);
}
示例#8
0
文件: keys.cpp 项目: Karunamon/kwm
void CheckPrefixTimeout()
{
    if(KWMHotkeys.Prefix.Active)
    {
        kwm_time_point NewPrefixTime = std::chrono::steady_clock::now();
        std::chrono::duration<double> Diff = NewPrefixTime - KWMHotkeys.Prefix.Time;
        if(Diff.count() > KWMHotkeys.Prefix.Timeout)
        {
            KWMHotkeys.Prefix.Active = false;
            ClearBorder(&PrefixBorder);
            UpdateBorder("focused");
        }
    }
}
示例#9
0
文件: kwm.cpp 项目: koekeishiya/kwm
int main(int argc, char **argv)
{
    if(ParseArguments(argc, argv))
        return 0;

    NSApplicationLoad();
    if(!AXLibDisplayHasSeparateSpaces())
        Fatal("Error: 'Displays have separate spaces' must be enabled!");

    AXLibInit(&AXState);
    AXLibStartEventLoop();
    if(!KwmStartDaemon())
        Fatal("Error: Could not start daemon!");

	OverlayLibInitialize();
	DEBUG("OverlayLib initialized!");

    ax_display *MainDisplay = AXLibMainDisplay();
    ax_display *Display = MainDisplay;
    do
    {
        ax_space *PrevSpace = Display->Space;
        Display->Space = AXLibGetActiveSpace(Display);
        Display->PrevSpace = PrevSpace;
        Display = AXLibNextDisplay(Display);
    } while(Display != MainDisplay);

    FocusedDisplay = MainDisplay;
    FocusedApplication = AXLibGetFocusedApplication();

    KwmInit();
    KwmParseConfig(KWMPath.Config);
    KwmExecuteInitScript();

    CreateWindowNodeTree(MainDisplay);

    /* TODO(koekeishiya): Probably want to defer this to run at some point where we know that
     * the focused application is set. This is usually the case as 'Finder' is always reported
     * as the active application when nothing is running. The following behaviour requries
     * refinement, because we will (sometimes ?) get NULL when started by launchd at login */
    if(FocusedApplication && FocusedApplication->Focus)
        UpdateBorder(&FocusedBorder, FocusedApplication->Focus);

    ConfigureRunLoop();
    CFRunLoopRun();
    return 0;
}
示例#10
0
文件: port.c 项目: Nebuleon/ReGBA
void ReGBA_MaxBlockSizeReached(uint32_t BlockStartPC, uint32_t BlockEndPC, uint32_t BlockSize)
{
	DS2_FillScreen(DS_ENGINE_MAIN, BGR555(15, 0, 0));
	char Line[512];

	draw_string_vcenter(DS2_GetMainScreen(), 0, 0, 256, COLOR_WHITE, "Guru Meditation");
	sprintf(Line, "Native code block size reached (%" PRIu32 ")", BlockSize);
	BDF_RenderUTF8s(DS2_GetMainScreen(), DS_SCREEN_WIDTH, 0, 32, COLOR_TRANS, COLOR_WHITE, Line);

	sprintf(Line, "at addresses %08" PRIX32 " .. %08" PRIX32, BlockStartPC, BlockEndPC);
	BDF_RenderUTF8s(DS2_GetMainScreen(), DS_SCREEN_WIDTH, 0, 48, COLOR_TRANS, COLOR_WHITE, Line);

	draw_string_vcenter(DS2_GetMainScreen(), 0, 80, 256, COLOR_WHITE, "The game has encountered a recoverable error. It has not crashed, but due to this, it soon may.");
	DS2_FlipMainScreen();
	UpdateBorder();

	DS2_AwaitAnyButtons();
	DS2_AwaitNoButtons();
}
示例#11
0
void FocusedAXObserverCallback(AXObserverRef Observer, AXUIElementRef Element, CFStringRef Notification, void *ContextData)
{
    if(KWMToggles.EnableDragAndDrop &&
       KWMToggles.DragInProgress &&
       CFEqual(Notification, kAXWindowMovedNotification) &&
       !IsWindowFloating(KWMFocus.Window->WID, NULL))
    {
        KWMToggles.DragInProgress = false;
        KWMTiling.FloatingWindowLst.push_back(KWMFocus.Window->WID);
        RemoveWindowFromBSPTree(KWMScreen.Current, KWMFocus.Window->WID, false, false);

        if(KWMMode.Focus != FocusModeDisabled && KWMMode.Focus != FocusModeAutofocus && KWMToggles.StandbyOnFloat)
            KWMMode.Focus = FocusModeStandby;
    }

    if(CFEqual(Notification, kAXTitleChangedNotification) && KWMFocus.Window)
        KWMFocus.Window->Name = GetWindowTitle(Element);

    if(IsFocusedWindowFloating())
        UpdateBorder("focused");
}
示例#12
0
文件: port.c 项目: Nebuleon/ReGBA
void ReGBA_DisplayFPS(void)
{
	uint32_t Visible = gpsp_persistent_config.DisplayFPS;
	if (Visible) {
		clock_t now = clock(), duration = now - Stats.LastFPSCalculationTime;
		if (duration >= CLOCKS_PER_SEC /* 1 second */) {
			Stats.RenderedFPS = Stats.RenderedFrames * CLOCKS_PER_SEC / duration;
			Stats.RenderedFrames = 0;
			Stats.EmulatedFPS = Stats.EmulatedFrames * CLOCKS_PER_SEC / duration;
			Stats.EmulatedFrames = 0;
			Stats.LastFPSCalculationTime = now;
			UpdateBorder();
		} else
			Visible = Stats.RenderedFPS != -1 && Stats.EmulatedFPS != -1;
	}

	// Blacken the bottom bar
	memset(DS2_GetMainScreen() + DS_SCREEN_WIDTH * 177, 0, DS_SCREEN_WIDTH * 15 * sizeof(uint16_t));
	if (Visible) {
		char line[512];
		sprintf(line, msg[FMT_STATUS_FRAMES_PER_SECOND], Stats.RenderedFPS, Stats.EmulatedFPS);
		PRINT_STRING_BG(DS2_GetMainScreen(), line, COLOR_WHITE, COLOR_BLACK, 1, 177);
	}
}
示例#13
0
internal void
KwmConfigCommand(std::vector<std::string> &Tokens)
{
    if(Tokens[1] == "reload")
    {
        KwmReloadConfig();
    }
    else if(Tokens[1] == "optimal-ratio")
    {
        KWMSettings.OptimalRatio = ConvertStringToDouble(Tokens[2]);
    }
    else if(Tokens[1] == "border")
    {
        if(Tokens[2] == "focused")
        {
            if(Tokens[3] == "on")
            {
                FocusedBorder.Enabled = true;
                UpdateBorder("focused");
            }
            else if(Tokens[3] == "off")
            {
                FocusedBorder.Enabled = false;
                UpdateBorder("focused");
            }
            else if(Tokens[3] == "size")
            {
                FocusedBorder.Width = ConvertStringToInt(Tokens[4]);
            }
            else if(Tokens[3] == "color")
            {
                FocusedBorder.Color = ConvertHexRGBAToColor(ConvertHexStringToInt(Tokens[4]));
                CreateColorFormat(&FocusedBorder.Color);
                mode *BindingMode = GetBindingMode("default");
                BindingMode->Color = FocusedBorder.Color;
            }
            else if(Tokens[3] == "radius")
            {
                FocusedBorder.Radius = ConvertStringToDouble(Tokens[4]);
            }
        }
        else if(Tokens[2] == "marked")
        {
            if(Tokens[3] == "on")
            {
                MarkedBorder.Enabled = true;
            }
            else if(Tokens[3] == "off")
            {
                MarkedBorder.Enabled = false;
                UpdateBorder("marked");
            }
            else if(Tokens[3] == "size")
            {
                MarkedBorder.Width = ConvertStringToInt(Tokens[4]);
            }
            else if(Tokens[3] == "color")
            {
                MarkedBorder.Color = ConvertHexRGBAToColor(ConvertHexStringToInt(Tokens[4]));
                CreateColorFormat(&MarkedBorder.Color);
            }
            else if(Tokens[3] == "radius")
            {
                MarkedBorder.Radius = ConvertStringToDouble(Tokens[4]);
            }
        }
    }
    else if(Tokens[1] == "float-non-resizable")
    {
        if(Tokens[2] == "off")
            KWMSettings.FloatNonResizable = false;
        else if(Tokens[2] == "on")
            KWMSettings.FloatNonResizable = true;
    }
    else if(Tokens[1] == "lock-to-container")
    {
        if(Tokens[2] == "off")
            KWMSettings.LockToContainer = false;
        else if(Tokens[2] == "on")
            KWMSettings.LockToContainer = true;
    }
    else if(Tokens[1] == "spawn")
    {
        if(Tokens[2] == "left")
            KWMSettings.SpawnAsLeftChild = true;
        else if(Tokens[2] == "right")
            KWMSettings.SpawnAsLeftChild = false;
    }
    else if(Tokens[1] == "tiling")
    {
        if(Tokens[2] == "bsp")
            KWMSettings.Space = SpaceModeBSP;
        else if(Tokens[2] == "monocle")
            KWMSettings.Space = SpaceModeMonocle;
        else if(Tokens[2] == "float")
            KWMSettings.Space = SpaceModeFloating;
    }
    else if(Tokens[1] == "space")
    {
        int ScreenID = ConvertStringToInt(Tokens[2]);
        int DesktopID = ConvertStringToInt(Tokens[3]);
        space_settings *SpaceSettings = GetSpaceSettingsForDesktopID(ScreenID, DesktopID);
        if(!SpaceSettings)
        {
            space_identifier Lookup = { ScreenID, DesktopID };
            space_settings NULLSpaceSettings = { KWMSettings.DefaultOffset, SpaceModeDefault, "", ""};

            space_settings *ScreenSettings = GetSpaceSettingsForDisplay(ScreenID);
            if(ScreenSettings)
                NULLSpaceSettings = *ScreenSettings;

            KWMSettings.SpaceSettings[Lookup] = NULLSpaceSettings;
            SpaceSettings = &KWMSettings.SpaceSettings[Lookup];
        }

        if(Tokens[4] == "mode")
        {
            if(Tokens[5] == "bsp")
                SpaceSettings->Mode = SpaceModeBSP;
            else if(Tokens[5] == "monocle")
                SpaceSettings->Mode = SpaceModeMonocle;
            else if(Tokens[5] == "float")
                SpaceSettings->Mode = SpaceModeFloating;
        }
        else if(Tokens[4] == "padding")
        {
            SpaceSettings->Offset.PaddingTop = ConvertStringToDouble(Tokens[5]);
            SpaceSettings->Offset.PaddingBottom = ConvertStringToDouble(Tokens[6]);
            SpaceSettings->Offset.PaddingLeft = ConvertStringToDouble(Tokens[7]);
            SpaceSettings->Offset.PaddingRight = ConvertStringToDouble(Tokens[8]);
        }
        else if(Tokens[4] == "gap")
        {
            SpaceSettings->Offset.VerticalGap = ConvertStringToDouble(Tokens[5]);
            SpaceSettings->Offset.HorizontalGap = ConvertStringToDouble(Tokens[6]);
        }
        else if(Tokens[4] == "name")
        {
            SpaceSettings->Name = Tokens[5];
        }
        else if(Tokens[4] == "tree")
        {
            SpaceSettings->Layout = Tokens[5];
        }
    }
    else if(Tokens[1] == "display")
    {
        int ScreenID = ConvertStringToInt(Tokens[2]);
        space_settings *DisplaySettings = GetSpaceSettingsForDisplay(ScreenID);
        if(!DisplaySettings)
        {
            space_settings NULLSpaceSettings = { KWMSettings.DefaultOffset, SpaceModeDefault, "", "" };
            KWMSettings.DisplaySettings[ScreenID] = NULLSpaceSettings;
            DisplaySettings = &KWMSettings.DisplaySettings[ScreenID];
        }

        if(Tokens[3] == "mode")
        {
            if(Tokens[4] == "bsp")
                DisplaySettings->Mode = SpaceModeBSP;
            else if(Tokens[4] == "monocle")
                DisplaySettings->Mode = SpaceModeMonocle;
            else if(Tokens[4] == "float")
                DisplaySettings->Mode = SpaceModeFloating;
        }
        else if(Tokens[3] == "padding")
        {
            DisplaySettings->Offset.PaddingTop = ConvertStringToDouble(Tokens[4]);
            DisplaySettings->Offset.PaddingBottom = ConvertStringToDouble(Tokens[5]);
            DisplaySettings->Offset.PaddingLeft = ConvertStringToDouble(Tokens[6]);
            DisplaySettings->Offset.PaddingRight = ConvertStringToDouble(Tokens[7]);
        }
        else if(Tokens[3] == "gap")
        {
            DisplaySettings->Offset.VerticalGap = ConvertStringToDouble(Tokens[4]);
            DisplaySettings->Offset.HorizontalGap = ConvertStringToDouble(Tokens[5]);
        }
    }
    else if(Tokens[1] == "focus-follows-mouse")
    {
        if(Tokens[2] == "toggle")
        {
            if(KWMSettings.Focus == FocusModeDisabled)
                KWMSettings.Focus = FocusModeAutoraise;
            else if(KWMSettings.Focus == FocusModeAutoraise)
                KWMSettings.Focus = FocusModeDisabled;
        }
        else if(Tokens[2] == "on")
            KWMSettings.Focus = FocusModeAutoraise;
        else if(Tokens[2] == "off")
            KWMSettings.Focus = FocusModeDisabled;
    }
    else if(Tokens[1] == "mouse-follows-focus")
    {
        if(Tokens[2] == "off")
            KWMSettings.UseMouseFollowsFocus = false;
        else if(Tokens[2] == "on")
            KWMSettings.UseMouseFollowsFocus = true;
    }
    else if(Tokens[1] == "standby-on-float")
    {
        if(Tokens[2] == "off")
            KWMSettings.StandbyOnFloat = false;
        else if(Tokens[2] == "on")
            KWMSettings.StandbyOnFloat = true;
    }
    else if(Tokens[1] == "cycle-focus")
    {
        if(Tokens[2] == "on")
            KWMSettings.Cycle = CycleModeScreen;
        else if(Tokens[2] == "off")
            KWMSettings.Cycle = CycleModeDisabled;;
    }
    else if(Tokens[1] == "hotkeys")
    {
        if(Tokens[2] == "off")
            KWMSettings.UseBuiltinHotkeys = false;
        else if(Tokens[2] == "on")
            KWMSettings.UseBuiltinHotkeys = true;
    }
    else if(Tokens[1] == "padding")
    {
        container_offset Offset = { ConvertStringToDouble(Tokens[2]),
                                    ConvertStringToDouble(Tokens[3]),
                                    ConvertStringToDouble(Tokens[4]),
                                    ConvertStringToDouble(Tokens[5]),
                                    0,
                                    0
                                  };

        SetDefaultPaddingOfDisplay(Offset);
    }
    else if(Tokens[1] == "gap")
    {
        container_offset Offset = { 0,
                                    0,
                                    0,
                                    0,
                                    ConvertStringToDouble(Tokens[2]),
                                    ConvertStringToDouble(Tokens[3])
                                  };

        SetDefaultGapOfDisplay(Offset);
    }
    else if(Tokens[1] == "split-ratio")
    {
        ChangeSplitRatio(ConvertStringToDouble(Tokens[2]));
    }
}
示例#14
0
void MutIconShapeClass<T>::LostFocus()
{
	TRACEC;
	UpdateBorder(wxBORDER_NONE);
}