/*
 * Copyright (c) 2018 Abex
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package net.runelite.mixins;

import java.awt.Canvas;
import java.awt.event.FocusListener;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSGameCanvas;

@Mixin(RSGameCanvas.class)
public abstract class RSGameCanvasMixin extends Canvas implements RSGameCanvas
{
	// This is inverted because it is false initialized.
	@Inject
	private static boolean shouldNotHaveFocus;

	@Inject
	@Override
	public void removeFocusListener(FocusListener l)
	{
		super.removeFocusListener(l);
		shouldNotHaveFocus = !this.hasFocus();
	}

	@Inject
	@Override
	public void requestFocus()
	{
		// Runescape requests focus whenever the window is resized. Because of this, PluginPanels cannot have focus
		// if they cause the sidebar to expand. This change prevents Runescape from requesting focus whenever it wants
		if (!shouldNotHaveFocus)
		{
			this.requestFocusInWindow();
		}
	}
}

@@ -23,16 +23,75 @@
 18 Abex%0A
+ * Copyright (c) 2018, Lotto %3Chttps://github.com/devLotto%3E%0A
  * All r
@@ -1579,16 +1579,92 @@
 .Mixin;%0A
+import net.runelite.api.mixins.Shadow;%0Aimport net.runelite.rs.api.RSClient;%0A
 import n
@@ -1696,16 +1696,16 @@
 Canvas;%0A
-
 %0A@Mixin(
@@ -1805,16 +1805,77 @@
 anvas%0A%7B%0A
+%09@Shadow(%22clientInstance%22)%0A%09private static RSClient client;%0A%0A
 %09// This
@@ -2429,16 +2429,16 @@
 us)%0A%09%09%7B%0A
-
 %09%09%09this.
@@ -2467,11 +2467,466 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09@Inject%0A%09@Override%0A%09public void setSize(int width, int height)%0A%09%7B%0A%09%09if (!client.isResized() && client.isStretchedEnabled())%0A%09%09%7B%0A%09%09%09super.setSize(getParent().getWidth(), getParent().getHeight());%0A%09%09%7D%0A%09%09else%0A%09%09%7B%0A%09%09%09super.setSize(width, height);%0A%09%09%7D%0A%09%7D%0A%0A%09@Inject%0A%09@Override%0A%09public void setLocation(int x, int y)%0A%09%7B%0A%09%09if (!client.isResized() && client.isStretchedEnabled())%0A%09%09%7B%0A%09%09%09super.setLocation(0, 0);%0A%09%09%7D%0A%09%09else%0A%09%09%7B%0A%09%09%09super.setLocation(x, y);%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Modify the size and location of the game canvas if stretched is enabled